Skip to content

Commit ddce803

Browse files
committed
clear counters control working
1 parent 9a8ecad commit ddce803

File tree

4 files changed

+35
-22
lines changed

4 files changed

+35
-22
lines changed

code/control_box/controlbox.cpp

Lines changed: 24 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,9 @@ ControlBox::ControlBox(const QCommandLineParser& parser, QWidget *parent)
138138
if (! parser.isSet("disable-counters"))
139139
connect(counter, SIGNAL(usageUpdated(QDBusObjectPath, QString, QString)), this, SLOT(counterUpdated(QDBusObjectPath, QString, QString)));
140140

141+
// restore GUI settings
142+
this->readSettings();
143+
141144
// setup the dbus interface to connman.manager
142145
if (! QDBusConnection::systemBus().isConnected() ) logErrors(CMST::Err_No_DBus);
143146
else {
@@ -166,6 +169,10 @@ ControlBox::ControlBox(const QCommandLineParser& parser, QWidget *parent)
166169
QDBusConnection::systemBus().connect(DBUS_SERVICE, DBUS_PATH, DBUS_MANAGER, "ServicesChanged", this, SLOT(dbsServicesChanged(QMap<QString, QVariant>, QList<QDBusObjectPath>, QDBusMessage)));
167170
QDBusConnection::systemBus().connect(DBUS_SERVICE, DBUS_PATH, DBUS_MANAGER, "TechnologyAdded", this, SLOT(dbsTechnologyAdded(QDBusObjectPath, QVariantMap)));
168171
QDBusConnection::systemBus().connect(DBUS_SERVICE, DBUS_PATH, DBUS_MANAGER, "TechnologyRemoved", this, SLOT(dbsTechnologyRemoved(QDBusObjectPath)));
172+
173+
// clear the counters if selected
174+
this->clearCounters();
175+
169176
} // else have valid connection
170177
} // else have connected systemBus
171178

@@ -241,10 +248,7 @@ ControlBox::ControlBox(const QCommandLineParser& parser, QWidget *parent)
241248

242249
// start the timer
243250
wifi_timer->start();
244-
245-
// restore GUI settings
246-
this->readSettings();
247-
251+
248252
// set up and fill in the display widgets
249253
this->updateDisplayWidgets();
250254
}
@@ -624,14 +628,8 @@ void ControlBox::dbsServicesChanged(QMap<QString, QVariant> vmap, QList<QDBusObj
624628
} // for
625629
} // if we needed to remove something
626630

627-
////////////////WORKING NOT CORRECT YET
628-
// reset the counters if we chose to
629-
//if (ui.checkBox_resetcounters->isChecked() ) {
630-
//QDBusInterface* iface_serv = new QDBusInterface(DBUS_SERVICE, serviceOnline().path(), "net.connman.Service", QDBusConnection::systemBus(), this);
631-
//iface_serv->call(QDBus::NoBlock, "ResetCounters");
632-
//iface_serv->deleteLater();
633-
//}
634-
631+
// clear the counters (if selected) and update the widgets'
632+
clearCounters();
635633
updateDisplayWidgets();
636634

637635
return;
@@ -1698,3 +1696,17 @@ QDBusObjectPath ControlBox::serviceOnline()
16981696

16991697
return service_online;
17001698
}
1699+
1700+
//
1701+
// Function to clear the counters if selected in the ui. Called from the constructor
1702+
// and from dbsServicesChanged
1703+
void ControlBox::clearCounters()
1704+
{
1705+
if (ui.checkBox_resetcounters->isChecked() ) {
1706+
QDBusInterface* iface_serv = new QDBusInterface(DBUS_SERVICE, serviceOnline().path(), "net.connman.Service", QDBusConnection::systemBus(), this);
1707+
iface_serv->call(QDBus::NoBlock, "ResetCounters");
1708+
iface_serv->deleteLater();
1709+
}
1710+
1711+
return;
1712+
}

code/control_box/controlbox.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,8 @@ class ControlBox : public QDialog
159159
bool extractMapData(QMap<QString,QVariant>&,const QVariant&);
160160
void logErrors(const quint8&);
161161
QString readResourceText(const char*);
162-
QDBusObjectPath serviceOnline();
162+
QDBusObjectPath serviceOnline();
163+
void clearCounters();
163164

164165
private slots:
165166
void updateDisplayWidgets();

code/control_box/ui/controlbox.ui

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -650,8 +650,8 @@
650650
<rect>
651651
<x>0</x>
652652
<y>0</y>
653-
<width>98</width>
654-
<height>46</height>
653+
<width>636</width>
654+
<height>137</height>
655655
</rect>
656656
</property>
657657
<layout class="QVBoxLayout" name="verticalLayout_9">
@@ -709,8 +709,8 @@
709709
<rect>
710710
<x>0</x>
711711
<y>0</y>
712-
<width>98</width>
713-
<height>46</height>
712+
<width>636</width>
713+
<height>136</height>
714714
</rect>
715715
</property>
716716
<layout class="QVBoxLayout" name="verticalLayout_10">
@@ -820,13 +820,13 @@
820820
<item>
821821
<widget class="QCheckBox" name="checkBox_resetcounters">
822822
<property name="enabled">
823-
<bool>false</bool>
823+
<bool>true</bool>
824824
</property>
825825
<property name="toolTip">
826826
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Reset counters when a new service is selected&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
827827
</property>
828828
<property name="whatsThis">
829-
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Normally counters are cummulative and will retain the counts between boots. When this box is checked the counters will reset to zero every time a Connman service is started. &lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
829+
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Normally counters are cummulative and will retain the connect time and the TX and RX counts between boots. &lt;/p&gt;&lt;p&gt;When this box is checked the counters will reset to zero every time CMST is started, and if CMST is running everytime a Connman service is started. &lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
830830
</property>
831831
<property name="text">
832832
<string>Reset C&amp;ounters</string>
@@ -1013,8 +1013,8 @@
10131013
<rect>
10141014
<x>0</x>
10151015
<y>0</y>
1016-
<width>104</width>
1017-
<height>1922</height>
1016+
<width>536</width>
1017+
<height>550</height>
10181018
</rect>
10191019
</property>
10201020
<layout class="QVBoxLayout" name="verticalLayout_8">

code/resource.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ DEALINGS IN THE SOFTWARE.
3434

3535
///////////////////////////////// Program Values ///////////////////////
3636
// Program Info
37-
#define VERSION "14.06.28-1"
37+
#define VERSION "14.06.29-1"
3838
#define RELEASE_DATE "14 June 2014"
3939
#define COPYRIGHT_DATE "2013-2014"
4040

0 commit comments

Comments
 (0)