Git commit ca08bb6ac50cd98fe8949e6481003807e4f3fc93 by Giorgos Tsiapaliwkas. Committed on 18/05/2012 at 14:22. Pushed by tsiapaliwkas into branch 'terietor/remoteinstaller'. Initial commit for Plasma Remote Installer M +24 -1 CMakeLists.txt M +53 -9 publisher/publisher.cpp M +4 -2 publisher/publisher.h A +48 -0 publisher/remoteinstaller/remoteinstaller.cpp [License: = GPL (v2+)] A +27 -0 publisher/remoteinstaller/remoteinstaller.h [License: GP= L (v2+)] A +105 -0 publisher/remoteinstaller/remoteinstaller.ui A +32 -0 publisher/remoteinstaller/remoteinstallerdialog.cpp [Lic= ense: GPL (v2+)] A +29 -0 publisher/remoteinstaller/remoteinstallerdialog.h [Licen= se: GPL (v2+)] A +50 -0 publisher/remoteinstaller/standalone/main.cpp [License: = GPL (v2+)] A +56 -0 publisher/remoteinstaller/standalone/plasmaremoteinstaller.c= pp [License: GPL (v2+)] A +30 -0 publisher/remoteinstaller/standalone/plasmaremoteinstaller.h= [License: GPL (v2+)] A +120 -0 publisher/remoteinstaller/standalone/plasmaremoteinstaller.ui http://commits.kde.org/plasmate/ca08bb6ac50cd98fe8949e6481003807e4f3fc93 diff --git a/CMakeLists.txt b/CMakeLists.txt index 7e1bf4b..2bffc9e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -54,9 +54,11 @@ set (PlasMate_SRC publisher/signingwidget.cpp publisher/signingdialog.cpp publisher/publisher.cpp + publisher/remoteinstaller/remoteinstaller.cpp + publisher/remoteinstaller/remoteinstallerdialog.cpp docbrowser/docbrowser.cpp projectmanager/projectmanager.cpp - ) +) = if (DEBUG_MODEL) set (PlasMate_SRC @@ -69,6 +71,7 @@ endif (DEBUG_MODEL) kde4_add_ui_files (PlasMate_SRC startpage.ui editors/metadata/metadata.ui + publisher/remoteinstaller/remoteinstaller.ui ) = include_directories(${KDE4_INCLUDES} @@ -103,4 +106,24 @@ install(FILES plasmate.desktop DESTINATION ${XDG_APPS_= INSTALL_DIR}) install(FILES plasmateui.rc DESTINATION ${DATA_INSTALL_DIR}/plasmate) install(FILES plasmate.knsrc DESTINATION ${CONFIG_INSTALL_DIR}) = +#standalone applications +set (PlasmaRemoteInstaller_SRC + publisher/remoteinstaller/remoteinstaller.cpp + publisher/remoteinstaller/standalone/main.cpp + publisher/remoteinstaller/standalone/plasmaremoteinstaller.cpp +) + +kde4_add_ui_files (PlasmaRemoteInstaller_SRC + publisher/remoteinstaller/standalone/plasmaremoteinstaller.ui +) + +kde4_add_executable(plasmaremoteinstaller ${PlasmaRemoteInstaller_SRC}) +target_link_libraries(plasmaremoteinstaller + ${KDE4_KDEUI_LIBS} + ${KDE4_KIO_LIBRARY} +) + +install(TARGETS plasmaremoteinstaller ${INSTALL_TARGETS_DEFAULT_ARGS}) + + macro_display_feature_log() diff --git a/publisher/publisher.cpp b/publisher/publisher.cpp index 3fcd268..bcace17 100644 --- a/publisher/publisher.cpp +++ b/publisher/publisher.cpp @@ -13,7 +13,11 @@ #include #include #include +#include = +#include +#include +#include #include #include #include @@ -27,6 +31,7 @@ #include "signingwidget.h" #include "../packagemodel.h" #include "../projectmanager/projectmanager.h" +#include "remoteinstaller/remoteinstallerdialog.h" = Publisher::Publisher(QWidget *parent, const KUrl &path, const QString& typ= e) : QDialog(parent), @@ -53,12 +58,14 @@ Publisher::Publisher(QWidget *parent, const KUrl &path,= const QString& type) m_installerButton->addItem(""); m_installerButton->addItem("Use PlasmaPkg"); m_installerButton->addItem("Use cmake"); + m_installerButton->addItem("Remote Install"); m_publisherButton =3D new QPushButton(i18n("Publish current project"),= this); = connect(m_exporterUrl, SIGNAL(urlSelected(const KUrl&)), this, SLOT(ad= dSuffix())); connect(m_exporterButton, SIGNAL(clicked()), this, SLOT(doExport())); - connect(m_installerButton, SIGNAL(currentIndexChanged(int)), this, SLO= T(doPlasmaPkg())); - connect(m_installerButton, SIGNAL(currentIndexChanged(int)), this, SLO= T(doCMake())); + connect(m_installerButton, SIGNAL(currentIndexChanged(int)), this, SLO= T(doPlasmaPkg(int))); + connect(m_installerButton, SIGNAL(currentIndexChanged(int)), this, SLO= T(doCMake(int))); + connect(m_installerButton, SIGNAL(currentIndexChanged(int)), this, SLO= T(doRemoteInstall(int))); connect(m_publisherButton, SIGNAL(clicked()), this, SLOT(doPublish())); = // Publish only works right for Plasmoid now afaik. Disabling for othe= r project types. @@ -126,7 +133,7 @@ void Publisher::doExport() } bool ok =3D exportToFile(m_exporterUrl->url()); = - // If signign is enabled, lets do that! + // If signign is enabled, lets do that!1 if (m_signingWidget->signingEnabled()) { ok =3D ok && m_signingWidget->sign(m_exporterUrl->url()); } @@ -139,16 +146,21 @@ void Publisher::doExport() } = // Plasmoid specific, for now -void Publisher::doCMake() +void Publisher::doCMake(int index) { + //check if this the index that we want + if (index !=3D 2) { + return; + } + if (m_projectType !=3D "Plasma/Applet") { qDebug() << "chaos"; return; } = - qDebug() << "aei gamis"; - const KUrl tempPackage(tempPackagePath()); + //this is the CMakeLists.txt from the templates directory QFile cmakeListsSourceFile(KStandardDirs::locate("appdata", "templates= /") + "cmakelists"); + QFile cmakeListsDestinationFile(m_projectPath.pathOrUrl() + "CMakeList= s.txt"); = cmakeListsSourceFile.open(QIODevice::ReadOnly); @@ -164,21 +176,41 @@ void Publisher::doCMake() = cmakeListsDestinationFile.close(); cmakeListsSourceFile.close(); + + //we need the last loaded package which also is the current package. + KConfigGroup cg(KGlobal::config(), "PackageModel::package"); + QString packagePath(cg.readEntry("lastLoadedPackage", QString())); + + //create a temporary build dir + QDir dir(packagePath); + dir.mkdir("build"); + + //TODO now we have to move into the build dir but how? QStringList argv("cmake"); - argv.append("-DCMAKE_INSTALL_PREFIX=3D$HOME"); - argv.append(tempPackagePath()); + argv.append(packagePath); + if(KProcess::execute(argv) >=3D 0 ? true: false) { QDBusInterface dbi("org.kde.kded", "/kbuildsycoca", "org.kde.kbuil= dsycoca"); dbi.call(QDBus::NoBlock, "recreate"); + KMessageBox::information(this, i18n("Project has been installed")); } else { KMessageBox::error(this, i18n("Project has not been installed")); return; } + + //now delete the temporary build directory. We don't need it anymore + KIO::del(packagePath + "build", KIO::HideProgressInfo); + //TODO remove the CMakeLists.txt in ~/.kde4/share/apps/plasma/plasmoid= s/projectName } = // Plasmoid specific, for now -void Publisher::doPlasmaPkg() +void Publisher::doPlasmaPkg(int index) { + //check if this the index that we want + if (index !=3D 1) { + return; + } + const KUrl tempPackage(tempPackagePath()); qDebug() << "tempPackagePath" << tempPackage.pathOrUrl(); qDebug() << "m_projectPath" << m_projectPath.pathOrUrl(); @@ -242,6 +274,18 @@ void Publisher::doPlasmaPkg() } } = +void Publisher::doRemoteInstall(int index) +{ + //check if this the index that we want + if (index !=3D 3) { + return; + } + + QPointer dialog =3D new RemoteInstallerDialog(); + dialog->exec(); + delete dialog; +} + const QString Publisher::tempPackagePath() { QDir d(m_projectPath.pathOrUrl()); diff --git a/publisher/publisher.h b/publisher/publisher.h index 6eba693..e001f19 100644 --- a/publisher/publisher.h +++ b/publisher/publisher.h @@ -22,6 +22,7 @@ class QComboBox; namespace Ui { class Publisher; +class RemoteInstaller; } = class Publisher : public QDialog @@ -35,8 +36,9 @@ private slots: void doExport(); void addSuffix(); void doPublish(); - void doPlasmaPkg(); - void doCMake(); + void doPlasmaPkg(int index); + void doCMake(int index); + void doRemoteInstall(int index); = private: bool exportToFile(const KUrl& url); diff --git a/publisher/remoteinstaller/remoteinstaller.cpp b/publisher/remo= teinstaller/remoteinstaller.cpp new file mode 100644 index 0000000..9c3729e --- /dev/null +++ b/publisher/remoteinstaller/remoteinstaller.cpp @@ -0,0 +1,48 @@ +/* + * Copyright 2012 Giorgos Tsiapaliwkas > + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + */ + +#include "remoteinstaller.h" + +#include +#include +#include +#include + +#include + +RemoteInstaller::RemoteInstaller(QObject* parent) + : QObject(parent) +{ +} + +#include +void RemoteInstaller::install(const QString& username, const QString& ip, = QWidget *window) +{ + //like fish://username@192.123.23.1 + KUrl execUrl =3D "fish://" + username + "@" + ip; + + //now we need the src + KConfigGroup c(KGlobal::config(), "PackageModel::package"); + QString src =3D c.readEntry("lastLoadedPackage", QString()); + + //now we need the destination in the target pc + QString destination =3D KIO::NetAccess::fish_execute(execUrl, "kde4-co= nfig --path data > ~/a", window); + + qDebug() << "dest" << destination; + //copy the project in the target's plasmate data directory + //KIO::NetAccess::dircopy(src, destination, window); + + //TODO we need both but this isn't a good solution + //execute plasmapkg + //KIO::NetAccess::fish_execute(execUrl, "plasmapkg -i + projectPath, w= indow); + // KIO::NetAccess::fish_execute(execUrl, "plasmapkg -u + projectPath, = window); + + //execute kbuildsycoca4 + KIO::NetAccess::fish_execute(execUrl, "kbuildsycoca4", window); +} \ No newline at end of file diff --git a/publisher/remoteinstaller/remoteinstaller.h b/publisher/remote= installer/remoteinstaller.h new file mode 100644 index 0000000..07eecf5 --- /dev/null +++ b/publisher/remoteinstaller/remoteinstaller.h @@ -0,0 +1,27 @@ +/* + * Copyright 2012 Giorgos Tsiapaliwkas + * = + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + */ + +#ifndef REMOTEINSTALLERCORE_H +#define REMOTEINSTALLERCORE_H + +#include +#include + +class QWidget; + +class RemoteInstaller : public QObject +{ + Q_OBJECT; +public: + RemoteInstaller(QObject* parent =3D 0); + + static void install(const QString& username, const QString& ip, QWidge= t *window); +}; + +#endif // PUBLISHER_H diff --git a/publisher/remoteinstaller/remoteinstaller.ui b/publisher/remot= einstaller/remoteinstaller.ui new file mode 100644 index 0000000..a9f1ee5 --- /dev/null +++ b/publisher/remoteinstaller/remoteinstaller.ui @@ -0,0 +1,105 @@ + + + RemoteInstaller + + + + 0 + 0 + 612 + 250 + + + + + 550 + 250 + + + + Form + + + + + 0 + 0 + 614 + 221 + + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + <html><head/><body><p><span st= yle=3D" font-weight:600;">HINT: Add below the username and the= ip of the target computer</span></p></body></html>= + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + + + Target ip address + + + + + + + + + + Target Username + + + + + + + + + + + + + + KLineEdit + QLineEdit +
klineedit.h
+
+
+ + +
diff --git a/publisher/remoteinstaller/remoteinstallerdialog.cpp b/publishe= r/remoteinstaller/remoteinstallerdialog.cpp new file mode 100644 index 0000000..bd643c3 --- /dev/null +++ b/publisher/remoteinstaller/remoteinstallerdialog.cpp @@ -0,0 +1,32 @@ +/* + * Copyright 2012 Giorgos Tsiapaliwkas > + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + */ + +#include "remoteinstallerdialog.h" +#include "remoteinstaller.h" + +RemoteInstallerDialog::RemoteInstallerDialog(QWidget* parent) + : KDialog(parent) +{ + QWidget *widget =3D new QWidget(this); + + m_ui.setupUi(widget); + setMainWidget(widget); + + connect(this, SIGNAL(okClicked()), this, SLOT(install())); +} + +void RemoteInstallerDialog::install() +{ + const QString username =3D m_ui.usernameLineEdit->text(); + const QString ip =3D m_ui.ipLineEdit->text(); + if (!username.isEmpty() && !ip.isEmpty()) { + RemoteInstaller::install(username, ip, this); + } +} + diff --git a/publisher/remoteinstaller/remoteinstallerdialog.h b/publisher/= remoteinstaller/remoteinstallerdialog.h new file mode 100644 index 0000000..0ab7b85 --- /dev/null +++ b/publisher/remoteinstaller/remoteinstallerdialog.h @@ -0,0 +1,29 @@ +/* + * Copyright 2012 Giorgos Tsiapaliwkas + * = + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + */ + +#ifndef REMOTEINSTALLERDIALOG_H +#define REMOTEINSTALLERDIALOG_H + +#include + +#include "ui_remoteinstaller.h" + +class RemoteInstallerDialog : public KDialog +{ + Q_OBJECT; +public: + RemoteInstallerDialog(QWidget* parent =3D 0); + = +public Q_SLOTS: + void install(); +private: + Ui::RemoteInstaller m_ui; +}; + +#endif // PUBLISHER_H diff --git a/publisher/remoteinstaller/standalone/main.cpp b/publisher/remo= teinstaller/standalone/main.cpp new file mode 100644 index 0000000..71f3954 --- /dev/null +++ b/publisher/remoteinstaller/standalone/main.cpp @@ -0,0 +1,50 @@ +/* + * Copyright 2012 Giorgos Tsiapaliwkas + * = + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of + * the License, or (at your option) any later version. + * = + * This program 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#include +#include +#include +#include + +#include + +#include "plasmaremoteinstaller.h" + +int main(int argc, char *argv[]) +{ + KAboutData aboutData("plasmaremoteinstaller", 0, ki18n("Plasma Remote = installer"), + "0.1alpha3", ki18n("Plasma Remote Installer"), + KAboutData::License_GPL, + ki18n("Copyright 2012 Plasma Development Team"), + KLocalizedString(), "", "plasma-devel@kde.org"); + + aboutData.addAuthor(ki18n("Giorgos Tsiapaliwkas"), ki18n("Author"), "t= erietor@gmail.com"); + + KCmdLineArgs::init(argc, argv, &aboutData); + + KCmdLineOptions options; + KCmdLineArgs::addCmdLineOptions(options); + KCmdLineArgs *args =3D KCmdLineArgs::parsedArgs(); + KApplication app; + + QPointer dialog =3D new PlasmaRemoteInstaller(); + dialog->exec(); + delete dialog; + + return app.exec(); +} + diff --git a/publisher/remoteinstaller/standalone/plasmaremoteinstaller.cpp= b/publisher/remoteinstaller/standalone/plasmaremoteinstaller.cpp new file mode 100644 index 0000000..3fa4a4f --- /dev/null +++ b/publisher/remoteinstaller/standalone/plasmaremoteinstaller.cpp @@ -0,0 +1,56 @@ +/* + * Copyright 2012 Giorgos Tsiapaliwkas > + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + */ + +#include "plasmaremoteinstaller.h" +#include "../remoteinstaller.h" + +PlasmaRemoteInstaller::PlasmaRemoteInstaller(QWidget* parent) + : KDialog(parent) +{ + QWidget *widget =3D new QWidget(this); + + m_ui.setupUi(widget); + setMainWidget(widget); + + connect(this, SIGNAL(okClicked()), this, SLOT(install())); + connect(m_ui.srcUrl, SIGNAL(textChanged(const QString&)), this, SLOT(c= heckProjectPath(const QString&))); + + //disable the buttons. The user hasn't give a path yet. + m_ui.usernameLineEdit->setEnabled(false); + m_ui.ipLineEdit->setEnabled(false); + enableButtonOk(false); +} + +void PlasmaRemoteInstaller::install() +{ + const QString username =3D m_ui.usernameLineEdit->text(); + const QString ip =3D m_ui.ipLineEdit->text(); + if (!username.isEmpty() && !ip.isEmpty()) { + RemoteInstaller::install(username, ip, this); + } +} + +void PlasmaRemoteInstaller::checkProjectPath(const QString& path) +{ + if (path.isEmpty()) { + return; + } + + //check if projectName/metadata.desktop exists + if(path.endsWith("metadata.desktop")) { + m_ui.usernameLineEdit->setEnabled(true); + m_ui.ipLineEdit->setEnabled(true); + enableButtonOk(true); + } else { + m_ui.usernameLineEdit->setEnabled(false); + m_ui.ipLineEdit->setEnabled(false); + enableButtonOk(false); + } +} + diff --git a/publisher/remoteinstaller/standalone/plasmaremoteinstaller.h b= /publisher/remoteinstaller/standalone/plasmaremoteinstaller.h new file mode 100644 index 0000000..9145ce7 --- /dev/null +++ b/publisher/remoteinstaller/standalone/plasmaremoteinstaller.h @@ -0,0 +1,30 @@ +/* + * Copyright 2012 Giorgos Tsiapaliwkas + * = + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + */ + +#ifndef PLASMAREMOTEINSTALLER_H +#define PLASMAREMOTEINSTALLER_H + +#include + +#include "ui_plasmaremoteinstaller.h" + +class PlasmaRemoteInstaller : public KDialog +{ + Q_OBJECT; +public: + PlasmaRemoteInstaller(QWidget* parent =3D 0); + +public Q_SLOTS: + void install(); + void checkProjectPath(const QString& path); +private: + Ui::PlasmaRemoteInstaller m_ui; +}; + +#endif // PUBLISHER_H diff --git a/publisher/remoteinstaller/standalone/plasmaremoteinstaller.ui = b/publisher/remoteinstaller/standalone/plasmaremoteinstaller.ui new file mode 100644 index 0000000..1965c44 --- /dev/null +++ b/publisher/remoteinstaller/standalone/plasmaremoteinstaller.ui @@ -0,0 +1,120 @@ + + + PlasmaRemoteInstaller + + + + 0 + 0 + 652 + 260 + + + + + 650 + 250 + + + + Form + + + + + 0 + 0 + 651 + 251 + + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + <html><head/><body><p><span st= yle=3D" font-weight:600;">HINT: Add below the username and the= ip of the target computer</span></p></body></html>= + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + + + Target ip address + + + + + + + Target Username + + + + + + + + + + + + + Project source + + + + + + + + + + + + + + KLineEdit + QLineEdit +
klineedit.h
+
+ + KUrlRequester + QFrame +
kurlrequester.h
+
+
+ + +