Skip to content

Commit

Permalink
fix #202
Browse files Browse the repository at this point in the history
  • Loading branch information
andrew-bibb committed Jan 9, 2022
1 parent 038a898 commit 7ef7261
Show file tree
Hide file tree
Showing 5 changed files with 127 additions and 73 deletions.
48 changes: 45 additions & 3 deletions apps/cmstapp/code/control_box/controlbox.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -456,6 +456,7 @@ ControlBox::ControlBox(const QCommandLineParser& parser, QWidget *parent)
connect(ui.pushButton_disconnect, SIGNAL(clicked()), this, SLOT(disconnectPressed()));
connect(ui.pushButton_vpn_disconnect, SIGNAL(clicked()), this, SLOT(disconnectPressed()));
connect(ui.pushButton_remove, SIGNAL(clicked()), this, SLOT(removePressed()));
connect(ui.pushButton_edit, SIGNAL(clicked()), this, SLOT(editPressed()));
connect(ui.pushButton_aboutCMST, SIGNAL(clicked()), this, SLOT(aboutCMST()));
connect(ui.pushButton_aboutIconSet, SIGNAL(clicked()), this, SLOT(aboutIconSet()));
connect(ui.pushButton_aboutOtherArt, SIGNAL(clicked()), this, SLOT(aboutOtherArt()));
Expand Down Expand Up @@ -826,7 +827,7 @@ void ControlBox::connectPressed()
// Slot to actually request a connection via DBUS. Called from the connectPressed() slot
void ControlBox::requestConnection()
{
// only way here is when a finished() signal fires, delete the object that did it
// if we got here because a finished() signal fireed delete the object that did it
if (proc) delete proc;
if (gened) delete gened;

Expand Down Expand Up @@ -918,7 +919,13 @@ void ControlBox::disconnectPressed()
// Called when ui.pushButton_remove is pressed
void ControlBox::removePressed()
{
// if no row selected return
// If there is only one row select it
if (ui.tableWidget_wifi->rowCount() == 1 ) {
QTableWidgetSelectionRange qtwsr = QTableWidgetSelectionRange(0, 0, 0, ui.tableWidget_wifi->columnCount() - 1);
ui.tableWidget_wifi->setRangeSelected(qtwsr, true);
}

// If no row is selected then return
QList<QTableWidgetItem*> list;
list.clear();
list = ui.tableWidget_wifi->selectedItems();
Expand All @@ -928,6 +935,10 @@ void ControlBox::removePressed()
return;
}

// calling Remove() on hidden or provisioned services will cause an error, so simply return now without executing the method.
QMap<QString,QVariant> map = wifi_list.at(list.at(0)->row()).objmap;
if(map.value("Name").toString().isEmpty() || map.value("Immutable").toBool() ) return;

// send the Remove message to the service
QDBusInterface* iface_serv = new QDBusInterface(DBUS_CON_SERVICE, wifi_list.at(list.at(0)->row()).objpath.path(), "net.connman.Service", QDBusConnection::systemBus(), this);
QDBusMessage reply = iface_serv->call(QDBus::AutoDetect, "Remove");
Expand All @@ -937,7 +948,38 @@ void ControlBox::removePressed()
return;
}

// dbs slots are slots to receive DBus Signals
//
// Slot to edit a Wifi service. Note that Connman does not provide a way to retrieve or edit a passphrase. Adding something like this is insecure as we don't know
// anything about the permissions the CMST user has. The best we can do issue a remove call then a connect call.
void ControlBox::editPressed()
{
// If there is only one row select it
if (ui.tableWidget_wifi->rowCount() == 1 ) {
QTableWidgetSelectionRange qtwsr = QTableWidgetSelectionRange(0, 0, 0, ui.tableWidget_wifi->columnCount() - 1);
ui.tableWidget_wifi->setRangeSelected(qtwsr, true);
}

// if no row selected return
QList<QTableWidgetItem*> list;
list.clear();
list = ui.tableWidget_wifi->selectedItems();
if (list.isEmpty() ) {
QMessageBox::information(this, tr("No Services Selected"),
tr("You need to select a Wifi service before pressing the edit button.") );
return;
}

// remove the connection
this->removePressed();

// connect the connection which will ask for user information if needed
pendingobjectpath = wifi_list.at(list.at(0)->row()).objpath.path();
this->requestConnection();

return;
}

