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

View File

@ -17,6 +17,8 @@
#include "netctlguiadaptor.h"
#include <QTextCodec>
#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()
{
mainWindow->show();

View File

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

View File

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

View File

@ -17,6 +17,8 @@
#include "controladaptor.h"
#include <QTextCodec>
#include "netctlhelper.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()
{
return (QString(DOCS_PATH) + QString("netctl-gui-security-notes.html"));

View File

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

View File

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

View File

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

View File

@ -93,9 +93,11 @@ bool Netctl::cmdCall(const bool sudo, const QString command, const QString comma
}
QString cmd = QString("");
if (sudo) cmd = sudoCommand + QString(" ");
if (sudo)
cmd = sudoCommand + QString(" ");
cmd += command + QString(" ") + commandLine;
if (argument != 0) cmd += QString(" ") + argument;
if (argument != 0)
cmd += QString(" ") + argument;
if (debug) qDebug() << "[Netctl]" << "[cmdCall]" << ":" << "Run cmd" << cmd;
TaskResult process = runTask(cmd, (useSuid && sudo));
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("");
if (sudo) cmd = sudoCommand + QString(" ");
if (sudo)
cmd = sudoCommand + QString(" ");
cmd += command + QString(" ") + commandLine;
if (argument != 0) cmd += QString(" ") + argument;
if (argument != 0)
cmd += QString(" ") + argument;
if (debug) qDebug() << "[Netctl]" << "[getCmdOutput]" << ":" << "Run cmd" << cmd;
TaskResult process = runTask(cmd, (useSuid && sudo));
if (debug) qDebug() << "[Netctl]" << "[getCmdOutput]" << ":" << "Cmd returns" << process.exitCode;
@ -255,9 +259,9 @@ QString Netctl::getProfileStatus(const QString profile)
else
status = QString("inactive");
if (isProfileEnabled(profile))
status = status + QString(" (enabled)");
status += QString(" (enabled)");
else
status = status + QString(" (static)");
status += QString(" (static)");
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]" << ":" << "Profile" << profile;
QString profileTempName = QDir::homePath() + QDir::separator() +
QString(".cache") + QDir::separator() + QFileInfo(profile).fileName();
QString profileTempName = QDir::homePath() + QString("/.cache/") + QFileInfo(profile).fileName();
QFile profileFile(profileTempName);
if (debug) qDebug() << "[NetctlProfile]" << "[createProfile]" << ":" << "Save to" << profileTempName;
if (!profileFile.open(QIODevice::WriteOnly | QIODevice::Text))

View File

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


View File

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

View File

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

View File

@ -7,7 +7,7 @@
#define TRANSLATORS ""
#define EMAIL "@PROJECT_CONTACT@"
#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 REPOSITORY "https://github.com/arcan1s/netctl-gui"