Commit 689545fe authored by Alf Gaida's avatar Alf Gaida

Cherry-picking upstream version 2016.04.03.

parent e499f98e
......@@ -41,6 +41,7 @@ HEADERS += ./code/vpn_agent/vpnagent.h
HEADERS += ./code/vpn_agent/vpnagent_dialog.h
HEADERS += ./code/vpn_agent/vpnagent_adaptor.h
HEADERS += ./code/vpn_agent/vpnagent_interface.h
HEADERS += ./code/shared/shared.h
# forms
FORMS += ./code/control_box/ui/controlbox.ui
......@@ -68,6 +69,7 @@ SOURCES += ./code/vpn_agent/vpnagent.cpp
SOURCES += ./code/vpn_agent/vpnagent_dialog.cpp
SOURCES += ./code/vpn_agent/vpnagent_adaptor.cpp
SOURCES += ./code/vpn_agent/vpnagent_interface.cpp
SOURCES += ./code/shared/shared.cpp
# resource files
RESOURCES += ../../cmst.qrc
......
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -65,6 +65,7 @@ struct arrayElement
QMap<QString,QVariant> objmap;
};
//
// custom QFrame containing a QToolButton that will emit a button id
class idButton : public QFrame
......@@ -111,7 +112,7 @@ class ControlBox : public QDialog
private:
// members
Ui::ControlBox ui;
quint8 q8_errors;
quint16 q16_errors;
QMap<QString,QVariant> properties_map;
QList<arrayElement> services_list;
QList<arrayElement> technologies_list;
......@@ -161,10 +162,10 @@ class ControlBox : public QDialog
bool getServices();
bool getArray(QList<arrayElement>&, const QDBusMessage&);
bool getMap(QMap<QString,QVariant>&, const QDBusMessage&);
static bool extractMapData(QMap<QString,QVariant>&,const QVariant&);
void logErrors(const quint8&);
QString readResourceText(const char*);
void clearCounters();
QString getNickName(const QDBusObjectPath&);
private slots:
void updateDisplayWidgets();
......@@ -176,16 +177,18 @@ class ControlBox : public QDialog
void disconnectPressed();
void removePressed();
void dbsPropertyChanged(QString,QDBusVariant);
void dbsServicesChanged(QMap<QString, QVariant>, QList<QDBusObjectPath>, QDBusMessage);
void dbsPeersChanged(QMap<QString, QVariant>, QList<QDBusObjectPath>, QDBusMessage);
void dbsServicesChanged(QList<QVariant>, QList<QDBusObjectPath>, QDBusMessage);
void dbsPeersChanged(QList<QVariant>, QList<QDBusObjectPath>, QDBusMessage);
void dbsServicePropertyChanged(QString, QDBusVariant, QDBusMessage);
void dbsTechnologyPropertyChanged(QString, QDBusVariant, QDBusMessage);
void dbsTechnologyAdded(QDBusObjectPath, QVariantMap);
void dbsTechnologyRemoved(QDBusObjectPath);
void scanWiFi();
void wifiIDPass(const QString& obj_path = QString() );
void toggleOfflineMode(bool);
void toggleTrayIcon(bool);
void togglePowered(QString, bool);
void toggleTethered(QString, bool);
void minMaxWindow(QAction* = 0);
void techSubmenuTriggered(QAction* = 0);
void infoSubmenuTriggered(QAction* = 0);
......
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -333,7 +333,7 @@ void IconManager::makeLocalFile()
if (ctr <= maxloop && f_cfg.copy(bak) ) {
QMessageBox::StandardButton dia_rtn = QMessageBox::information(0, QString(APP),
tr("A new icon definition file will be installed to <b>%1</b> and a backup of the old definition file has been created as <b>%2</b> \
<p>If the original definition file was customized you wish to retain those changes you will need to manually merge them into the new file. \
<p>If the original definition file was customized and you wish to retain those changes you will need to manually merge them into the new file. \
<p>If the original was never customized or you just wish to delete the backup now you may select <i>Discard</i> to delete the backup or <i>Save</i> to retain it.").arg(cfg).arg(bak),
QMessageBox::Save | QMessageBox::Discard,
QMessageBox::Save);
......
......@@ -96,7 +96,7 @@ int main(int argc, char *argv[])
QCommandLineOption useIconTheme(QStringList() << "i" << "icon-theme",
QCoreApplication::translate("main.cpp", "Use an icon theme from your system."),
QCoreApplication::translate("main.cpp", "Icon Theme Name"),
QString() );
QString("") );
parser.addOption(useIconTheme);
QCommandLineOption logInputRequest(QStringList() << "l" << "log-input-request",
......
......@@ -36,9 +36,9 @@ DEALINGS IN THE SOFTWARE.
# include "./notify.h"
#define DBUS_SERVICE "org.freedesktop.Notifications"
#define DBUS_PATH "/org/freedesktop/Notifications"
#define DBUS_INTERFACE "org.freedesktop.Notifications"
#define DBUS_NOTIFY_SERVICE "org.freedesktop.Notifications"
#define DBUS_NOTIFY_PATH "/org/freedesktop/Notifications"
#define DBUS_NOTIFY_INTERFACE "org.freedesktop.Notifications"
// constructor
NotifyClient::NotifyClient(QObject* parent)
......@@ -78,13 +78,13 @@ void NotifyClient::connectToServer()
// return now if we already have a valid connection
if (b_validconnection) return;
notifyclient = new QDBusInterface(DBUS_SERVICE, DBUS_PATH, DBUS_INTERFACE, QDBusConnection::sessionBus(), this);
notifyclient = new QDBusInterface(DBUS_NOTIFY_SERVICE, DBUS_NOTIFY_PATH, DBUS_NOTIFY_INTERFACE, QDBusConnection::sessionBus(), this);
if (notifyclient->isValid() ) {
b_validconnection = true;
getServerInformation();
getCapabilities();
QDBusConnection::sessionBus().connect(DBUS_SERVICE, DBUS_PATH, DBUS_INTERFACE, "NotificationClosed", this, SLOT(notificationClosed(quint32, quint32)));
QDBusConnection::sessionBus().connect(DBUS_SERVICE, DBUS_PATH, DBUS_INTERFACE, "ActionInvoked", this, SLOT(actionInvoked(quint32, QString)));
QDBusConnection::sessionBus().connect(DBUS_NOTIFY_SERVICE, DBUS_NOTIFY_PATH, DBUS_NOTIFY_INTERFACE, "NotificationClosed", this, SLOT(notificationClosed(quint32, quint32)));
QDBusConnection::sessionBus().connect(DBUS_NOTIFY_SERVICE, DBUS_NOTIFY_PATH, DBUS_NOTIFY_INTERFACE, "ActionInvoked", this, SLOT(actionInvoked(quint32, QString)));
} // if connection is valid
else {
notifyclient->deleteLater();
......
This diff is collapsed.
......@@ -45,7 +45,7 @@ class PropertiesEditor : public QDialog
public:
// members
PropertiesEditor(QWidget*, const arrayElement&, bool (*extractMapData) (QMap<QString,QVariant>&, const QVariant&) );
PropertiesEditor(QWidget*, const arrayElement&);
private:
// members
......@@ -55,6 +55,10 @@ class PropertiesEditor : public QDialog
QMap<QString,QVariant> ipv4map;
QMap<QString,QVariant> ipv6map;
QMap<QString,QVariant> proxmap;
QStringList sl_ipv4_method;
QStringList sl_ipv6_method;
QStringList sl_ipv6_privacy;
QStringList sl_proxy_method;
// functions
......
......@@ -68,8 +68,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>279</width>
<height>166</height>
<width>98</width>
<height>46</height>
</rect>
</property>
<property name="whatsThis">
......@@ -102,8 +102,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>279</width>
<height>166</height>
<width>98</width>
<height>46</height>
</rect>
</property>
<property name="whatsThis">
......@@ -136,8 +136,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>279</width>
<height>166</height>
<width>98</width>
<height>46</height>
</rect>
</property>
<property name="whatsThis">
......@@ -170,8 +170,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>154</width>
<height>132</height>
<width>279</width>
<height>166</height>
</rect>
</property>
<property name="whatsThis">
......@@ -215,21 +215,9 @@
</item>
<item row="0" column="1">
<widget class="QComboBox" name="comboBox_ipv4method">
<item>
<property name="text">
<string>DHCP</string>
</property>
</item>
<item>
<property name="text">
<string>Manual</string>
</property>
</item>
<item>
<property name="text">
<string>Off</string>
</property>
</item>
<property name="currentText">
<string/>
</property>
</widget>
</item>
<item row="0" column="0">
......@@ -261,8 +249,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>194</width>
<height>161</height>
<width>279</width>
<height>166</height>
</rect>
</property>
<property name="whatsThis">
......@@ -276,21 +264,9 @@
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="1">
<widget class="QComboBox" name="comboBox_ipv6method">
<item>
<property name="text">
<string>Auto</string>
</property>
</item>
<item>
<property name="text">
<string>Manual</string>
</property>
</item>
<item>
<property name="text">
<string>Off</string>
</property>
</item>
<property name="currentText">
<string/>
</property>
</widget>
</item>
<item row="3" column="0">
......@@ -315,7 +291,11 @@
</widget>
</item>
<item row="2" column="1">
<widget class="QLineEdit" name="lineEdit_ipv6address"/>
<widget class="QLineEdit" name="lineEdit_ipv6address">
<property name="text">
<string/>
</property>
</widget>
</item>
<item row="4" column="0">
<widget class="QLabel" name="label_6">
......@@ -336,21 +316,9 @@
</item>
<item row="4" column="1">
<widget class="QComboBox" name="comboBox_ipv6privacy">
<item>
<property name="text">
<string>Disabled</string>
</property>
</item>
<item>
<property name="text">
<string>Preferred</string>
</property>
</item>
<item>
<property name="text">
<string>Enabled</string>
</property>
</item>
<property name="currentText">
<string/>
</property>
</widget>
</item>
<item row="0" column="0">
......@@ -382,7 +350,7 @@
<rect>
<x>0</x>
<y>0</y>
<width>146</width>
<width>265</width>
<height>168</height>
</rect>
</property>
......@@ -404,21 +372,9 @@
</item>
<item row="0" column="1">
<widget class="QComboBox" name="comboBox_proxymethod">
<item>
<property name="text">
<string>Direct</string>
</property>
</item>
<item>
<property name="text">
<string>Auto</string>
</property>
</item>
<item>
<property name="text">
<string>Manual</string>
</property>
</item>
<property name="currentText">
<string/>
</property>
</widget>
</item>
<item row="1" column="0" colspan="2">
......
This diff is collapsed.
......@@ -35,39 +35,12 @@ DEALINGS IN THE SOFTWARE.
# include <QStatusBar>
# include <QActionGroup>
# include <QButtonGroup>
# include <QLabel>
# include <QLineEdit>
# include <QDialogButtonBox>
# include <QString>
# include <QStringList>
# include <QtDBus/QtDBus>
# include "ui_provisioning_editor.h"
//
// Class for an QInputDialog knockoff with validator
class ValidatingDialog : public QDialog
{
Q_OBJECT
public:
ValidatingDialog(QWidget*);
inline void setLabel(const QString& s) {label->setText(s);}
inline QString getText() {return lineedit->text();}
inline void clear() {lineedit->clear();}
void setValidator(const int&, bool plural = false);
inline bool isPlural() {return plural;}
private:
// members
QLabel* label;
QLineEdit* lineedit;
QDialogButtonBox* buttonbox;
bool plural;
};
// The class to control the properties editor UI based on a QDialog
class ProvisioningEditor : public QDialog
{
......
......@@ -370,6 +370,30 @@
<string>IPv6.Privacy</string>
</property>
</action>
<action name="actionTemplateeap_peap">
<property name="text">
<string>EAP-PEAP</string>
</property>
<property name="toolTip">
<string>EAP-PEAP</string>
</property>
</action>
<action name="actionTemplateeap_tls">
<property name="text">
<string>EAP-TLS</string>
</property>
<property name="toolTip">
<string>EAP-TLS</string>
</property>
</action>
<action name="actionTemplateeap_ttls">
<property name="text">
<string>EAP-TTLS</string>
</property>
<property name="toolTip">
<string>EAP-TTLS</string>
</property>
</action>
</widget>
<resources/>
<connections>
......
/**************************** shared.cpp ***************************
Functions shared across various classes
Copyright (C) 2013-2016
by: Andrew J. Bibb
License: MIT
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"),to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included
in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF C
* ONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.
***********************************************************************/
# include <QtCore/QDebug>
# include <QCoreApplication>
# include <QVBoxLayout>
# include <QRegularExpression>
# include <QRegularExpressionValidator>
# include "../resource.h"
# include "./shared.h"
# include "./code/trstring/tr_strings.h"
//
// Function to process the reply from a dbus call.
QDBusMessage::MessageType shared::processReply(const QDBusMessage& reply)
{
if (reply.type() != QDBusMessage::ReplyMessage) {
QMessageBox::warning(0,
QString(TranslateStrings::cmtr("cmst") + qApp->translate("processReply", " Warning") ),
qApp->translate("processReply",
"<center><b>We received a DBUS reply message indicating an error.</b></center>"
"<br><br>Error Name: %1<br><br>Error Message: %2")
.arg(reply.errorName())
.arg(TranslateStrings::cmtr(reply.errorMessage())) );
} // if reply is something other than a normal reply message
return reply.type();
}
//
// Function to extract the data from a QDBusArgument that contains a map.
// Some of the arrayElements can contain a QDBusArgument as the object
// instead of a primitive (string, bool, int, etc.). This function
// will extract the data from the QDBusArgument and write it into a map.
//
// Return value a bool, true on success, false otherwise.
// The map is sent by reference (called r_map here) and is modified by this function.
// r_var is a constant reference to the QDBusArgument.
//
bool shared::extractMapData(QMap<QString,QVariant>& r_map, const QVariant& r_var)
{
// make sure we can convert the QVariant into a QDBusArgument
if (! r_var.canConvert<QDBusArgument>() ) return false;
const QDBusArgument qdba = r_var.value<QDBusArgument>();
// make sure the QDBusArgument holds a map
if (qdba.currentType() != QDBusArgument::MapType ) return false;
// iterate over the QDBusArgument pulling map keys and values out
r_map.clear();
qdba.beginMap();
while ( ! qdba.atEnd() ) {
QString key;
QVariant value;
qdba.beginMapEntry();
qdba >> key >> value;
qdba.endMapEntry();
r_map.insert(key, value);
} // while
qdba.endMap();
return true;
}
//
// Validating Dialog - an input dialog knockoff with a validated lineedit.
// In addition to the usual input validation the dialog will only enable
// the OK button when the input is completely validated..
// Constructor
shared::ValidatingDialog::ValidatingDialog(QWidget* parent) : QDialog(parent)
{
// build the dialog
label = new QLabel(this);
lineedit = new QLineEdit(this);
lineedit->setClearButtonEnabled(true);
buttonbox = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel, Qt::Horizontal, this);
buttonbox->button(QDialogButtonBox::Ok)->setDisabled(true); // disable OK until input validates
this->setSizeGripEnabled(true);
QVBoxLayout* vboxlayout = new QVBoxLayout;
vboxlayout->addWidget(label);
vboxlayout->addWidget(lineedit);
vboxlayout->addWidget(buttonbox);
this->setLayout(vboxlayout);
// signals and slots
connect(buttonbox, SIGNAL(accepted()), this, SLOT(accept()));
connect(buttonbox, SIGNAL(rejected()), this, SLOT(reject()));
connect(lineedit, SIGNAL(textChanged(QString)), this, SLOT(textChanged()));
connect(lineedit, SIGNAL(returnPressed()), this, SLOT(accept()));
}
// Slot to set the lineedit validator. If plural is true multiple values can
// be supplied separated by comma, semi-colon or white space
void shared::ValidatingDialog::setValidator(const int& vd, bool plural)
{
// setup a switch to set the validator
QString s_ip4 = "(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9]?[0-9])";
QString s_ip6 = "(?:[0-9a-fA-F]{1,4})";
QString s_mac = "(?:[0-9a-fA-F]{1,2})";
QString s_hex = "[0-9a-fA-F]*";
QString s_int = "[0-9]*";
QString s_dom = "[0-9a-zA-Z]*[\\.]?[0-9a-zA-Z]*";
QString s_wd = "[0-9,a-zA-Z_\\.\\!\\@\\#\\$\\%\\^\\&\\*\\+\\-]*";
QString s_ch = "\\S";
QString s_start = (plural ? "\\s?|(" : "^");
QString s_end = (plural ? "(\\s*[,|;|\\s]\\s*))+" : "$");
switch (vd){
case CMST::ValDialog_IPv4: {
QRegularExpression rx4(s_start + s_ip4 + "(?:\\." + s_ip4 + "){3}" + s_end);
QRegularExpressionValidator* lev_4 = new QRegularExpressionValidator(rx4, this);
lineedit->setValidator(lev_4); }
break;
case CMST::ValDialog_IPv6: {
QRegularExpression rx6(s_start + s_ip6 + "(?::" + s_ip6 + "){7}" + s_end);
QRegularExpressionValidator* lev_6 = new QRegularExpressionValidator(rx6, this);
lineedit->setValidator(lev_6); }
break;
case CMST::ValDialog_MAC: {
QRegularExpression rxm(s_start + s_mac + "(?::" + s_mac + "){5}" + s_end);
QRegularExpressionValidator* lev_m = new QRegularExpressionValidator(rxm, this);
lineedit->setValidator(lev_m); }
break;
case CMST::ValDialog_46: {
QRegularExpression rx46(s_start + "(" + s_ip4 + "(?:\\." + s_ip4 + "){3}|" + s_ip6 + "(?::" + s_ip6 + "){7})" + s_end);
QRegularExpressionValidator* lev_46 = new QRegularExpressionValidator(rx46, this);
lineedit->setValidator(lev_46); }
break;
case CMST::ValDialog_Hex: {
QRegularExpression rxh(s_start + s_hex + s_end);
QRegularExpressionValidator* lev_h = new QRegularExpressionValidator(rxh, this);
lineedit->setValidator(lev_h); }
break;
case CMST::ValDialog_Int: {
QRegularExpression rxint(s_start + s_int + s_end);
QRegularExpressionValidator* lev_int = new QRegularExpressionValidator(rxint, this);
lineedit->setValidator(lev_int); }
break;
case CMST::ValDialog_Dom: {
QRegularExpression rxdom(s_start + s_dom + s_end);
QRegularExpressionValidator* lev_dom = new QRegularExpressionValidator(rxdom, this);
lineedit->setValidator(lev_dom); }
break;
case CMST::ValDialog_Wd: {
QRegularExpression rxwd(s_start + s_wd + s_end);
QRegularExpressionValidator* lev_wd = new QRegularExpressionValidator(rxwd, this);
lineedit->setValidator(lev_wd); }
break;
case CMST::ValDialog_min1ch: {
QRegularExpression rx1char(s_start + s_ch + "{1,}" + s_end);
QRegularExpressionValidator* lev_1char = new QRegularExpressionValidator(rx1char, this);
lineedit->setValidator(lev_1char); }
break;
case CMST::ValDialog_min8ch: {
QRegularExpression rx8char(s_start + s_ch + "{8,}" + s_end);
QRegularExpressionValidator* lev_8char = new QRegularExpressionValidator(rx8char, this);
lineedit->setValidator(lev_8char); }
break;
default:
lineedit->setValidator(0);
break;
} // switch
return;
}
//
// Slot to check if the text can be validated
// Called when the lineedit emits a textChanged() signal
void shared::ValidatingDialog::textChanged()
{
// enable OK button if text can be validated
buttonbox->button(QDialogButtonBox::Ok)->setEnabled(lineedit->hasAcceptableInput() );
return;
}
//
// Slot to initialize the dialog children
// Called when dialog finished() signal is triggered
void shared::ValidatingDialog::initialize()
{
lineedit->clear();
lineedit->setValidator(0);
lineedit->setInputMask(QString());
lineedit->setModified(false);
lineedit->setFocus(Qt::OtherFocusReason);
buttonbox->button(QDialogButtonBox::Ok)->setDisabled(true);
return;
}
/**************************** shared.h ***************************
Functions shared across various classes
Copyright (C) 2013-2016
by: Andrew J. Bibb
License: MIT
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"),to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included
in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.
***********************************************************************/
# ifndef CMST_SHARED
# define CMST_SHARED
# include <QMessageBox>
# include <QtDBus/QDBusMessage>
# include <QtDBus/QDBusArgument>
# include <QString>
# include <QVariant>
# include <QDialogButtonBox>
# include <QLineEdit>
# include <QLabel>
# include <QPushButton>
namespace shared {
//
// Class for an QInputDialog knockoff with validator
class ValidatingDialog : public QDialog
{
Q_OBJECT
public:
ValidatingDialog(QWidget*);
inline void setLabel(const QString& s) {label->setText(s);}
void setValidator(const int&, bool plural = false);
inline QString getText() {return lineedit->text().trimmed();}
inline void setText(const QString& s) {lineedit->setText(s);}
inline void clear() {initialize();}
inline bool isPlural() {return plural;}
private slots:
void textChanged();
void initialize();
private:
// members
QLabel* label;
QLineEdit* lineedit;
QDialogButtonBox* buttonbox;
bool plural;
};
QDBusMessage::MessageType processReply(const QDBusMessage& reply);
bool extractMapData(QMap<QString,QVariant>&,const QVariant&);
}
#endif
......@@ -27,7 +27,6 @@ FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.
***********************************************************************/
# include <QStringList>