// dbs slots: these slots are to receive DBus Signals
//
// Slot called whenever DBUS issues a PropertyChanged signal
void ControlBox::dbsPropertyChanged(QString prop, QDBusVariant dbvalue)
Expand Down
1 change: 1 addition & 0 deletions apps/cmstapp/code/control_box/controlbox.h
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,7 @@ class ControlBox : public QDialog
void requestConnection();
void disconnectPressed();
void removePressed();
void editPressed();
void dbsPropertyChanged(QString,QDBusVariant);
void dbsServicesChanged(QList<QVariant>, QList<QDBusObjectPath>, QDBusMessage);
void dbsPeersChanged(QList<QVariant>, QList<QDBusObjectPath>, QDBusMessage);
Expand Down
148 changes: 79 additions & 69 deletions apps/cmstapp/code/control_box/ui/controlbox.ui
Original file line number Diff line number Diff line change
Expand Up @@ -580,74 +580,6 @@
<string>&amp;Wireless</string>
</attribute>
<layout class="QGridLayout" name="gridLayout_5">
<item row="2" column="0">
<widget class="QTableWidget" name="tableWidget_wifi">
<property name="whatsThis">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;This page shows the known WiFi services. &lt;/p&gt;&lt;p&gt;&lt;span style=&quot; font-weight:600;&quot;&gt;Name:&lt;/span&gt; The SSID of the network.&lt;/p&gt;&lt;p&gt;&lt;span style=&quot; font-weight:600;&quot;&gt;Favorite:&lt;/span&gt; A heart symbol in this column indicates that this computer has previously made a connection to the network using this service.&lt;/p&gt;&lt;p&gt;&lt;span style=&quot; font-weight:600;&quot;&gt;Connected:&lt;/span&gt; Shows the connection state of this service. Hover the mouse over the icon to popup a text description. Online signals that an Internet connectionis available and has been verified. Ready signals a successfully connected device. &lt;/p&gt;&lt;p&gt;&lt;span style=&quot; font-weight:600;&quot;&gt;Security: &lt;/span&gt;Describes the type of security used for this service. Possible values are &amp;quot;none&amp;quot;, &amp;quot;wep&amp;quot;, &amp;quot;psk&amp;quot;, &amp;quot;ieee8021x&amp;quot;, and &amp;quot;wps&amp;quot;.&lt;/p&gt;&lt;p&gt;&lt;span style=&quot; font-weight:600;&quot;&gt;Signal Strength:&lt;/span&gt; The strength of the WiFi signal, normalized to a scale of 0 to 100.&lt;/p&gt;&lt;p&gt;&lt;br/&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="editTriggers">
<set>QAbstractItemView::NoEditTriggers</set>
</property>
<property name="showDropIndicator" stdset="0">
<bool>false</bool>
</property>
<property name="dragDropOverwriteMode">
<bool>false</bool>
</property>
<property name="selectionMode">
<enum>QAbstractItemView::SingleSelection</enum>
</property>
<property name="selectionBehavior">
<enum>QAbstractItemView::SelectRows</enum>
</property>
<property name="showGrid">
<bool>false</bool>
</property>
<property name="cornerButtonEnabled">
<bool>false</bool>
</property>
<property name="columnCount">
<number>5</number>
</property>
<attribute name="horizontalHeaderMinimumSectionSize">
<number>80</number>
</attribute>
<attribute name="horizontalHeaderStretchLastSection">
<bool>true</bool>
</attribute>
<attribute name="verticalHeaderVisible">
<bool>false</bool>
</attribute>
<attribute name="verticalHeaderHighlightSections">
<bool>false</bool>
</attribute>
<column>
<property name="text">
<string>Name</string>
</property>
</column>
<column>
<property name="text">
<string>Favorite</string>
</property>
</column>
<column>
<property name="text">
<string>Connected</string>
</property>
</column>
<column>
<property name="text">
<string>Security</string>
</property>
</column>
<column>
<property name="text">
<string>Signal Strength</string>
</property>
</column>
</widget>
</item>
<item row="1" column="0">
<widget class="QGroupBox" name="groupBox_wireless_utils">
<property name="title">
Expand Down Expand Up @@ -684,6 +616,16 @@
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="pushButton_edit">
<property name="whatsThis">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Select a wifi service in the table below and press this button to edit the service. &lt;/p&gt;&lt;p&gt;The service must have previously been successfully connected (Favorite is true) for this button to work. Pressing &lt;span style=&quot; font-weight:600;&quot;&gt;Edit&lt;/span&gt; will remove the service and then request credentials to establish the connection. If the service is currently connected it will be disconnected first. If the service required a passphrase then the old passphrase it will be cleared and forgotten.&lt;/p&gt;&lt;p&gt;Connman does not provide any methods to retrieve credentials (passphrases, etc.) as that is insecure. CMST will not work around this protection. All this button really does is automate pressing the &lt;span style=&quot; font-weight:600;&quot;&gt;Remove&lt;/span&gt; and &lt;span style=&quot; font-weight:600;&quot;&gt;Connect&lt;/span&gt; buttons above. Make sure you know all of the credentials to reconnect as the existing credentials will be cleared when this button is pressed.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="text">
<string>Edit</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="pushButton_rescanwifi02">
<property name="whatsThis">
Expand Down Expand Up @@ -726,6 +668,74 @@
</layout>
</widget>
</item>
<item row="2" column="0">
<widget class="QTableWidget" name="tableWidget_wifi">
<property name="whatsThis">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;This page shows the known WiFi services. &lt;/p&gt;&lt;p&gt;&lt;span style=&quot; font-weight:600;&quot;&gt;Name:&lt;/span&gt; The SSID of the network.&lt;/p&gt;&lt;p&gt;&lt;span style=&quot; font-weight:600;&quot;&gt;Favorite:&lt;/span&gt; A heart symbol in this column indicates that this computer has previously made a connection to the network using this service.&lt;/p&gt;&lt;p&gt;&lt;span style=&quot; font-weight:600;&quot;&gt;Connected:&lt;/span&gt; Shows the connection state of this service. Hover the mouse over the icon to popup a text description. Online signals that an Internet connectionis available and has been verified. Ready signals a successfully connected device. &lt;/p&gt;&lt;p&gt;&lt;span style=&quot; font-weight:600;&quot;&gt;Security: &lt;/span&gt;Describes the type of security used for this service. Possible values are &amp;quot;none&amp;quot;, &amp;quot;wep&amp;quot;, &amp;quot;psk&amp;quot;, &amp;quot;ieee8021x&amp;quot;, and &amp;quot;wps&amp;quot;.&lt;/p&gt;&lt;p&gt;&lt;span style=&quot; font-weight:600;&quot;&gt;Signal Strength:&lt;/span&gt; The strength of the WiFi signal, normalized to a scale of 0 to 100.&lt;/p&gt;&lt;p&gt;&lt;br/&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="editTriggers">
<set>QAbstractItemView::NoEditTriggers</set>
</property>
<property name="showDropIndicator" stdset="0">
<bool>false</bool>
</property>
<property name="dragDropOverwriteMode">
<bool>false</bool>
</property>
<property name="selectionMode">
<enum>QAbstractItemView::SingleSelection</enum>
</property>
<property name="selectionBehavior">
<enum>QAbstractItemView::SelectRows</enum>
</property>
<property name="showGrid">
<bool>false</bool>
</property>
<property name="cornerButtonEnabled">
<bool>false</bool>
</property>
<property name="columnCount">
<number>5</number>
</property>
<attribute name="horizontalHeaderMinimumSectionSize">
<number>80</number>
</attribute>
<attribute name="horizontalHeaderStretchLastSection">
<bool>true</bool>
</attribute>
<attribute name="verticalHeaderVisible">
<bool>false</bool>
</attribute>
<attribute name="verticalHeaderHighlightSections">
<bool>false</bool>
</attribute>
<column>
<property name="text">
<string>Name</string>
</property>
</column>
<column>
<property name="text">
<string>Favorite</string>
</property>
</column>
<column>
<property name="text">
<string>Connected</string>
</property>
</column>
<column>
<property name="text">
<string>Security</string>
</property>
</column>
<column>
<property name="text">
<string>Signal Strength</string>
</property>
</column>
</widget>
</item>
</layout>
</widget>
<widget class="QWidget" name="VPN">
Expand Down Expand Up @@ -1047,7 +1057,7 @@
<property name="geometry">
<rect>
<x>0</x>
<y>-22</y>
<y>0</y>
<width>621</width>
<height>663</height>
</rect>
Expand Down
2 changes: 1 addition & 1 deletion apps/resource.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ DEALINGS IN THE SOFTWARE.
///////////////////////////////// Program Values ///////////////////////
//
// Program Info (may be visible, but don't mark for tranalation)
#define VERSION "2022.01.09-2"
#define VERSION "2022.01.09-3"

#define RELEASE_DATE "05 January 2022"
#define COPYRIGHT_DATE "2013-2022"
Expand Down
1 change: 1 addition & 0 deletions text/changelog.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
<b><center>Change Log</center></b>
<b> In Progress </b>
<ul>
<li>Added Edit button to Wifi Services (issue #202)</li>
<li>Removed obsolete managerRescan() function, moved code to where needed.</li>
<li>Fix VPN parsing not being done in various display elements (issue #192)</li>
</ul>
Expand Down

0 comments on commit 7ef7261

Please sign in to comment.