Skip to content

Commit

Permalink
fixed #192
Browse files Browse the repository at this point in the history
  • Loading branch information
andrew-bibb committed Jan 9, 2022
1 parent c14007d commit 1f9a28f
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 15 deletions.
49 changes: 39 additions & 10 deletions apps/cmstapp/code/control_box/controlbox.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@ ControlBox::ControlBox(const QCommandLineParser& parser, QWidget *parent)
wifi_list.clear();
peer_list.clear();
vpn_list.clear();
vpnconn_list.clear();
agent = new ConnmanAgent(this);
vpnagent = new ConnmanVPNAgent(this);
counter = new ConnmanCounter(this);
Expand Down Expand Up @@ -381,8 +382,18 @@ ControlBox::ControlBox(const QCommandLineParser& parser, QWidget *parent)
ui.pushButton_vpn_editor->setEnabled(true);
ui.checkBox_killswitch->setEnabled(true);
shared::processReply(vpn_manager->call(QDBus::AutoDetect, "RegisterAgent", QVariant::fromValue(QDBusObjectPath(VPN_AGENT_OBJECT))) );
} // else register agent
} // else normal vpn manager

// connect vpn services to slots
QDBusMessage reply = vpn_manager->call("GetConnections");
shared::processReply(reply);
vpnconn_list.clear();
getArray(vpnconn_list, reply);
for (int i = 0; i < vpnconn_list.size(); ++i) {
QDBusConnection::systemBus().disconnect(DBUS_VPN_SERVICE, vpnconn_list.at(i).objpath.path(), "net.connman.vpn.Connection", "PropertyChanged", this, SLOT(dbsVPNPropertyChanged(QString, QDBusVariant, QDBusMessage)));
QDBusConnection::systemBus().connect(DBUS_VPN_SERVICE, vpnconn_list.at(i).objpath.path(), "net.connman.vpn.Connection", "PropertyChanged", this, SLOT(dbsVPNPropertyChanged(QString, QDBusVariant, QDBusMessage)));
} // vpnconn_list for loop
} // else enable vpn widgets, register agent, connect signals
} // else vpn_manager is valid
} // else have valid connection
} // else have connected systemBus

Expand Down Expand Up @@ -1220,10 +1231,28 @@ void ControlBox::dbsServicePropertyChanged(QString property, QDBusVariant dbvalu
else if (s_path == onlineobjectpath) {
onlineobjectpath.clear();
} // else if object went offline
} // if property contains State

// update the widgets
updateDisplayWidgets();

return;
}

//
// Slot called whenever a vpn connection issues a PropertyChanged signal on DBUS
void ControlBox::dbsVPNPropertyChanged(QString property, QDBusVariant dbvalue, QDBusMessage msg)
{
QString s_path = msg.path();
QVariant value = dbvalue.variant();

if (property == "State") {
// This is sort of a hack. Not all VPN service properties are signaled when they change (for instance Provider, IPV4). This slot was created to address that, plus we moved the notification code from dbsServicePropertyChanged to here. Force a new service list to be created.
getServices();

// Send notification if vpn changed
for (int i = 0; i < vpn_list.count(); ++i) {
if (s_path == vpn_list.at(i).objpath.path() ) {
for (int i = 0; i < vpnconn_list.count(); ++i) {
if (s_path == vpnconn_list.at(i).objpath.path() ) {
notifyclient->init();
if (value.toString() == "ready") {
notifyclient->setSummary(QString(tr("VPN Engaged")) );
Expand All @@ -1239,12 +1268,12 @@ void ControlBox::dbsServicePropertyChanged(QString property, QDBusVariant dbvalu
break;
} // if
} // for
} // if property contains State
} // if property = State

// update the widgets
updateDisplayWidgets();
// update the widgets
updateDisplayWidgets();

return;
return;
}

//
Expand Down Expand Up @@ -2000,7 +2029,7 @@ void ControlBox::assembleTabWireless()
ui.label_wifi_state->setText(tr(" WiFi Technologies:<br> %1 Found, %2 Powered").arg(i_wifidevices).arg(i_wifipowered) );
} // technologis if no errors

// Run through each service_list looking for wifi services
// Run through each services_list looking for wifi services
wifi_list.clear();

for (int row = 0; row < services_list.size(); ++row) {
Expand Down Expand Up @@ -2105,7 +2134,7 @@ void ControlBox::assembleTabVPN()
// Make sure we got the services_list before we try to work with it.
if ( (q16_errors & CMST::Err_Services ) != 0x00 ) return;

// Run through each service_list looking for vpn services
// Run through each services_list looking for vpn services
vpn_list.clear();
for (int row = 0; row < services_list.size(); ++row) {
QMap<QString,QVariant> map = services_list.at(row).objmap;
Expand Down
4 changes: 3 additions & 1 deletion apps/cmstapp/code/control_box/controlbox.h
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,8 @@ class ControlBox : public QDialog
QList<arrayElement> technologies_list;
QList<arrayElement> wifi_list;
QList<arrayElement> peer_list;
QList<arrayElement> vpn_list;
QList<arrayElement> vpn_list; // extracted from our services list
QList<arrayElement> vpnconn_list; // from vpn manager used for signals and slots
ConnmanAgent* agent;
ConnmanVPNAgent* vpnagent;
ConnmanCounter* counter;
Expand Down Expand Up @@ -189,6 +190,7 @@ class ControlBox : public QDialog
void dbsServicesChanged(QList<QVariant>, QList<QDBusObjectPath>, QDBusMessage);
void dbsPeersChanged(QList<QVariant>, QList<QDBusObjectPath>, QDBusMessage);
void dbsServicePropertyChanged(QString, QDBusVariant, QDBusMessage);
void dbsVPNPropertyChanged(QString, QDBusVariant, QDBusMessage);
void dbsTechnologyPropertyChanged(QString, QDBusVariant, QDBusMessage);
void dbsTechnologyAdded(QDBusObjectPath, QVariantMap);
void dbsTechnologyRemoved(QDBusObjectPath);
Expand Down
4 changes: 2 additions & 2 deletions apps/resource.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,9 @@ DEALINGS IN THE SOFTWARE.
///////////////////////////////// Program Values ///////////////////////
//
// Program Info (may be visible, but don't mark for tranalation)
#define VERSION "2022.01.02-1"
#define VERSION "2022.01.09-1"

#define RELEASE_DATE "02 December 2021"
#define RELEASE_DATE "05 January 2022"
#define COPYRIGHT_DATE "2013-2022"

// Program Values:
Expand Down
7 changes: 5 additions & 2 deletions text/changelog.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
<b><center>Connman System Tray (CMST)</center></b>
<b><center>Change Log</center></b>
<b> IN PROGRESS</b>
<b> In Progress </b>
<ul>
<li>Fix VPN parsing not being done in various display elements (issue #192)</li>
</ul>
<b> 2022.01.05 </b>
<ul>
<li>Desktop entry in .config/autostart is saved when enable/disable is toggled (issue #238).</li>
<li>Removed --use-mate and --use-xfce options from program (issue #237)</li>
Expand All @@ -9,7 +13,6 @@
<li>Auto run lupdate and embed translations automatically from make via qmake.</li>
<li>Added scroll bars to Agent dialog (issue #242).</li>
</ul>

<b> 2021.12.02</b>
<ul>
<li>Disable configuration button when service is VPN.</li>
Expand Down

0 comments on commit 1f9a28f

Please sign in to comment.