Prepare to release 1.4.1

update docs, update ui
deprecate description function
This commit is contained in:
arcan1s 2015-03-16 05:14:53 +03:00
parent 3f49988cef
commit a2b1d46900
17 changed files with 161 additions and 174 deletions

@ -1 +1 @@
Subproject commit 9c63e102b05e11ead690489ca470c8482b6335b1 Subproject commit 294a590bb966fd79eb2e93a7b02377ca57731cd5

View File

@ -35,6 +35,7 @@ small {
<li><a href="#api">DBus API</a></li> <li><a href="#api">DBus API</a></li>
<li><a href="#helper">Helper API</a></li> <li><a href="#helper">Helper API</a></li>
<li><a href="#ctrl">Helper ctrl API</a></li> <li><a href="#ctrl">Helper ctrl API</a></li>
<li><a href="#interface">Helper interface API</a></li>
<li><a href="#netctl">Helper netctl API</a></li> <li><a href="#netctl">Helper netctl API</a></li>
<li><a href="#gui">GUI API</a></li> <li><a href="#gui">GUI API</a></li>
<li><a href="#netctlgui">GUI netctlgui API</a></li> <li><a href="#netctlgui">GUI netctlgui API</a></li>
@ -74,7 +75,7 @@ small {
</tr> </tr>
<tr> <tr>
<td>QStringList FindSettings()</td> <td>QStringList FindSettings()</td>
<td>scans system and suggests the recommended configuration which will be used by the library</td> <td>scans system and suggests the recommended configuration which may be used by the library</td>
<td>no</td> <td>no</td>
</tr> </tr>
<tr> <tr>
@ -211,6 +212,78 @@ small {
<td>returns available WiFi points in format <code>NAME|SECURITY|SIGNAL|ACTIVE|EXISTS</code></td> <td>returns available WiFi points in format <code>NAME|SECURITY|SIGNAL|ACTIVE|EXISTS</code></td>
<td>yes</td> <td>yes</td>
</tr> </tr>
<!-- /interface path -->
<tr>
<th colspan="3" class="sub"><a href="#interface" class="anchor" id="interface"></a><code>/interface</code> path</th>
</tr>
<!-- netctl control -->
<tr>
<td>int Enable(QString profile)</td>
<td>enables or disables the profile. Returns is the profile enabled or <code>2</code> if there was an another error</td>
<td>yes</td>
</tr>
<tr>
<td>int Restart(QString profile)</td>
<td>restarts the profile. Returns is the profile active or <code>2</code> if there was an error</td>
<td>yes</td>
</tr>
<tr>
<td>int Start(QString profile)</td>
<td>starts or stops the profile. Returns is the profile active or <code>2</code> if there was an error</td>
<td>yes</td>
</tr>
<tr>
<td>bool StopAll()</td>
<td>synonym of <code>/ctlr/StopAll()</code></td>
<td>yes</td>
</tr>
<tr>
<td>bool SwitchTo(QString profile)</td>
<td>switchs to the profile (works with netctl and netctl-auto). Returns is the profile active or <code>2</code> if there was an error</td>
<td>yes</td>
</tr>
<tr>
<td>int Create(QString profile, QStringList settingsList)</td>
<td>>creates the profile with specified settings. Settings should be given in the format <code>KEY==VALUE</code>. Returns <code>1</code> if action has been performed successfully, <code>0</code> if there was an error in the profile copying and <code>2</code> if there was an another error</td>
<td>yes</td>
</tr>
<tr>
<td>QStringList Profile(QString profile)</td>
<td>synonym of <code>/netctl/Profile()</code></td>
<td>no</td>
</tr>
<tr>
<td>int Remove(QString profile)</td>
<td>synonym of <code>/ctrl/Remove()</code></td>
<td>yes</td>
</tr>
<!-- information -->
<tr>
<td>QStringList Information()</td>
<td>returns general information in format <code>[IsNetctlAutoActive, NetctlProfiles, NetctlAutoProfiles]</code></td>
<td>no</td>
</tr>
<tr>
<td>QStringList Status()</td>
<td>returns actual information in format <code>[IsNetctlAutoActive, ProfilesNames, ActiveProfile, ActiveProfileEnables]</code></td>
<td>no</td>
</tr>
<!-- wpa_supplicant actions -->
<tr>
<td>int Essid(QString essid, QStringList settingsList)</td>
<td>connects to WiFi point with the given ESSID, calls KnownEssid or UnknownESSID depending on whether there is a profile. Settings may be empty. To get return codes refer to <code>KnownEssid()</code> and <code>UnknownEssid()</code></td>
<td>yes</td>
</tr>
<tr>
<td>int KnownEssid(QString essid)</td>
<td>connects to WiFi point with the given ESSID with existent profile. Returns <code>Start()</code> if ok, in other cases returns <code>2</code></td>
<td>yes</td>
</tr>
<tr>
<td>int UnknownEssid(QString essid, QStringList settingsList)</td>
<td>creates a profile and connects to WiFi point with the given ESSID. Returns <code>Start()</code> if ok, in other cases returns <code>2</code></td>
<td>yes</td>
</tr>
<!-- /netctl path --> <!-- /netctl path -->
<tr> <tr>
<th colspan="3" class="sub"><a href="#netctl" class="anchor" id="netctl"></a><code>/netctl</code> path</th> <th colspan="3" class="sub"><a href="#netctl" class="anchor" id="netctl"></a><code>/netctl</code> path</th>
@ -318,7 +391,6 @@ small {
<tr> <tr>
<th colspan="3"><a href="#gui" class="anchor" id="gui"></a><code>org.netctlgui.netctlgui</code> service (session bus)</th> <th colspan="3"><a href="#gui" class="anchor" id="gui"></a><code>org.netctlgui.netctlgui</code> service (session bus)</th>
</tr> </tr>
<!-- /netctlgui path -->
<tr> <tr>
<th colspan="3" class="sub"><a href="#netctlgui" class="anchor" id="netctlgui"></a><code>/netctlgui</code> path</th> <th colspan="3" class="sub"><a href="#netctlgui" class="anchor" id="netctlgui"></a><code>/netctlgui</code> path</th>
</tr> </tr>
@ -338,11 +410,6 @@ small {
<td><code>true</code> and closes the application</td> <td><code>true</code> and closes the application</td>
<td>no</td> <td>no</td>
</tr> </tr>
<tr>
<td>QString Information()</td>
<td>returns general information in format <code>[ActiveProfile, ActiveProfileStatus]</code></td>
<td>no</td>
</tr>
<tr> <tr>
<td>void LibraryDocs()</td> <td>void LibraryDocs()</td>
<td>opens the library documentation</td> <td>opens the library documentation</td>

View File

@ -26,6 +26,9 @@
<property name="text"> <property name="text">
<string>netctl-auto is running</string> <string>netctl-auto is running</string>
</property> </property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget> </widget>
</item> </item>
<item> <item>

View File

@ -121,32 +121,6 @@ Qt::ToolBarArea MainWindow::getToolBarArea()
} }
QStringList MainWindow::printInformation()
{
if (debug) qDebug() << PDEBUG;
QStringList output;
output.append(QApplication::translate("MainWindow", "none"));
output.append(QApplication::translate("MainWindow", "(none)"));
netctlCurrent current = printTrayInformation();
if (current.current.isEmpty()) return output;
QStringList profiles;
for (int i=0; i<current.current.count(); i++) {
QString status;
if (current.netctlAuto)
status = QApplication::translate("MainWindow", "(netctl-auto)");
else if (current.enables[i])
status = QApplication::translate("MainWindow", "(enabled)");
else
status = QApplication::translate("MainWindow", "(static)");
profiles.append(QString("%1 %2").arg(current.current[i]).arg(status));
}
return output;
}
QStringList MainWindow::printSettings() QStringList MainWindow::printSettings()
{ {
if (debug) qDebug() << PDEBUG; if (debug) qDebug() << PDEBUG;
@ -234,7 +208,7 @@ void MainWindow::showMainWindow()
if (debug) qDebug() << PDEBUG; if (debug) qDebug() << PDEBUG;
if (isHidden()) { if (isHidden()) {
updateTabs(ui->stackedWidget->currentIndex()); setTab(ui->stackedWidget->currentIndex());
show(); show();
} else } else
hide(); hide();
@ -336,12 +310,24 @@ void MainWindow::setTab(int tab)
{ {
if (debug) qDebug() << PDEBUG; if (debug) qDebug() << PDEBUG;
if (debug) qDebug() << PDEBUG << ":" << "Set tab" << tab; if (debug) qDebug() << PDEBUG << ":" << "Set tab" << tab;
if (ui->stackedWidget->currentWidget() == nullptr) return;
if ((tab > 2) || (tab < 0)) tab = 0; if ((tab > 2) || (tab < 0)) tab = 0;
if (tab == ui->stackedWidget->currentIndex()) if (tab != ui->stackedWidget->currentIndex())
updateTabs(tab); return ui->stackedWidget->setCurrentIndex(tab);
else
ui->stackedWidget->setCurrentIndex(tab); switch (tab) {
case 1:
newProfileWidget->update();
break;
case 2:
wifiMenuWidget->update();
break;
case 0:
default:
mainWidget->update();
break;
}
} }
@ -426,26 +412,6 @@ void MainWindow::updateConfiguration(const QMap<QString, QVariant> args)
} }
void MainWindow::updateTabs(const int tab)
{
if (debug) qDebug() << PDEBUG;
if (debug) qDebug() << PDEBUG << ":" << "Update tab" << tab;
switch (tab) {
case 1:
newProfileWidget->update();
break;
case 2:
wifiMenuWidget->update();
break;
case 0:
default:
mainWidget->update();
break;
}
}
void MainWindow::updateToolBarState(const Qt::ToolBarArea area) void MainWindow::updateToolBarState(const Qt::ToolBarArea area)
{ {
if (debug) qDebug() << PDEBUG; if (debug) qDebug() << PDEBUG;
@ -460,27 +426,17 @@ void MainWindow::updateToolBarState(const Qt::ToolBarArea area)
// private slots // private slots
void MainWindow::setMainTab() void MainWindow::setTabByAction(QAction *action)
{ {
if (debug) qDebug() << PDEBUG; if (debug) qDebug() << PDEBUG;
if (action == nullptr) return;
return setTab(0); if (action == ui->actionNetctl)
} setTab(0);
else if (action == ui->actionProfiles)
setTab(1);
void MainWindow::setProfileTab() else if (action == ui->actionWiFi_menu)
{ setTab(2);
if (debug) qDebug() << PDEBUG;
return setTab(1);
}
void MainWindow::setWifiTab()
{
if (debug) qDebug() << PDEBUG;
return setTab(2);
} }
@ -513,10 +469,8 @@ void MainWindow::createActions()
{ {
if (debug) qDebug() << PDEBUG; if (debug) qDebug() << PDEBUG;
connect(ui->toolBar, SIGNAL(actionTriggered(QAction *)), this, SLOT(setTabByAction(QAction *)));
connect(ui->actionNetctl_auto, SIGNAL(triggered()), this, SLOT(showNetctlAutoWindow())); connect(ui->actionNetctl_auto, SIGNAL(triggered()), this, SLOT(showNetctlAutoWindow()));
connect(ui->actionNetctl, SIGNAL(triggered()), this, SLOT(setMainTab()));
connect(ui->actionProfiles, SIGNAL(triggered()), this, SLOT(setProfileTab()));
connect(ui->actionWiFi_menu, SIGNAL(triggered()), this, SLOT(setWifiTab()));
connect(ui->stackedWidget, SIGNAL(currentChanged(int)), this, SLOT(setTab(int))); connect(ui->stackedWidget, SIGNAL(currentChanged(int)), this, SLOT(setTab(int)));
connect(this, SIGNAL(needToBeConfigured()), this, SLOT(showSettingsWindow())); connect(this, SIGNAL(needToBeConfigured()), this, SLOT(showSettingsWindow()));
@ -572,9 +526,9 @@ void MainWindow::createObjects()
trayIcon = new TrayIcon(this, configuration, debug); trayIcon = new TrayIcon(this, configuration, debug);
// windows // windows
ui->retranslateUi(this); ui->retranslateUi(this);
ui->layout_main->addWidget(mainWidget); ui->stackedWidget->addWidget(mainWidget);
ui->layout_new->addWidget(newProfileWidget); ui->stackedWidget->addWidget(newProfileWidget);
ui->layout_wifi->addWidget(wifiMenuWidget); ui->stackedWidget->addWidget(wifiMenuWidget);
updateToolBarState(static_cast<Qt::ToolBarArea>(configuration[QString("MAIN_TOOLBAR")].toInt())); updateToolBarState(static_cast<Qt::ToolBarArea>(configuration[QString("MAIN_TOOLBAR")].toInt()));
aboutWin = new AboutWindow(this, debug); aboutWin = new AboutWindow(this, debug);
settingsWin = new SettingsWindow(this, debug, configPath); settingsWin = new SettingsWindow(this, debug, configPath);
@ -585,6 +539,9 @@ void MainWindow::deleteObjects()
{ {
if (debug) qDebug() << PDEBUG; if (debug) qDebug() << PDEBUG;
// workaround to avoid crash on window closing
disconnect(ui->stackedWidget, SIGNAL(currentChanged(int)), this, SLOT(setTab(int)));
QDBusConnection::sessionBus().unregisterObject(DBUS_OBJECT_PATH); QDBusConnection::sessionBus().unregisterObject(DBUS_OBJECT_PATH);
QDBusConnection::sessionBus().unregisterService(DBUS_SERVICE); QDBusConnection::sessionBus().unregisterService(DBUS_SERVICE);
if (netctlCommand != nullptr) delete netctlCommand; if (netctlCommand != nullptr) delete netctlCommand;

View File

@ -48,7 +48,6 @@ public:
QTranslator *appTranslator = 0); QTranslator *appTranslator = 0);
~MainWindow(); ~MainWindow();
Qt::ToolBarArea getToolBarArea(); Qt::ToolBarArea getToolBarArea();
QStringList printInformation();
QStringList printSettings(); QStringList printSettings();
netctlCurrent printTrayInformation(); netctlCurrent printTrayInformation();
bool isHelperActive(); bool isHelperActive();
@ -83,16 +82,16 @@ public slots:
void showMessage(const bool status); void showMessage(const bool status);
void storeToolBars(); void storeToolBars();
void updateConfiguration(const QMap<QString, QVariant> args = QMap<QString, QVariant>()); void updateConfiguration(const QMap<QString, QVariant> args = QMap<QString, QVariant>());
void updateTabs(const int tab);
void updateToolBarState(const Qt::ToolBarArea area = Qt::TopToolBarArea); void updateToolBarState(const Qt::ToolBarArea area = Qt::TopToolBarArea);
signals: signals:
void needToBeConfigured(); void needToBeConfigured();
void needShowAboutWindow();
void needShowNetctlAutoWindow();
void needShowSettingsWindow();
private slots: private slots:
void setMainTab(); void setTabByAction(QAction *action);
void setProfileTab();
void setWifiTab();
void reportABug(); void reportABug();
private: private:

View File

@ -23,27 +23,6 @@
<verstretch>0</verstretch> <verstretch>0</verstretch>
</sizepolicy> </sizepolicy>
</property> </property>
<widget class="QWidget" name="page_main">
<layout class="QVBoxLayout" name="layout_main">
<property name="margin">
<number>0</number>
</property>
</layout>
</widget>
<widget class="QWidget" name="page_new">
<layout class="QVBoxLayout" name="layout_new">
<property name="margin">
<number>0</number>
</property>
</layout>
</widget>
<widget class="QWidget" name="page_wifi">
<layout class="QVBoxLayout" name="layout_wifi">
<property name="margin">
<number>0</number>
</property>
</layout>
</widget>
</widget> </widget>
</item> </item>
</layout> </layout>

View File

@ -54,12 +54,6 @@ bool NetctlGuiAdaptor::Close()
} }
QStringList NetctlGuiAdaptor::Information()
{
return mainWindow->printInformation();
}
void NetctlGuiAdaptor::LibraryDocs() void NetctlGuiAdaptor::LibraryDocs()
{ {
return mainWindow->showLibrary(); return mainWindow->showLibrary();

View File

@ -37,7 +37,6 @@ public slots:
bool Active(); bool Active();
void ApiDocs(); void ApiDocs();
bool Close(); bool Close();
QStringList Information();
void LibraryDocs(); void LibraryDocs();
QString Pony(); QString Pony();
bool Restore(); bool Restore();

View File

@ -188,9 +188,10 @@ void TrayIcon::enableProfileTraySlot()
{ {
if (debug) qDebug() << PDEBUG; if (debug) qDebug() << PDEBUG;
QString profile = mainWindow->printInformation()[0]; QStringList profiles = mainWindow->printTrayInformation().current;
if (profiles.isEmpty()) return;
enableProfileSlot(profile, mainWindow->netctlInterface, useHelper, debug); enableProfileSlot(profiles[0], mainWindow->netctlInterface, useHelper, debug);
} }
@ -198,9 +199,10 @@ void TrayIcon::restartProfileTraySlot()
{ {
if (debug) qDebug() << PDEBUG; if (debug) qDebug() << PDEBUG;
QString profile = mainWindow->printInformation()[0]; QStringList profiles = mainWindow->printTrayInformation().current;
if (profiles.isEmpty()) return;
restartProfileSlot(profile, mainWindow->netctlInterface, useHelper, debug); restartProfileSlot(profiles[0], mainWindow->netctlInterface, useHelper, debug);
} }
@ -208,7 +210,13 @@ void TrayIcon::startProfileTraySlot(QAction *action)
{ {
if (debug) qDebug() << PDEBUG; if (debug) qDebug() << PDEBUG;
QString profile = action == nullptr ? mainWindow->printInformation()[0] : action->text().remove(QChar('&')); QString profile;
if (action == nullptr) {
QStringList profiles = mainWindow->printTrayInformation().current;
if (profiles.isEmpty()) return;
profile = profiles[0];
} else
profile = action->text().remove(QChar('&'));
startProfileSlot(profile, mainWindow->netctlInterface, useHelper, debug); startProfileSlot(profile, mainWindow->netctlInterface, useHelper, debug);
} }
@ -227,7 +235,8 @@ void TrayIcon::switchToProfileTraySlot(QAction *action)
if (debug) qDebug() << PDEBUG; if (debug) qDebug() << PDEBUG;
if (action == nullptr) return; if (action == nullptr) return;
QString profile = action->text().remove(QChar('&')); QStringList profiles = mainWindow->printTrayInformation().current;
if (profiles.isEmpty()) return;
switchToProfileSlot(profile, mainWindow->netctlInterface, useHelper, debug); switchToProfileSlot(profiles[0], mainWindow->netctlInterface, useHelper, debug);
} }

View File

@ -110,6 +110,12 @@ QString ControlAdaptor::SecurityDocs()
} }
bool ControlAdaptor::SelfDestruct()
{
return SelfDestruct();
}
QStringList ControlAdaptor::Settings() QStringList ControlAdaptor::Settings()
{ {
return helper->printSettings(); return helper->printSettings();

View File

@ -45,6 +45,7 @@ public slots:
QString LibraryDocs(); QString LibraryDocs();
QString Pony(); QString Pony();
QString SecurityDocs(); QString SecurityDocs();
bool SelfDestruct();
QStringList Settings(); QStringList Settings();
QStringList UIDs(); QStringList UIDs();
bool Update(); bool Update();

View File

@ -119,7 +119,7 @@ public:
* @param profile profile name * @param profile profile name
* @return profile description or "" * @return profile description or ""
*/ */
QString getProfileDescription(const QString profile); Q_DECL_DEPRECATED QString getProfileDescription(const QString profile);
/** /**
* @brief method which gets profile status * @brief method which gets profile status
* @param profile profile name * @param profile profile name

View File

@ -321,9 +321,9 @@ bool Netctl::autoIsProfileActive(const QString profile)
bool status = false; bool status = false;
QList<netctlProfileInfo> profiles = getProfileListFromNetctlAuto(); QList<netctlProfileInfo> profiles = getProfileListFromNetctlAuto();
for (int i=0; i<profiles.count(); i++) for (int i=0; i<profiles.count(); i++) {
if ((profiles[i].name == profile) && (profiles[i].active)) { if (profiles[i].name == profile) continue;
status = true; status = profiles[i].active;
break; break;
} }
@ -341,9 +341,9 @@ bool Netctl::autoIsProfileEnabled(const QString profile)
bool status = false; bool status = false;
QList<netctlProfileInfo> profiles = getProfileListFromNetctlAuto(); QList<netctlProfileInfo> profiles = getProfileListFromNetctlAuto();
for (int i=0; i<profiles.count(); i++) for (int i=0; i<profiles.count(); i++) {
if ((profiles[i].name == profile) && (profiles[i].enabled)) { if (profiles[i].name == profile) continue;
status = true; status = profiles[i].enabled;
break; break;
} }

View File

@ -182,10 +182,7 @@ InterfaceAnswer NetctlInterface::removeProfile(const QString profile)
return InterfaceAnswer::Error; return InterfaceAnswer::Error;
} }
if (netctlProfile->removeProfile(profile)) return static_cast<InterfaceAnswer>(netctlProfile->removeProfile(profile));
return InterfaceAnswer::True;
else
return InterfaceAnswer::Error;
} }
@ -238,10 +235,7 @@ InterfaceAnswer NetctlInterface::stopAllProfiles()
return InterfaceAnswer::Error; return InterfaceAnswer::Error;
} }
if (netctlCommand->stopAllProfiles()) return static_cast<InterfaceAnswer>(netctlCommand->stopAllProfiles());
return InterfaceAnswer::True;
else
return InterfaceAnswer::Error;
} }

View File

@ -220,7 +220,7 @@ QMap<QString, QString> NetctlProfile::getSettingsFromProfile(const QString profi
if (debug) qDebug() << PDEBUG << ":" << "Error" << process.error; if (debug) qDebug() << PDEBUG << ":" << "Error" << process.error;
output = QString(process.output).trimmed().split(QChar('\n')); output = QString(process.output).trimmed().split(QChar('\n'));
// gettings variables // read variables
QStringList keys; QStringList keys;
for (int i=0; i<output.count(); i++) for (int i=0; i<output.count(); i++)
if (!systemVariables.contains(output[i].split(QChar('='))[0])) if (!systemVariables.contains(output[i].split(QChar('='))[0]))

View File

@ -142,26 +142,6 @@ void TestNetctl::test_getActiveProfile()
} }
void TestNetctl::test_getProfileDescription()
{
Netctl *netctl = createNetctlObj();
QString original = QString("Simple test profile");
QString result = netctl->getProfileDescription(QString("netctlgui-test-dummy"));
QString dbus;
if (helper) {
QList<QVariant> args;
args.append(QString("netctlgui-test-dummy"));
args.append(QString("Description"));
dbus = sendDBusRequest(QString("/netctl"), QString("ProfileValue"), args)
[0].toString();
}
delete netctl;
QCOMPARE(result, original);
if (helper) QCOMPARE(dbus, result);
}
void TestNetctl::test_getProfileStatus() void TestNetctl::test_getProfileStatus()
{ {
Netctl *netctl = createNetctlObj(); Netctl *netctl = createNetctlObj();

View File

@ -36,7 +36,6 @@ private slots:
// netctl // netctl
void test_getRecommendedConfiguration(); void test_getRecommendedConfiguration();
void test_getActiveProfile(); void test_getActiveProfile();
void test_getProfileDescription();
void test_getProfileStatus(); void test_getProfileStatus();
void test_isProfileActive(); void test_isProfileActive();
void test_isProfileEnabled(); void test_isProfileEnabled();