Commit 2da600ea authored by Jan Grulich's avatar Jan Grulich
Browse files

Remove old version of the editor

parent 36d9dc9e
......@@ -87,8 +87,7 @@ if (WITH_MODEMMANAGER_SUPPORT)
endif()
add_subdirectory(applet)
# add_subdirectory(editor)
add_subdirectory(editor-qml)
add_subdirectory(editor)
add_subdirectory(kded)
add_subdirectory(libs)
add_subdirectory(settings)
......
include_directories(${CMAKE_SOURCE_DIR}/libs/editor
${CMAKE_SOURCE_DIR}/libs/editor/widgets
${CMAKE_SOURCE_DIR}/libs/models)
set(connectioneditor_sources
connectioneditor.cpp
main.cpp
)
add_executable(kde-nm-connection-editor
${connectioneditor_sources}
)
target_link_libraries(kde-nm-connection-editor
plasmanetworkmanagement-editor
KF5::NetworkManagerQt
Qt5::Core
Qt5::Gui
Qt5::Widgets # FIXME: QApplication
Qt5::Quick
KF5::I18n
KF5::Plasma
KF5::Service # Plasma dependency
KF5::KDE4Support # Plasma dependency
)
install(TARGETS kde-nm-connection-editor ${INSTALL_TARGETS_DEFAULT_ARGS})
install(DIRECTORY qml/ DESTINATION ${DATA_INSTALL_DIR}/kde-nm-connection-editor/qml)
#! /usr/bin/env bash
$XGETTEXT `find . -name "*.cpp" -o -name "*.qml"` -o $podir/kde-nm-connection-editor.pot
/*
Copyright 2013-2014 Jan Grulich <jgrulich@redhat.com>
Copyright 2013 Lukas Tinkl <ltinkl@redhat.com>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) version 3, or any
later version accepted by the membership of KDE e.V. (or its
successor approved by the membership of KDE e.V.), which shall
act as a proxy defined in Section 6 of version 3 of the license.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library. If not, see <http://www.gnu.org/licenses/>.
*/
#include "connectioneditor.h"
#include "connectiondetaileditor.h"
#include "mobileconnectionwizard.h"
#include <KService>
#include <KServiceTypeTrader>
ConnectionEditor::ConnectionEditor(QObject* parent)
: QObject(parent)
{
const KService::List services = KServiceTypeTrader::self()->query("PlasmaNetworkManagement/VpnUiPlugin");
foreach (const KService::Ptr & service, services) {
m_vpnPlugins.insert(service->name(), service->property("X-NetworkManager-Services", QVariant::String).toString());
}
}
ConnectionEditor::~ConnectionEditor()
{
}
void ConnectionEditor::addConnection(uint connectionType, bool shared)
{
NetworkManager::ConnectionSettings::ConnectionType type = (NetworkManager::ConnectionSettings::ConnectionType) connectionType;
if (type == NetworkManager::ConnectionSettings::Gsm) { // launch the mobile broadband wizard, both gsm/cdma
#if WITH_MODEMMANAGER_SUPPORT
QWeakPointer<MobileConnectionWizard> wizard = new MobileConnectionWizard(NetworkManager::ConnectionSettings::Unknown);
if (wizard.data()->exec() == QDialog::Accepted && wizard.data()->getError() == MobileProviders::Success) {
qDebug() << "Mobile broadband wizard finished:" << wizard.data()->type() << wizard.data()->args();
QPointer<ConnectionDetailEditor> editor = new ConnectionDetailEditor(wizard.data()->type(), wizard.data()->args());
editor->exec();
if (editor) {
editor->deleteLater();
}
}
if (wizard) {
wizard.data()->deleteLater();
}
#endif
} else {
if (type == NetworkManager::ConnectionSettings::Wired || type == NetworkManager::ConnectionSettings::Wireless) {
}
QPointer<ConnectionDetailEditor> editor = new ConnectionDetailEditor(type, QString(), shared);
editor->exec();
if (editor) {
editor->deleteLater();
}
}
}
void ConnectionEditor::addVpnConnection(const QString& plugin)
{
QPointer<ConnectionDetailEditor> editor = new ConnectionDetailEditor(NetworkManager::ConnectionSettings::Vpn, m_vpnPlugins[plugin], false);
editor->exec();
if (editor) {
editor->deleteLater();
}
}
QStringList ConnectionEditor::availableVpnPlugins() const
{
return m_vpnPlugins.keys();
}
// void ConnectionEditor::importSecretsFromPlainTextFiles()
// {
// const QString secretsDirectory = QStandardPaths::locate(QStandardPaths::DataLocation, "networkmanagement/secrets/", QStandardPaths::LocateDirectory);
// QDir dir(secretsDirectory);
// if (dir.exists() && !dir.entryList(QDir::Files).isEmpty()) {
// QMap<QString, QMap<QString, QString > > resultingMap;
// foreach (const QString & file, dir.entryList(QDir::Files)) {
// KConfig config(secretsDirectory % file, KConfig::SimpleConfig);
// foreach (const QString & groupName, config.groupList()) {
// KConfigGroup group = config.group(groupName);
// QMap<QString, QString> map = group.entryMap();
// if (!map.isEmpty()) {
// const QString entry = file % ';' % groupName;
// resultingMap.insert(entry, map);
// }
// }
// }
//
// storeSecrets(resultingMap);
// }
// }
// void ConnectionEditor::storeSecrets(const QMap< QString, QMap< QString, QString > >& map)
// {
// if (KWallet::Wallet::isEnabled()) {
// KWallet::Wallet * wallet = KWallet::Wallet::openWallet(KWallet::Wallet::LocalWallet(), 0, KWallet::Wallet::Synchronous);
//
// if (!wallet || !wallet->isOpen()) {
// return;
// }
//
// if (!wallet->hasFolder("Network Management")) {
// wallet->createFolder("Network Management");
// }
//
// if (wallet->hasFolder("Network Management") && wallet->setFolder("Network Management")) {
// int count = 0;
// foreach (const QString & entry, map.keys()) {
// QString connectionUuid = entry.split(';').first();
// connectionUuid.replace('{',"").replace('}',"");
// NetworkManager::Connection::Ptr connection = NetworkManager::findConnectionByUuid(connectionUuid);
//
// if (connection) {
// wallet->writeMap(entry, map.value(entry));
// ++count;
// }
// }
// }
// } else {
// KConfig config("plasma-networkmanagement");
// foreach (const QString & groupName, map.keys()) {
// KConfigGroup secretsGroup = config.group(groupName);
// NMStringMap secretsMap = map.value(groupName);
// NMStringMap::ConstIterator i = secretsMap.constBegin();
// while (i != secretsMap.constEnd()) {
// secretsGroup.writeEntry(i.key(), i.value());
// ++i;
// }
// }
// }
// }
// void ConnectionEditor::importVpn()
// {
// // get the list of supported extensions
// const KService::List services = KServiceTypeTrader::self()->query("PlasmaNetworkManagement/VpnUiPlugin");
// QString extensions;
// foreach (const KService::Ptr &service, services) {
// VpnUiPlugin * vpnPlugin = service->createInstance<VpnUiPlugin>(this);
// if (vpnPlugin) {
// extensions += vpnPlugin->supportedFileExtensions() % QLatin1Literal(" ");
// delete vpnPlugin;
// }
// }
//
// const QString filename = QFileDialog::getOpenFileName(this, i18n("Import VPN Connection"), QDir::homePath(), extensions.simplified());
// if (!filename.isEmpty()) {
// QFileInfo fi(filename);
// const QString ext = QLatin1Literal("*.") % fi.suffix();
// qDebug() << "Importing VPN connection" << filename << "extension:" << ext;
//
// foreach (const KService::Ptr &service, services) {
// VpnUiPlugin * vpnPlugin = service->createInstance<VpnUiPlugin>(this);
// if (vpnPlugin && vpnPlugin->supportedFileExtensions().contains(ext)) {
// qDebug() << "Found VPN plugin" << service->name() << ", type:" << service->property("X-NetworkManager-Services", QVariant::String).toString();
//
// NMVariantMapMap connection = vpnPlugin->importConnectionSettings(filename);
//
// //qDebug() << "Raw connection:" << connection;
//
// NetworkManager::ConnectionSettings connectionSettings;
// connectionSettings.fromMap(connection);
// connectionSettings.setUuid(NetworkManager::ConnectionSettings::createNewUuid());
//
// //qDebug() << "Converted connection:" << connectionSettings;
//
// const QString conId = NetworkManager::addConnection(connectionSettings.toMap());
// qDebug() << "Adding imported connection under id:" << conId;
//
// if (connection.isEmpty()) { // the "positive" part will arrive with connectionAdded
// m_editor->messageWidget->animatedShow();
// m_editor->messageWidget->setMessageType(KMessageWidget::Error);
// m_editor->messageWidget->setText(i18n("Importing VPN connection %1 failed\n%2", fi.fileName(), vpnPlugin->lastErrorMessage()));
// QTimer::singleShot(5000, m_editor->messageWidget, SLOT(animatedHide()));
// } else {
// delete vpnPlugin;
// break; // stop iterating over the plugins if the import produced at least some output
// }
//
// delete vpnPlugin;
// }
// }
// }
// }
// void ConnectionEditor::exportVpn()
// {
// const QModelIndex currentIndex = m_editor->connectionsWidget->currentIndex();
//
// if (!currentIndex.isValid() || currentIndex.parent().isValid()) {
// return;
// }
//
// Connection::Ptr connection = NetworkManager::findConnectionByUuid(currentIndex.data(NetworkModel::UuidRole).toString());
// if (!connection) {
// return;
// }
//
// NetworkManager::ConnectionSettings::Ptr connSettings = connection->settings();
//
// if (connSettings->connectionType() != NetworkManager::ConnectionSettings::Vpn)
// return;
//
// NetworkManager::VpnSetting::Ptr vpnSetting = connSettings->setting(NetworkManager::Setting::Vpn).dynamicCast<NetworkManager::VpnSetting>();
//
// qDebug() << "Exporting VPN connection" << connection->name() << "type:" << vpnSetting->serviceType();
//
// QString error;
// VpnUiPlugin * vpnPlugin = KServiceTypeTrader::createInstanceFromQuery<VpnUiPlugin>(QString::fromLatin1("PlasmaNetworkManagement/VpnUiPlugin"),
// QString::fromLatin1("[X-NetworkManager-Services]=='%1'").arg(vpnSetting->serviceType()),
// this, QVariantList(), &error);
//
// if (vpnPlugin) {
// if (vpnPlugin->suggestedFileName(connSettings).isEmpty()) { // this VPN doesn't support export
// m_editor->messageWidget->animatedShow();
// m_editor->messageWidget->setMessageType(KMessageWidget::Error);
// m_editor->messageWidget->setText(i18n("Export is not supported by this VPN type"));
// QTimer::singleShot(5000, m_editor->messageWidget, SLOT(animatedHide()));
// return;
// }
//
// const QString url = QStandardPaths::writableLocation(QStandardPaths::DocumentsLocation) + QDir::separator() + vpnPlugin->suggestedFileName(connSettings);
// const QString filename = QFileDialog::getSaveFileName(this, i18n("Export VPN Connection"), url, vpnPlugin->supportedFileExtensions());
// if (!filename.isEmpty()) {
// if (!vpnPlugin->exportConnectionSettings(connSettings, filename)) {
// m_editor->messageWidget->animatedShow();
// m_editor->messageWidget->setMessageType(KMessageWidget::Error);
// m_editor->messageWidget->setText(i18n("Exporting VPN connection %1 failed\n%2", connection->name(), vpnPlugin->lastErrorMessage()));
// QTimer::singleShot(5000, m_editor->messageWidget, SLOT(animatedHide()));
// } else {
// m_editor->messageWidget->animatedShow();
// m_editor->messageWidget->setMessageType(KMessageWidget::Positive);
// m_editor->messageWidget->setText(i18n("VPN connection %1 exported successfully", connection->name()));
// QTimer::singleShot(5000, m_editor->messageWidget, SLOT(animatedHide()));
// }
// }
// delete vpnPlugin;
// } else {
// qWarning() << "Error getting VpnUiPlugin for export:" << error;
// }
// }
/*
Copyright 2013-2014 Jan Grulich <jgrulich@redhat.com>
Copyright 2013 Lukas Tinkl <ltinkl@redhat.com>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) version 3, or any
later version accepted by the membership of KDE e.V. (or its
successor approved by the membership of KDE e.V.), which shall
act as a proxy defined in Section 6 of version 3 of the license.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef PLASMA_NM_CONNECTION_EDITOR_H
#define PLASMA_NM_CONNECTION_EDITOR_H
#include <QObject>
#include <NetworkManagerQt/ConnectionSettings>
class ConnectionEditor : public QObject
{
Q_OBJECT
Q_PROPERTY(QStringList availableVpnPlugins READ availableVpnPlugins)
public:
explicit ConnectionEditor(QObject* parent = 0);
virtual ~ConnectionEditor();
Q_INVOKABLE void addConnection(uint connectionType, bool shared);
Q_INVOKABLE void addVpnConnection(const QString& plugin);
// Q_INVOKABLE void exportVpn();
// Q_INVOKABLE void importVpn();
QStringList availableVpnPlugins() const;
private:
QMap<QString, QString> m_vpnPlugins;
// void importSecretsFromPlainTextFiles();
// void storeSecrets(const QMap<QString, QMap<QString, QString> > & map);
};
#endif // PLASMA_NM_CONNECTION_EDITOR_H
/*
Copyright 2014 Jan Grulich <jgrulich@redhat.com>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) version 3, or any
later version accepted by the membership of KDE e.V. (or its
successor approved by the membership of KDE e.V.), which shall
act as a proxy defined in Section 6 of version 3 of the license.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library. If not, see <http://www.gnu.org/licenses/>.
*/
#include <QApplication>
#include <QQmlApplicationEngine>
#include <QCommandLineParser>
#include <QtQml/QtQml>
#include <KGlobal>
#include <NetworkManagerQt/Settings>
#include <NetworkManagerQt/Connection>
#include <NetworkManagerQt/ConnectionSettings>
#include "connectioneditor.h"
#include "connectiondetaileditor.h"
void prependEnv(const char *env, const QByteArray &value)
{
QByteArray values = qgetenv(env);
if (!values.contains(value + ":")) {
values = value + ":" + values;
}
qputenv(env, values);
}
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
prependEnv("XDG_DATA_DIRS", "/opt/kde5/share");
// FIXME: OUCH!
prependEnv("QML2_IMPORT_PATH", "/usr/lib64/qml");
prependEnv("QML2_IMPORT_PATH", "/opt/kde5/lib64/qml");
// FIXME:
QCommandLineParser parser;
parser.addPositionalArgument("uuid", i18n("Edit connection"), "[uuid]");
parser.addHelpOption();
parser.addVersionOption();
parser.process(app);
const QStringList args = parser.positionalArguments();
if (!args.isEmpty()) {
NetworkManager::Connection::Ptr connection = NetworkManager::findConnectionByUuid(args.first());
if (connection) {
NetworkManager::ConnectionSettings::Ptr connectionSetting = connection->settings();
ConnectionDetailEditor * editor = new ConnectionDetailEditor(connectionSetting);
editor->show();
} else {
return 1;
}
} else {
qmlRegisterType<ConnectionEditor>("ConnectionEditor", 0, 1, "ConnectionEditor");
// FIXME
QQmlApplicationEngine * engine = new QQmlApplicationEngine("/opt/kde5/share/kde-nm-connection-editor/qml/main.qml");
}
return app.exec();
}
......@@ -2,43 +2,27 @@ include_directories(${CMAKE_SOURCE_DIR}/libs/editor
${CMAKE_SOURCE_DIR}/libs/editor/widgets
${CMAKE_SOURCE_DIR}/libs/models)
set(connectioneditor_SRCS
main.cpp
connectioneditor.cpp
set(connectioneditor_sources
connectioneditor.cpp
main.cpp
)
# add_app_icon(connectioneditor_SRCS "${KDE4_INSTALL_DIR}/share/icons/oxygen/*/devices/network-defaultroute.png" )
qt5_wrap_ui(connectioneditor_SRCS
ui/connectioneditor.ui
add_executable(kde-nm-connection-editor
${connectioneditor_sources}
)
add_executable(kde-nm-connection-editor ${connectioneditor_SRCS})
target_link_libraries(kde-nm-connection-editor
plasmanetworkmanagement-internal
plasmanetworkmanagement-editor
Qt5::Widgets
Qt5::Network
Qt5::DBus
KF5::NetworkManagerQt
KF5::Service
KF5::Completion
Qt5::Core
Qt5::Gui
Qt5::Widgets # FIXME: QApplication
Qt5::Quick
KF5::I18n
KF5::WidgetsAddons
KF5::KIOCore KF5::KIOWidgets
KF5::KIOWidgets
KF5::CoreAddons
KF5::Wallet
KF5::ItemViews
KF5::XmlGui
KF5::KDE4Support
KF5::Plasma
KF5::Service # Plasma dependency
KF5::KDE4Support # Plasma dependency
)
if (WITH_MODEMMANAGER_SUPPORT)
target_link_libraries(kde-nm-connection-editor KF5::ModemManagerQt)
endif()
install(TARGETS kde-nm-connection-editor DESTINATION ${INSTALL_TARGETS_DEFAULT_ARGS})
install(PROGRAMS kde-nm-connection-editor.desktop DESTINATION ${XDG_APPS_INSTALL_DIR})
install(FILES kde-nm-connection-editorui.rc DESTINATION ${DATA_INSTALL_DIR}/kde-nm-connection-editor)
install(TARGETS kde-nm-connection-editor ${INSTALL_TARGETS_DEFAULT_ARGS})
install(DIRECTORY qml/ DESTINATION ${DATA_INSTALL_DIR}/kde-nm-connection-editor/qml)
#! /usr/bin/env bash
$EXTRACTRC `find . -name "*.ui" -o -name "*.rc"` >> rc.cpp
$XGETTEXT `find . -name "*.cpp"` -o $podir/kde-nm-connection-editor.pot
rm -f rc.cpp
$XGETTEXT `find . -name "*.cpp" -o -name "*.qml"` -o $podir/kde-nm-connection-editor.pot
This diff is collapsed.
/*
Copyright 2013 Jan Grulich <jgrulich@redhat.com>
Copyright 2013-2014 Jan Grulich <jgrulich@redhat.com>
Copyright 2013 Lukas Tinkl <ltinkl@redhat.com>
This library is free software; you can redistribute it and/or
......@@ -22,53 +22,29 @@
#ifndef PLASMA_NM_CONNECTION_EDITOR_H
#define PLASMA_NM_CONNECTION_EDITOR_H
#include "handler.h"
#include <QObject>
#include <QMenu>
#include <QModelIndex>
#include <NetworkManagerQt/ConnectionSettings>
#include <KXmlGuiWindow>
#include <KActionMenu>
#include <NetworkManagerQt/Connection>
namespace Ui
{
class ConnectionEditor;
}
class QTreeWidgetItem;
class ConnectionEditor : public KXmlGuiWindow
class ConnectionEditor : public QObject
{
Q_OBJECT
Q_PROPERTY(QStringList availableVpnPlugins READ availableVpnPlugins)
public:
explicit ConnectionEditor(QWidget* parent = 0, Qt::WindowFlags flags = 0);
explicit ConnectionEditor(QObject* parent = 0);
virtual ~ConnectionEditor();
private Q_SLOTS:
void addConnection(QAction * action);
void connectionAdded(const QString & connection);
void connectConnection();
void disconnectConnection();
void editConnection();
void exportVpn();
void importVpn();
void initializeConnections();
void removeConnection();
void slotContextMenuRequested(const QPoint& point);
void slotItemClicked(const QModelIndex& index);
void slotItemDoubleClicked(const QModelIndex& index);
Q_INVOKABLE void addConnection(uint connectionType, bool shared);
Q_INVOKABLE void addVpnConnection(const QString& plugin);
// Q_INVOKABLE void exportVpn();
// Q_INVOKABLE void importVpn();
QStringList availableVpnPlugins() const;
private:
Ui::ConnectionEditor * m_editor;
Handler * m_handler;
KActionMenu * m_menu;
void initializeMenu();
void importSecretsFromPlainTextFiles();
void storeSecrets(const QMap<QString, QMap<QString, QString> > & map);
QMap<QString, QString> m_vpnPlugins;
// void importSecretsFromPlainTextFiles();
// void storeSecrets(const QMap<QString, QMap<QString, QString> > & map);
};
#endif // PLASMA_NM_CONNECTION_EDITOR_H
#!/usr/bin/env xdg-open
[Desktop Entry]
Name=kde-nm-connection-editor
Name[bs]=kde-nm-connection-editor
Name[ca]=kde-nm-connection-editor
Name[cs]=kde-nm-connection-editor
Name[da]=kde-nm-connection-editor
Name[de]=KDE-NM-Verbindungseditor
Name[el]=kde-nm-connection-editor
Name[es]=kde-nm-connection-editor
Name[fi]=kde-nm-connection-editor
Name[fr]=kde-nm-connection-editor
Name[hu]=kde-nm-connection-editor
Name[mr]=केडीई-एनएम-जुळवणी-संपादक
Name[nl]=Bewerker van verbindingen voor kde-nm
Name[pl]=kde-nm-connection-editor
Name[pt]=kde-nm-connection-editor
Name[pt_BR]=kde-nm-connection-editor
Name[ro]=kde-nm-connection-editor
Name[sk]=kde-nm-connection-editor
Name[sl]=kde-nm-connection-editor
Name[sv]=kde-nm-connection-editor
Name[tr]=kde-nm-connection-editor
Name[uk]=Редактор з’єднань kde-nm
Name[x-test]=xxkde-nm-connection-editorxx
Name[zh_CN]=kde-nm-connection-editor
GenericName=Connection editor
GenericName[bs]=Uređivač veze
GenericName[ca]=Editor de la connexió
GenericName[cs]=Editor spojení
GenericName[da]=Forbindelseseditor
GenericName[de]=Verbindungs-Editor
GenericName[el]=Επεξεργαστής συνδέσεων
GenericName[es]=Editor de conexión
GenericName[fi]=Yhteysmuokkain
GenericName[fr]=Éditeur de connexion
GenericName[hu]=Kapcsolatszerkesztő
GenericName[nl]=Bewerker van verbindingen
GenericName[pl]=Edytor połączenia
GenericName[pt]=Editor de ligações
GenericName[pt_BR]=Editor de conexão
GenericName[ro]=Redactor de conexiuni
GenericName[sk]=Editor pripojení
GenericName[sl]=Urejevalnik povezav
GenericName[sv]=Anslutningseditor
GenericName[tr]=Bağlantı düzenleyici
GenericName[uk]=Редактор з’єднань
GenericName[x-test]=xxConnection editorxx
GenericName[zh_CN]=连接编辑器
Comment=Edit your network connections
Comment[bs]=Uredi mrežne konekcije