[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    [plasmate/terietor/remoteinstaller] publisher: Populate the remoteinstaller
From:       Giorgos Tsiapaliwkas <terietor () gmail ! com>
Date:       2012-05-31 12:00:00
Message-ID: 20120531120000.CBC52A60A9 () git ! kde ! org
[Download RAW message or body]

Git commit e43b192630954658de279010fe308b21e87a143d by Giorgos \
Tsiapaliwkas. Committed on 31/05/2012 at 13:59.
Pushed by tsiapaliwkas into branch 'terietor/remoteinstaller'.

Populate the remoteinstaller

M  +1    -0    publisher/publisher.cpp
M  +56   -20   publisher/remoteinstaller/remoteinstaller.cpp
M  +16   -5    publisher/remoteinstaller/remoteinstaller.h
M  +3    -23   publisher/remoteinstaller/remoteinstaller.ui
M  +11   -6    publisher/remoteinstaller/remoteinstallerdialog.cpp
M  +4    -1    publisher/remoteinstaller/remoteinstallerdialog.h
M  +2    -2    publisher/remoteinstaller/standalone/main.cpp
M  +0    -3    publisher/remoteinstaller/standalone/plasmaremoteinstaller.cpp


http://commits.kde.org/plasmate/e43b192630954658de279010fe308b21e87a143d

diff --git a/publisher/publisher.cpp b/publisher/publisher.cpp
index 2592f53..1baa116 100644
--- a/publisher/publisher.cpp
+++ b/publisher/publisher.cpp
@@ -182,6 +182,7 @@ void Publisher::doCMake(int index)
 
     //create a temporary build dir
     QDir dir(packagePath);
+    dir.mkdir("build/");
 
     //cd build/
     dir.cd("build/");
diff --git a/publisher/remoteinstaller/remoteinstaller.cpp \
b/publisher/remoteinstaller/remoteinstaller.cpp index 01280cb..1418eb2 \
                100644
--- a/publisher/remoteinstaller/remoteinstaller.cpp
+++ b/publisher/remoteinstaller/remoteinstaller.cpp
@@ -9,38 +9,74 @@
 
 #include "remoteinstaller.h"
 
+#include <unistd.h>
+
 #include <KIO/NetAccess>
 #include <KIO/CopyJob>
+#include <KMessageBox>
 
 #include <QWidget>
 #include <QDir>
 
-RemoteInstaller::RemoteInstaller(QObject* parent)
-        : QObject(parent)
+RemoteInstaller::RemoteInstaller(const QString& username, const QString& \
hostname, +                                 const QString& source, QWidget \
*window, QObject* parent) +        : QObject(parent),
+          m_widget(window)
 {
+    //like fish://username@192.123.23.1
+    m_execUrl.setUrl("fish://" + hostname);
+    m_execUrl.setUserName(username);
+
+    //we need a temporary directory
+    //all users have access into /var/tmp
+    if (!KIO::NetAccess::exists(m_execUrl, \
"/var/tmp/plasmaremoteinstaller/", m_widget)) { +        \
KIO::NetAccess::exists(m_execUrl, "/var/tmp/plasmaremoteinstaller/", \
m_widget); +    }
+
+    QString temporaryDirectory("/var/tmp/plasmaremoteinstaller/");
+
+    //our destination path
+    m_destinationPath = m_execUrl;
+    m_destinationPath.setPath(temporaryDirectory);
+
+    //we need the name of the package and the directory
+    QDir packageDir(source);
+    //NOTE our path isn't a directory it is a metadata.desktop,
+    //that's plasmate's way to validate packages
+    packageDir.cdUp();
+    m_sourcePath = packageDir.path();
+
+    m_plasmaPkgUrl.append("plasmapkg -u " + temporaryDirectory + \
packageDir.dirName() + '/'); +
 }
 
-#include <QDebug>
-void RemoteInstaller::install(const QString& username, const QString& ip,
-                              const QString& source, const QString& \
temporaryDirectory, QWidget *window) +void RemoteInstaller::doInstall()
 {
-    //like fish://username@192.123.23.1
-    QString execUrl = "fish://" + username + "@" + ip;
+    //copy the project in the target's plasmate data directory
+    KIO::CopyJob *copy = KIO::copy(m_sourcePath, m_destinationPath);
 
-    //we need the url of the src
-    QString destinationPath;
-    destinationPath.append(execUrl);
-    destinationPath.append(temporaryDirectory);
+    //an error has occured.
+    if (copy->error() != 0) {
+        //show the error to the user.
+        KMessageBox::error(m_widget, copy->errorText());
+    }
 
-    //copy the project in the target's plasmate data directory
-    KIO::copy(source, temporaryDirectory);
+    connect(copy, SIGNAL(result(KJob*)), this, SLOT(doPlasmaPkg()));
+}
 
-    //we need the name of the package
-    QDir packageDir(source);
+void RemoteInstaller::doPlasmaPkg()
+{
+    KIO::NetAccess::fish_execute(m_execUrl, m_plasmaPkgUrl, m_widget);
+
+    //an error has occured.
+    if (KIO::NetAccess::lastError()) {
+        //show the error
+        KMessageBox::error(m_widget, KIO::NetAccess::lastErrorString());
+    }
+    //wait plasmapkg -u to finish
+    sleep(5);
+
+    KIO::NetAccess::fish_execute(m_execUrl, "kbuildsycoca4", m_widget);
+}
 
-    //execute plasmapkg
-     KIO::NetAccess::fish_execute(execUrl, "plasmapkg -u" + \
destinationPath + packageDir.dirName(), 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/remoteinstaller/remoteinstaller.h index 88117ed..e642eae 100644
--- a/publisher/remoteinstaller/remoteinstaller.h
+++ b/publisher/remoteinstaller/remoteinstaller.h
@@ -11,18 +11,29 @@
 #define REMOTEINSTALLERCORE_H
 
 #include <QObject>
-#include <KUrl>
+#include <QUrl>
 
 class QWidget;
 
 class RemoteInstaller : public QObject
 {
-    Q_OBJECT;
+    Q_OBJECT
 public:
-    RemoteInstaller(QObject* parent = 0);
+    RemoteInstaller(const QString& username, const QString& hostname,
+                    const QString& source, QWidget *window, QObject* \
parent = 0); +
+   void doInstall();
+
+private Q_SLOTS:
+    void doPlasmaPkg();
+
+private:
+    QUrl m_execUrl;
+    QString m_plasmaPkgUrl;
+    QString m_sourcePath;
+    QUrl m_destinationPath;
+    QWidget *m_widget;
 
-    static void install(const QString& username, const QString& ip,
-                        const QString& source, const QString& \
temporaryDirectory, QWidget *window);  };
 
 #endif // PUBLISHER_H
diff --git a/publisher/remoteinstaller/remoteinstaller.ui \
b/publisher/remoteinstaller/remoteinstaller.ui index d2ae349..e109610 \
                100644
--- a/publisher/remoteinstaller/remoteinstaller.ui
+++ b/publisher/remoteinstaller/remoteinstaller.ui
@@ -6,8 +6,8 @@
    <rect>
     <x>0</x>
     <y>0</y>
-    <width>643</width>
-    <height>512</height>
+    <width>550</width>
+    <height>469</height>
    </rect>
   </property>
   <property name="minimumSize">
@@ -72,7 +72,7 @@
     <item>
      <widget class="QLabel" name="label_6">
       <property name="text">
-       <string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;&lt;span \
style=&quot; font-size:12pt; font-weight:600;&quot;&gt;IP \
Address&lt;/span&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string> +       \
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;&lt;span style=&quot; \
font-size:12pt; font-weight:600;&quot;&gt;Hostname&lt;/span&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
  </property>
      </widget>
     </item>
@@ -90,26 +90,6 @@
      <widget class="KLineEdit" name="ipLineEdit"/>
     </item>
     <item>
-     <widget class="QLabel" name="label_8">
-      <property name="text">
-       <string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;&lt;span \
style=&quot; font-size:12pt; font-weight:600;&quot;&gt;Temporary \
                Directory&lt;/span&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
                
-      </property>
-     </widget>
-    </item>
-    <item>
-     <widget class="KSeparator" name="kseparator_3"/>
-    </item>
-    <item>
-     <widget class="QLabel" name="label_9">
-      <property name="text">
-       <string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;For this \
process the remote installer will need a temporary \
directory.&lt;/p&gt;&lt;p&gt;Choose one. After the installation the \
temporary directory will \
be&lt;/p&gt;&lt;p&gt;untouched.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
                
-      </property>
-     </widget>
-    </item>
-    <item>
-     <widget class="KUrlRequester" name="tmpDirUrl"/>
-    </item>
-    <item>
      <widget class="QLabel" name="label">
       <property name="text">
        <string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;&lt;span \
style=&quot; font-size:12pt;&quot;&gt;Install \
                Package&lt;/span&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
                
diff --git a/publisher/remoteinstaller/remoteinstallerdialog.cpp \
b/publisher/remoteinstaller/remoteinstallerdialog.cpp index \
                04bd13e..efc1d33 100644
--- a/publisher/remoteinstaller/remoteinstallerdialog.cpp
+++ b/publisher/remoteinstaller/remoteinstallerdialog.cpp
@@ -14,7 +14,8 @@
 #include <QVBoxLayout>
 
 RemoteInstallerDialog::RemoteInstallerDialog(QWidget* parent)
-        : QDialog(parent)
+        : QDialog(parent),
+        m_installer(0)
 {
     QWidget *widget = new QWidget();
 
@@ -30,7 +31,6 @@ RemoteInstallerDialog::RemoteInstallerDialog(QWidget* \
parent)  
     connect(m_ui.usernameLineEdit, SIGNAL(textChanged(const QString&)), \
                this, SLOT(checkInformations()));
     connect(m_ui.ipLineEdit, SIGNAL(textChanged(const QString&)), this, \
                SLOT(checkInformations()));
-    connect(m_ui.tmpDirUrl, SIGNAL(textChanged(const QString&)), this, \
                SLOT(checkInformations()));
     connect(m_ui.installButton, SIGNAL(clicked()), this, SLOT(install()));
 
     //we don't want the source relative ui to be visible.
@@ -42,21 +42,25 @@ RemoteInstallerDialog::RemoteInstallerDialog(QWidget* \
parent)  
 }
 
+RemoteInstallerDialog::~RemoteInstallerDialog()
+{
+    delete m_installer;
+}
+
+
 void RemoteInstallerDialog::checkInformations()
 {
     const QString username = m_ui.usernameLineEdit->text();
     const QString ip = m_ui.ipLineEdit->text();
-    const QString tmpDir = m_ui.tmpDirUrl->text();
 
     QFile metadateDesktopFile(m_packagePath);
     if (!metadateDesktopFile.exists()) {
         return;
     }
 
-    if (!username.isEmpty() && !ip.isEmpty() && !tmpDir.isEmpty()) {
+    if (!username.isEmpty() && !ip.isEmpty()) {
         m_username = username;
         m_ip = ip;
-        m_tmpDir = tmpDir;
 
         //now enable the install button
         m_ui.installButton->setEnabled(true);
@@ -66,7 +70,8 @@ void RemoteInstallerDialog::checkInformations()
 
 void RemoteInstallerDialog::install()
 {
-    RemoteInstaller::install(m_username, m_ip, m_packagePath, m_tmpDir, \
this); +    m_installer = new RemoteInstaller(m_username, m_ip, \
m_packagePath, this); +    m_installer->doInstall();
 }
 
 QString RemoteInstallerDialog::packagePath() const
diff --git a/publisher/remoteinstaller/remoteinstallerdialog.h \
b/publisher/remoteinstaller/remoteinstallerdialog.h index b84f9c3..0e9541f \
                100644
--- a/publisher/remoteinstaller/remoteinstallerdialog.h
+++ b/publisher/remoteinstaller/remoteinstallerdialog.h
@@ -14,11 +14,14 @@
 
 #include "ui_remoteinstaller.h"
 
+class RemoteInstaller;
+
 class RemoteInstallerDialog : public QDialog
 {
     Q_OBJECT;
 public:
     RemoteInstallerDialog(QWidget* parent = 0);
+    ~RemoteInstallerDialog();
 
     QString packagePath() const;
     void setPackagePath(const QString& path);
@@ -31,10 +34,10 @@ protected:
     Ui::RemoteInstaller m_ui;
 
 private:
+    RemoteInstaller *m_installer;
     QString m_packagePath;
     QString m_username;
     QString m_ip;
-    QString m_tmpDir;
 };
 
 #endif // PUBLISHER_H
diff --git a/publisher/remoteinstaller/standalone/main.cpp \
b/publisher/remoteinstaller/standalone/main.cpp index 4471197..9c940d3 \
                100644
--- a/publisher/remoteinstaller/standalone/main.cpp
+++ b/publisher/remoteinstaller/standalone/main.cpp
@@ -1,11 +1,11 @@
 /*
  * Copyright 2012 Giorgos Tsiapaliwkas <terietor@gmail.com>
- * 
+ *
  * 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
diff --git a/publisher/remoteinstaller/standalone/plasmaremoteinstaller.cpp \
b/publisher/remoteinstaller/standalone/plasmaremoteinstaller.cpp index \
                a1d6216..37f9dbe 100644
--- a/publisher/remoteinstaller/standalone/plasmaremoteinstaller.cpp
+++ b/publisher/remoteinstaller/standalone/plasmaremoteinstaller.cpp
@@ -18,7 +18,6 @@ PlasmaRemoteInstaller::PlasmaRemoteInstaller(QWidget* \
parent)  //disable the buttons. The user hasn't give a path yet.
     m_ui.usernameLineEdit->setEnabled(false);
     m_ui.ipLineEdit->setEnabled(false);
-    m_ui.tmpDirUrl->setEnabled(false);
 
     //we want the source relative ui to be visible.
     m_ui.srcLabel1->setVisible(true);
@@ -38,10 +37,8 @@ void PlasmaRemoteInstaller::checkProjectPath(const \
QString& path)  setPackagePath(path);
         m_ui.usernameLineEdit->setEnabled(true);
         m_ui.ipLineEdit->setEnabled(true);
-        m_ui.tmpDirUrl->setEnabled(true);
     } else {
         m_ui.usernameLineEdit->setEnabled(false);
         m_ui.ipLineEdit->setEnabled(false);
-        m_ui.tmpDirUrl->setEnabled(false);
     }
 }


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic