add Pony() call <3

helper and library refatoring
This commit is contained in:
arcan1s 2014-08-11 21:51:50 +04:00
parent d166668feb
commit 61d814d9a2
14 changed files with 95 additions and 36 deletions

View File

@ -76,6 +76,11 @@ th.sub {
<td>returns path to the library documentation</td> <td>returns path to the library documentation</td>
<td>no</td> <td>no</td>
</tr> </tr>
<tr>
<td>QString Pony()</td>
<td>prints Pinkie Pie to stdout. Really, just try</td>
<td>no</td>
</tr>
<tr> <tr>
<td>QString SecurityDocs()</td> <td>QString SecurityDocs()</td>
<td>returns path to the security documentation</td> <td>returns path to the security documentation</td>
@ -272,6 +277,11 @@ th.sub {
<td>opens the library documentation</td> <td>opens the library documentation</td>
<td>no</td> <td>no</td>
</tr> </tr>
<tr>
<td>QString Pony()</td>
<td>prints Pinkie Pie to stdout. Really, just try</td>
<td>no</td>
</tr>
<tr> <tr>
<td>bool Restore()</td> <td>bool Restore()</td>
<td><code>true</code> and restores the application</td> <td><code>true</code> and restores the application</td>

View File

@ -17,6 +17,8 @@
#include "netctlguiadaptor.h" #include "netctlguiadaptor.h"
#include <QTextCodec>
#include "mainwindow.h" #include "mainwindow.h"
@ -57,6 +59,19 @@ void NetctlGuiAdaptor::LibraryDocs()
} }
QString NetctlGuiAdaptor::Pony()
{
QString pony;
QFile ponyFile(QString(":pinkiepie"));
if (!ponyFile.open(QIODevice::ReadOnly))
return pony;
pony = QTextCodec::codecForMib(106)->toUnicode(ponyFile.readAll());
ponyFile.close();
return pony;
}
bool NetctlGuiAdaptor::Restore() bool NetctlGuiAdaptor::Restore()
{ {
mainWindow->show(); mainWindow->show();

View File

@ -38,6 +38,7 @@ public slots:
bool Close(); bool Close();
QStringList Information(); QStringList Information();
void LibraryDocs(); void LibraryDocs();
QString Pony();
bool Restore(); bool Restore();
void SecurityDocs(); void SecurityDocs();
QStringList Settings(); QStringList Settings();

View File

@ -24,7 +24,7 @@ if (USE_QT5)
set (QT_NEEDED_LIBS ${Qt5Core_LIBRARIES} ${Qt5DBus_LIBRARIES}) set (QT_NEEDED_LIBS ${Qt5Core_LIBRARIES} ${Qt5DBus_LIBRARIES})
qt5_wrap_cpp (MOC_SOURCES ${HEADERS}) qt5_wrap_cpp (MOC_SOURCES ${HEADERS})
qt5_add_resources (QRC_SOURCES ${RESOURCES}) qt5_add_resources (QRC_SOURCES ${RESOURCES})
foreach (LANGUAGE ${LANGUAGES}) foreach (LANGUAGE ${LANGUAGES})
set (TS ${LANGUAGE}) set (TS ${LANGUAGE})
string (REPLACE ".ts" ".qm" QM ${TS}) string (REPLACE ".ts" ".qm" QM ${TS})
@ -40,7 +40,7 @@ else ()
set (QT_NEEDED_LIBS ${QT_QTCORE_LIBRARY} ${QT_QTDBUS_LIBRARY}) set (QT_NEEDED_LIBS ${QT_QTCORE_LIBRARY} ${QT_QTDBUS_LIBRARY})
qt4_wrap_cpp (MOC_SOURCES ${HEADERS}) qt4_wrap_cpp (MOC_SOURCES ${HEADERS})
qt4_add_resources (QRC_SOURCES ${RESOURCES}) qt4_add_resources (QRC_SOURCES ${RESOURCES})
foreach (LANGUAGE ${LANGUAGES}) foreach (LANGUAGE ${LANGUAGES})
set (TS ${LANGUAGE}) set (TS ${LANGUAGE})
string (REPLACE ".ts" ".qm" QM ${TS}) string (REPLACE ".ts" ".qm" QM ${TS})

View File

@ -17,6 +17,8 @@
#include "controladaptor.h" #include "controladaptor.h"
#include <QTextCodec>
#include "netctlhelper.h" #include "netctlhelper.h"
#include "version.h" #include "version.h"
@ -66,6 +68,19 @@ QString ControlAdaptor::LibraryDocs()
} }
QString ControlAdaptor::Pony()
{
QString pony;
QFile ponyFile(QString(":pinkiepie"));
if (!ponyFile.open(QIODevice::ReadOnly))
return pony;
pony = QTextCodec::codecForMib(106)->toUnicode(ponyFile.readAll());
ponyFile.close();
return pony;
}
QString ControlAdaptor::SecurityDocs() QString ControlAdaptor::SecurityDocs()
{ {
return (QString(DOCS_PATH) + QString("netctl-gui-security-notes.html")); return (QString(DOCS_PATH) + QString("netctl-gui-security-notes.html"));

View File

@ -41,6 +41,7 @@ public slots:
QString ApiDocs(); QString ApiDocs();
bool Close(); bool Close();
QString LibraryDocs(); QString LibraryDocs();
QString Pony();
QString SecurityDocs(); QString SecurityDocs();
QStringList Settings(); QStringList Settings();
bool Update(); bool Update();

View File

@ -37,10 +37,8 @@ using namespace std;
bool checkExistSession() bool checkExistSession()
{ {
QDBusConnection bus = QDBusConnection::systemBus(); QDBusConnection bus = QDBusConnection::systemBus();
QDBusMessage request = QDBusMessage::createMethodCall(DBUS_HELPER_SERVICE, QDBusMessage request = QDBusMessage::createMethodCall(DBUS_HELPER_SERVICE, DBUS_CTRL_PATH,
DBUS_CTRL_PATH, DBUS_HELPER_INTERFACE, QString("Active"));
DBUS_HELPER_INTERFACE,
QString("Active"));
QDBusMessage response = bus.call(request); QDBusMessage response = bus.call(request);
QList<QVariant> arguments = response.arguments(); QList<QVariant> arguments = response.arguments();
return !arguments.isEmpty(); return !arguments.isEmpty();
@ -52,33 +50,26 @@ int main(int argc, char *argv[])
QMap<QString, QVariant> args = getArgs(); QMap<QString, QVariant> args = getArgs();
// reading // reading
for (int i=1; i<argc; i++) { for (int i=1; i<argc; i++) {
// config path
if ((QString(argv[i]) == QString("-c")) || (QString(argv[i]) == QString("--config"))) { if ((QString(argv[i]) == QString("-c")) || (QString(argv[i]) == QString("--config"))) {
// config path
args[QString("config")] = QDir().absoluteFilePath(argv[i+1]); args[QString("config")] = QDir().absoluteFilePath(argv[i+1]);
i++; i++;
} } else if ((QString(argv[i]) == QString("-d")) || (QString(argv[i]) == QString("--debug"))) {
// debug // debug
else if ((QString(argv[i]) == QString("-d")) || (QString(argv[i]) == QString("--debug"))) {
args[QString("debug")] = true; args[QString("debug")] = true;
} } else if (QString(argv[i]) == QString("--nodaemon")) {
// daemonized // daemonized
else if (QString(argv[i]) == QString("--nodaemon")) {
args[QString("nodaemon")] = true; args[QString("nodaemon")] = true;
} } else if ((QString(argv[i]) == QString("-h")) || (QString(argv[i]) == QString("--help"))) {
// messages // help message
// help message
else if ((QString(argv[i]) == QString("-h")) || (QString(argv[i]) == QString("--help"))) {
args[QString("help")] = true; args[QString("help")] = true;
} } else if ((QString(argv[i]) == QString("-i")) || (QString(argv[i]) == QString("--info"))) {
// info message // info message
else if ((QString(argv[i]) == QString("-i")) || (QString(argv[i]) == QString("--info"))) {
args[QString("info")] = true; args[QString("info")] = true;
} } else if ((QString(argv[i]) == QString("-v")) || (QString(argv[i]) == QString("--version"))) {
// version message // version message
else if ((QString(argv[i]) == QString("-v")) || (QString(argv[i]) == QString("--version"))) {
args[QString("version")] = true; args[QString("version")] = true;
} } else {
else {
args[QString("error")] = true; args[QString("error")] = true;
} }
} }

View File

@ -166,9 +166,7 @@ void NetctlHelper::updateConfiguration()
if (debug) qDebug() << "[NetctlHelper]" << "[updateConfiguration]"; if (debug) qDebug() << "[NetctlHelper]" << "[updateConfiguration]";
deleteInterface(); deleteInterface();
configuration = getSettings(); configuration = getSettings();
createInterface(); createInterface();
} }

View File

@ -93,9 +93,11 @@ bool Netctl::cmdCall(const bool sudo, const QString command, const QString comma
} }
QString cmd = QString(""); QString cmd = QString("");
if (sudo) cmd = sudoCommand + QString(" "); if (sudo)
cmd = sudoCommand + QString(" ");
cmd += command + QString(" ") + commandLine; cmd += command + QString(" ") + commandLine;
if (argument != 0) cmd += QString(" ") + argument; if (argument != 0)
cmd += QString(" ") + argument;
if (debug) qDebug() << "[Netctl]" << "[cmdCall]" << ":" << "Run cmd" << cmd; if (debug) qDebug() << "[Netctl]" << "[cmdCall]" << ":" << "Run cmd" << cmd;
TaskResult process = runTask(cmd, (useSuid && sudo)); TaskResult process = runTask(cmd, (useSuid && sudo));
if (debug) qDebug() << "[Netctl]" << "[cmdCall]" << ":" << "Cmd returns" << process.exitCode; if (debug) qDebug() << "[Netctl]" << "[cmdCall]" << ":" << "Cmd returns" << process.exitCode;
@ -122,9 +124,11 @@ QString Netctl::getCmdOutput(const bool sudo, const QString command, const QStri
} }
QString cmd = QString(""); QString cmd = QString("");
if (sudo) cmd = sudoCommand + QString(" "); if (sudo)
cmd = sudoCommand + QString(" ");
cmd += command + QString(" ") + commandLine; cmd += command + QString(" ") + commandLine;
if (argument != 0) cmd += QString(" ") + argument; if (argument != 0)
cmd += QString(" ") + argument;
if (debug) qDebug() << "[Netctl]" << "[getCmdOutput]" << ":" << "Run cmd" << cmd; if (debug) qDebug() << "[Netctl]" << "[getCmdOutput]" << ":" << "Run cmd" << cmd;
TaskResult process = runTask(cmd, (useSuid && sudo)); TaskResult process = runTask(cmd, (useSuid && sudo));
if (debug) qDebug() << "[Netctl]" << "[getCmdOutput]" << ":" << "Cmd returns" << process.exitCode; if (debug) qDebug() << "[Netctl]" << "[getCmdOutput]" << ":" << "Cmd returns" << process.exitCode;
@ -255,9 +259,9 @@ QString Netctl::getProfileStatus(const QString profile)
else else
status = QString("inactive"); status = QString("inactive");
if (isProfileEnabled(profile)) if (isProfileEnabled(profile))
status = status + QString(" (enabled)"); status += QString(" (enabled)");
else else
status = status + QString(" (static)"); status += QString(" (static)");
return status; return status;
} }

View File

@ -100,8 +100,7 @@ QString NetctlProfile::createProfile(const QString profile, const QMap<QString,
if (debug) qDebug() << "[NetctlProfile]" << "[createProfile]"; if (debug) qDebug() << "[NetctlProfile]" << "[createProfile]";
if (debug) qDebug() << "[NetctlProfile]" << "[createProfile]" << ":" << "Profile" << profile; if (debug) qDebug() << "[NetctlProfile]" << "[createProfile]" << ":" << "Profile" << profile;
QString profileTempName = QDir::homePath() + QDir::separator() + QString profileTempName = QDir::homePath() + QString("/.cache/") + QFileInfo(profile).fileName();
QString(".cache") + QDir::separator() + QFileInfo(profile).fileName();
QFile profileFile(profileTempName); QFile profileFile(profileTempName);
if (debug) qDebug() << "[NetctlProfile]" << "[createProfile]" << ":" << "Save to" << profileTempName; if (debug) qDebug() << "[NetctlProfile]" << "[createProfile]" << ":" << "Save to" << profileTempName;
if (!profileFile.open(QIODevice::WriteOnly | QIODevice::Text)) if (!profileFile.open(QIODevice::WriteOnly | QIODevice::Text))

View File

@ -0,0 +1,21 @@
 
▄██▄▄▄ ▄▄▄ 
███▄▄█▄▄▄▄▄▄▄▄▄ 
▄▄▄███▄▄██▄██████▄▄ 
▄▄▄▄█▄▄██▄▄▄▄▄▄▄▄█▄████ 
████▄▄██▄▄██▄▄▄█▄██▄████ ▄█▄▄▄▄ 
████ █▄██▄▄███▄▄▄█▄▄▄██ ▄▄▄▄▄▄█▄█▄▄▄█▄▄ 
███ ██████████▄██████ ██▄▄▄▄█▄▄▄██████ 
▀▄██ ▄█▄▄█▄████▄▄█▄▄▄█▄▄▄▄█▄▄█████▄▄████████ 
▀█ ███▄██████████▄▄███▄██▄▄██████▄▄███████ 
▄▀ ▀▀█▄▄▄▄▄███▄▄▄▄▄▄▄██▄███▄███▄▄██████▄▀ 
▀ ██▄▄██▄▄█▄▄▄▄▄▄▄ ▀▀▄▄█▄▄▄███▄▄ 
█████▄▄█▄▄███▄▄▄█ ████▄▄███▄▄
█▄▄█▄▄▄▄▄█▄██▄▄█ ███▄█▄▄▄█▄██
▄▄▄█▄█████▄████ ▀▄█████▄▄██▀
▄█▄▄▄▄███▀▄█▄████▄█ ▀▄█▄▄███ ▄
▄▄██▄██▄▄▄▀█▄███▄██▄▀ ▄▄█▄█▄▄█
█▄██████ ███▄▄███▄▀ ▀▄▄▄▄▀▀ 
██████ ▀▀███████ 
▀▀▀▀▀▀ ▀▀▀▀▀▀ 


View File

@ -3,5 +3,7 @@
<!-- helper translations --> <!-- helper translations -->
<file>translations-helper/en.qm</file> <file>translations-helper/en.qm</file>
<file>translations-helper/ru.qm</file> <file>translations-helper/ru.qm</file>
<!-- pony <3 -->
<file>pinkiepie</file>
</qresource> </qresource>
</RCC> </RCC>

View File

@ -8,5 +8,7 @@
<file>wifi.png</file> <file>wifi.png</file>
<file>network-idle-64x64.png</file> <file>network-idle-64x64.png</file>
<file>network-offline-64x64.png</file> <file>network-offline-64x64.png</file>
<!-- pony <3 -->
<file>pinkiepie</file>
</qresource> </qresource>
</RCC> </RCC>

View File

@ -7,7 +7,7 @@
#define TRANSLATORS "" #define TRANSLATORS ""
#define EMAIL "@PROJECT_CONTACT@" #define EMAIL "@PROJECT_CONTACT@"
#define LICENSE "@PROJECT_LICENSE@" #define LICENSE "@PROJECT_LICENSE@"
#define TRDPARTY_LICENSE "tasks,BSD,https://github.com/mhogomchungu/tasks;" #define TRDPARTY_LICENSE "tasks,BSD,https://github.com/mhogomchungu/tasks;ponysay,GPLv3,http://erkin.co/ponysay"
#define HOMEPAGE "http://arcanis.name/projects/netctl-gui/" #define HOMEPAGE "http://arcanis.name/projects/netctl-gui/"
#define REPOSITORY "https://github.com/arcan1s/netctl-gui" #define REPOSITORY "https://github.com/arcan1s/netctl-gui"