commit 293017f7d3d84bb49cbda65cc85ebe9eb84023ae
Author: Eric Seigne <eric.seigne@ryxeo.com>
Date:   Sat Jun 9 00:45:27 2012 +0200

    debut d'assistant -> a finir

diff --git a/assistant.cpp b/assistant.cpp
new file mode 100644
index 0000000..5033742
--- /dev/null
+++ b/assistant.cpp
@@ -0,0 +1,72 @@
+/**
+  * Classe 
+  * @see https://redmine.ryxeo.com/projects/
+  * @author 2012 Eric Seigne <eric.seigne@ryxeo.com>
+  * @see The GNU Public License (GNU/GPL) v3
+  *
+  *
+  *
+  * 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 3 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 <http://www.gnu.org/licenses/>.
+  */
+
+
+#include "assistant.h"
+#include "ui_assistant.h"
+
+Assistant::Assistant(QWidget *parent) :
+    QWizard(parent),
+    ui(new Ui::Assistant)
+{
+    ui->setupUi(this);
+    m_tools = new tools(QDir("."),this);
+}
+
+Assistant::~Assistant()
+{
+    delete ui;
+}
+
+void Assistant::on_btnUploadPHP_clicked()
+{
+    qDebug() << "Assistant::on_btnUploadPHP_clicked";
+
+    m_ftp = m_tools->ftpConnect(ui->leFTPServeur->text(),
+                                ui->leFTPLogin->text(),
+                                ui->leFTPPass->text());
+
+    m_ftp->mkdir(ui->leFTPDirectory->text());
+    m_ftp->mkdir(ui->leFTPDirectory->text() + "/galleries");
+
+    //On uploade le code php
+    m_ftp->cd(ui->leFTPDirectory->text());
+    QDir dir("www");
+    m_tools->clear();
+    m_tools->parcoursRecursif(dir.absolutePath(),"");
+    //qDebug() << m_fileListToUpload;
+    m_tools->uploadRecursifPHP(ui->leFTPDirectory->text());
+    connect(m_tools, SIGNAL(signalUpload(int,int)), this, SLOT(updateProgressFichier(int,int)));
+    connect(m_tools, SIGNAL(signalUploadData(int,int)), this, SLOT(updateProgressData(int,int)));
+}
+
+void Assistant::updateProgressFichier(int total, int current)
+{
+    ui->pbFTPFichier->setMaximum(total);
+    ui->pbFTPFichier->setValue(current);
+}
+
+void Assistant::updateProgressData(int total, int current)
+{
+    ui->pbFTPProgress->setMaximum(total);
+    ui->pbFTPProgress->setValue(current);
+}
diff --git a/assistant.h b/assistant.h
new file mode 100644
index 0000000..e6403bb
--- /dev/null
+++ b/assistant.h
@@ -0,0 +1,63 @@
+/**
+  * Classe 
+  * @see https://redmine.ryxeo.com/projects/
+  * @author 2012 Eric Seigne <eric.seigne@ryxeo.com>
+  * @see The GNU Public License (GNU/GPL) v3
+  *
+  *
+  *
+  * 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 3 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 <http://www.gnu.org/licenses/>.
+  */
+
+
+#ifndef ASSISTANT_H
+#define ASSISTANT_H
+
+#include <QWizard>
+#include <QFtp>
+#include <QDebug>
+#include <QDir>
+#include "tools.h"
+
+namespace Ui {
+class Assistant;
+}
+
+class Assistant : public QWizard
+{
+    Q_OBJECT
+    
+public:
+    explicit Assistant(QWidget *parent = 0);
+    ~Assistant();
+    
+private slots:
+    void on_btnUploadPHP_clicked();
+    void updateProgressFichier(int total, int current);
+    void updateProgressData(int total, int current);
+
+private:
+    Ui::Assistant *ui;
+    tools *m_tools;
+    QFtp  *m_ftp;
+    QString m_currentProjectDir;
+    QString m_typeUploadRecursif;
+    QStringList m_fileListToUploadIndex;
+    QMap<QString,QString> m_fileListToUpload;
+    int m_currentProjectPictureNumber;
+    int m_currentFTPFileUpload;
+
+};
+
+#endif // ASSISTANT_H
diff --git a/assistant.ui b/assistant.ui
new file mode 100644
index 0000000..0547131
--- /dev/null
+++ b/assistant.ui
@@ -0,0 +1,149 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>Assistant</class>
+ <widget class="QWizard" name="Assistant">
+  <property name="geometry">
+   <rect>
+    <x>0</x>
+    <y>0</y>
+    <width>450</width>
+    <height>310</height>
+   </rect>
+  </property>
+  <property name="windowTitle">
+   <string>Wizard</string>
+  </property>
+  <widget class="QWizardPage" name="wizardPage1">
+   <layout class="QGridLayout" name="gridLayout">
+    <item row="0" column="0">
+     <widget class="QLabel" name="lblBonjour">
+      <property name="text">
+       <string>Bonjour et bienvenue dans cet assistant qui va vous permettre d'initialiser votre album photo en ligne.
+
+Pour l'instant l'hébergement sur les serveurs suivants a été testé et validé, si vous utilisez un autre hébergeur merci de nous indiquer si ça marche :)
+ - Free.fr (pages perso)
+ - Herbergratuit.com
+ - Serveur FTP générique
+
+Cliquez sur le bouton Suivant pour passer à l'étape suivante.
+
+Si vous voulez relancer cet assistant vous pourrez le faire depuis le menu Options du logiciel.</string>
+      </property>
+      <property name="scaledContents">
+       <bool>true</bool>
+      </property>
+      <property name="wordWrap">
+       <bool>true</bool>
+      </property>
+     </widget>
+    </item>
+   </layout>
+  </widget>
+  <widget class="QWizardPage" name="wizardPage2">
+   <layout class="QFormLayout" name="formLayout">
+    <property name="fieldGrowthPolicy">
+     <enum>QFormLayout::AllNonFixedFieldsGrow</enum>
+    </property>
+    <item row="0" column="0">
+     <widget class="QLabel" name="lblFTPLogin">
+      <property name="text">
+       <string>Identifiant :</string>
+      </property>
+     </widget>
+    </item>
+    <item row="0" column="1">
+     <widget class="QLineEdit" name="leFTPLogin">
+      <property name="text">
+       <string>webopenphoto</string>
+      </property>
+     </widget>
+    </item>
+    <item row="1" column="0">
+     <widget class="QLabel" name="lblFTPPass">
+      <property name="text">
+       <string>Mot de passe :</string>
+      </property>
+     </widget>
+    </item>
+    <item row="1" column="1">
+     <widget class="QLineEdit" name="leFTPPass">
+      <property name="text">
+       <string>MowlUcDyach6</string>
+      </property>
+      <property name="echoMode">
+       <enum>QLineEdit::PasswordEchoOnEdit</enum>
+      </property>
+     </widget>
+    </item>
+    <item row="2" column="0">
+     <widget class="QLabel" name="lblFTPServeur">
+      <property name="text">
+       <string>Serveur FTP :</string>
+      </property>
+     </widget>
+    </item>
+    <item row="2" column="1">
+     <widget class="QLineEdit" name="leFTPServeur">
+      <property name="text">
+       <string>ftpperso.free.fr</string>
+      </property>
+     </widget>
+    </item>
+    <item row="3" column="0">
+     <widget class="QLabel" name="lblFTPDirectory">
+      <property name="text">
+       <string>Répertoire d'installation :</string>
+      </property>
+     </widget>
+    </item>
+    <item row="3" column="1">
+     <widget class="QLineEdit" name="leFTPDirectory">
+      <property name="text">
+       <string>/album</string>
+      </property>
+     </widget>
+    </item>
+    <item row="5" column="1">
+     <widget class="QProgressBar" name="pbFTPFichier">
+      <property name="value">
+       <number>0</number>
+      </property>
+      <property name="format">
+       <string>%v / %m</string>
+      </property>
+     </widget>
+    </item>
+    <item row="5" column="0">
+     <widget class="QLabel" name="lblFTPProgress">
+      <property name="text">
+       <string>Fichier :</string>
+      </property>
+     </widget>
+    </item>
+    <item row="7" column="0" colspan="2">
+     <widget class="QPushButton" name="btnUploadPHP">
+      <property name="text">
+       <string>&amp;Initialiser l'album photo</string>
+      </property>
+     </widget>
+    </item>
+    <item row="6" column="0">
+     <widget class="QLabel" name="label">
+      <property name="text">
+       <string>Progression :</string>
+      </property>
+     </widget>
+    </item>
+    <item row="6" column="1">
+     <widget class="QProgressBar" name="pbFTPProgress">
+      <property name="value">
+       <number>0</number>
+      </property>
+     </widget>
+    </item>
+   </layout>
+  </widget>
+ </widget>
+ <resources/>
+ <connections/>
+</ui>
diff --git a/original.cpp b/original.cpp
index 4fe3fc1..f137568 100644
--- a/original.cpp
+++ b/original.cpp
@@ -67,6 +67,7 @@ original::original(QWidget *parent) :
         item->setText(0, list.at(i).fileName());
         item->setData(1,0,list.at(i).absoluteFilePath());
     }
+    m_tools = new tools(m_baseDir, this);
 
     //============== l'étiquette invitant a déposer des images
     m_labelDeposez = new QLabel(trUtf8("Glissez-déposez ici les photos que vous voulez ajouter à cet album ..."),ui->lwPictures);
@@ -402,178 +403,26 @@ void original::refreshPictureList()
     }
 }
 
-void original::ftpConnect()
-{
-    m_currentFTPFileUpload = -1;
-
-    m_ftp = new QFtp(this);
-    connect(m_ftp, SIGNAL(commandFinished(int,bool)),
-            this, SLOT(ftpCommandFinished(int,bool)));
-    connect(m_ftp, SIGNAL(listInfo(QUrlInfo)),
-            this, SLOT(addToList(QUrlInfo)));
-    connect(m_ftp, SIGNAL(dataTransferProgress(qint64,qint64)),
-            this, SLOT(updateDataTransferProgress(qint64,qint64)));
-
-    qDebug() << "aaaaaaaaaaaaaa";
-    m_ftp->connectToHost(ui->leFTPServeur->text(), 21);
-    m_ftp->setTransferMode(QFtp::Passive);
-
-    qDebug() << "bbbbbbbbbbbbb";
-
-    m_ftp->login(ui->leFTPLogin->text(), ui->leFTPPass->text());
-
-    qDebug() << "Listing FTP: ";
-    //ftp->cd(url.path());
-    m_ftp->mkdir(ui->leFTPDirectory->text());
-    m_ftp->mkdir(ui->leFTPDirectory->text() + "/galleries");
-
-    //On uploade l'album en cours
-    //m_ftp->put()
-}
-
-void original::ftpCommandFinished(int commandId, bool error)
-{
-    qDebug() << "ftpCommandFinished : " << commandId << "(" << QFtp::Put << ") : " << m_ftp->currentCommand();
-#ifndef QT_NO_CURSOR
-    setCursor(Qt::ArrowCursor);
-#endif
-
-    if (m_ftp->currentCommand() == QFtp::ConnectToHost) {
-        qDebug() << "Logged onto " << ui->leFTPServeur->text() << " error : " << error;
-    }
-
-    if (m_ftp->currentCommand() == QFtp::Login) {
-        qDebug() << "Login ...";
-        m_ftp->list();
-    }
-
-    if (m_ftp->currentCommand() == QFtp::Put) {
-        qDebug() << "Put ...";
-    }
-
-    if (m_ftp->currentCommand() == QFtp::Get) {
-        qDebug() << "Get ...";
-        if (error) {
-        } else {
-        }
-    } else if (m_ftp->currentCommand() == QFtp::List) {
-        qDebug() << "List ...";
-    }
-
-    //on passe au suivant
-    if(m_currentFTPFileUpload >= 0 && m_fileListToUploadIndex.count() > 0) {
-        qDebug() << "Il en reste encore a envoyer ";
-        if(m_typeUploadRecursif == "PHP")
-            uploadRecursifPHP();
-        else
-            uploadRecursifGallery();
-    }
-    else {
-        qDebug() << "Tout a ete expedie ";
-    }
-}
-
-void original::addToList(const QUrlInfo &urlInfo)
-{
-    qDebug() << urlInfo.name();
-}
-
-void original::updateDataTransferProgress(qint64 readBytes, qint64 totalBytes)
-{
-    qDebug() << "Transfert: " << readBytes << " sur " << totalBytes;
-}
-
-void original::on_btnPHP_clicked()
-{
-    ftpConnect();
-    qDebug() << "on_btnPHP_clicked";
-    //On uploade le code php
-    m_ftp->cd(ui->leFTPDirectory->text());
-    QDir dir(m_baseDir.absolutePath() + "/www");
-    m_fileListToUpload.clear();
-    m_fileListToUploadIndex.clear();
-    m_currentFTPFileUpload = 0;
-    parcoursRecursif(dir.absolutePath(),"");
-    //qDebug() << m_fileListToUpload;
-    m_typeUploadRecursif = "PHP";
-    uploadRecursifPHP();
-}
-
-void original::uploadRecursifPHP()
-{
-    qDebug() << "uploadRecursif : " << m_fileListToUploadIndex.count() ;
-    if(m_fileListToUploadIndex.count()>0) {
-        QFileInfo fi(m_fileListToUploadIndex.takeFirst());
-        if(fi.isDir()) {
-            QString ladest = ui->leFTPDirectory->text() + "/" + fi.absoluteFilePath().remove(m_baseDir.absolutePath()).remove("/www");
-            qDebug() << "mkdir : " << ladest;
-            m_ftp->mkdir(ladest);
-        }
-        else {
-            QFile *fic = new QFile(fi.absoluteFilePath());
-            fic->open(QIODevice::ReadOnly);
-            QString ladest = ui->leFTPDirectory->text() + "/" + m_fileListToUpload.value(fi.absoluteFilePath()) + "/" + fi.fileName();
-            qDebug() << "Upload : " << fi.fileName() << " -> " << ladest;
-            m_ftp->put(fic,ladest);
-            fic->close();
-        }
-        m_currentFTPFileUpload++;
-    }
-}
-
-void original::uploadRecursifGallery()
-{
-    qDebug() << "uploadRecursifGallery : ";
-    if(m_currentFTPFileUpload < m_fileListToUploadIndex.count()) {
-        QFileInfo fi(m_fileListToUploadIndex.at(m_currentFTPFileUpload));
-        if(fi.isDir()) {
-            QString ladest = ui->leFTPDirectory->text() + "/galleries/" + fi.absoluteFilePath().remove(m_baseDir.absolutePath()).remove("/www");
-            qDebug() << "mkdir : " << ladest;
-            m_ftp->mkdir(ladest);
-        }
-        else {
-            QFile *fic = new QFile(fi.absoluteFilePath());
-            fic->open(QIODevice::ReadOnly);
-            QString ladest = ui->leFTPDirectory->text() + "/galleries/" + m_fileListToUpload.value(fi.absoluteFilePath()) + "/" + fi.fileName();
-            qDebug() << "Upload : " << fi.fileName() << " -> " << ladest;
-            m_ftp->put(fic,ladest);
-            fic->close();
-        }
-        m_currentFTPFileUpload++;
-    }
-}
-
-void original::parcoursRecursif(QString rep, QString repertoireServeur)
-{
-    qDebug() << "parcoursRecursif : " << rep;
-    QDir dir(rep);
-    dir.setFilter(QDir::Hidden | QDir::Files | QDir::Dirs | QDir::NoSymLinks | QDir::NoDotAndDotDot);
-    QFileInfoList list = dir.entryInfoList();
-    for(int i = 0; i < list.count(); i++) {
-        qDebug() << "Ajout de ... " << list.at(i).absoluteFilePath();
-        m_fileListToUpload.insert(list.at(i).absoluteFilePath(), repertoireServeur);
-        m_fileListToUploadIndex << list.at(i).absoluteFilePath();
-        if(list.at(i).isDir()) {
-            parcoursRecursif(list.at(i).absoluteFilePath(), list.at(i).absoluteFilePath().remove(m_baseDir.absolutePath()).remove("/www"));
-        }
-    }
-}
-
 void original::on_btnUpload_clicked()
 {
-    ftpConnect();
+    m_ftp = m_tools->ftpConnect(ui->leFTPServeur->text(),
+                                ui->leFTPLogin->text(),
+                                ui->leFTPPass->text());
     qDebug() << "on_btnUpload_clicked : " << ui->treeWidget->currentItem()->data(1,0).toString();
     QFileInfo fi(ui->treeWidget->currentItem()->data(1,0).toString());
     QDir dir(fi.absoluteFilePath());
-    m_fileListToUpload.clear();
-    m_fileListToUploadIndex.clear();
-    m_currentFTPFileUpload = 0;
-    parcoursRecursif(dir.absolutePath(),ui->treeWidget->currentItem()->text(0));
+    m_tools->clear();
+    m_tools->parcoursRecursif(dir.absolutePath(),ui->treeWidget->currentItem()->text(0));
 //    qDebug() << m_fileListToUpload;
-    m_typeUploadRecursif = "Gallery";
 
     QString ladest = ui->leFTPDirectory->text() + "/galleries/" + ui->treeWidget->currentItem()->text(0);
     qDebug() << "mkdir : " << ladest;
     m_ftp->mkdir(ladest);
 //    uploadRecursifGallery();
 }
+
+void original::on_action_Assistant_d_installation_triggered()
+{
+    Assistant *a = new Assistant(this);
+    a->show();
+}
diff --git a/original.h b/original.h
index 68d5a25..29bd244 100644
--- a/original.h
+++ b/original.h
@@ -36,8 +36,9 @@
 #include <QDragEnterEvent>
 #include <QUrl>
 #include <QLabel>
-#include <QFtp>
 #include <QMessageBox>
+#include "tools.h"
+#include "assistant.h"
 
 namespace Ui {
 class original;
@@ -61,25 +62,14 @@ private slots:
     void dropEvent(QDropEvent *event);
     void addPictureToProject(QString fic);
     void refreshPictureList();
-    void ftpConnect();
-
 //    void connectOrDisconnect();
 //    void uploadFile();
 //    void cancelUpload();
-
-    void ftpCommandFinished(int commandId, bool error);
-    void addToList(const QUrlInfo &urlInfo);
 //    void processItem(QTreeWidgetItem *item, int column);
-    void updateDataTransferProgress(qint64 readBytes,
-                                    qint64 totalBytes);
-
-    void on_btnPHP_clicked();
-    void uploadRecursifPHP();
-    void uploadRecursifGallery();
-    void parcoursRecursif(QString rep, QString repertoireServeur);
-
     void on_btnUpload_clicked();
 
+    void on_action_Assistant_d_installation_triggered();
+
 private:
     Ui::original *ui;
     QDir m_baseDir;
@@ -92,6 +82,7 @@ private:
     int m_currentProjectPictureNumber;
     int m_currentFTPFileUpload;
     QFtp *m_ftp;
+    tools *m_tools;
 
 };
 
diff --git a/original.ui b/original.ui
index ee2fde6..f9a1819 100644
--- a/original.ui
+++ b/original.ui
@@ -262,24 +262,17 @@
          <item row="3" column="1">
           <widget class="QLineEdit" name="leFTPDirectory">
            <property name="text">
-            <string>/gallery</string>
+            <string>/album</string>
            </property>
           </widget>
          </item>
-         <item row="4" column="4">
+         <item row="4" column="1">
           <widget class="QPushButton" name="btnUpload">
            <property name="text">
             <string>Upload gallerie en cours</string>
            </property>
           </widget>
          </item>
-         <item row="4" column="1">
-          <widget class="QPushButton" name="btnPHP">
-           <property name="text">
-            <string>Envoyer le code PHP</string>
-           </property>
-          </widget>
-         </item>
         </layout>
        </widget>
       </widget>
@@ -309,6 +302,7 @@
      <string>&amp;Édition</string>
     </property>
     <addaction name="action_Pr_f_rences"/>
+    <addaction name="action_Assistant_d_installation"/>
    </widget>
    <addaction name="menu_Fichier"/>
    <addaction name="menu_dition"/>
@@ -342,6 +336,11 @@
     <string>&amp;Préférences</string>
    </property>
   </action>
+  <action name="action_Assistant_d_installation">
+   <property name="text">
+    <string>&amp;Assistant d'installation</string>
+   </property>
+  </action>
  </widget>
  <layoutdefault spacing="6" margin="11"/>
  <tabstops>
diff --git a/ryxeo-webphotoalbum.pro b/ryxeo-webphotoalbum.pro
index e0fbfd7..5ec512e 100644
--- a/ryxeo-webphotoalbum.pro
+++ b/ryxeo-webphotoalbum.pro
@@ -11,10 +11,15 @@ TEMPLATE = app
 
 SOURCES += main.cpp\
         original.cpp \
+    assistant.cpp \
+    tools.cpp
 
-HEADERS  += original.h
+HEADERS  += original.h \
+    assistant.h \
+    tools.h
 
-FORMS    += original.ui
+FORMS    += original.ui \
+    assistant.ui
 
 unix:LIBS += -lexiv2
 win32:LIBS += -lexiv2
diff --git a/tools.cpp b/tools.cpp
new file mode 100644
index 0000000..304e6b4
--- /dev/null
+++ b/tools.cpp
@@ -0,0 +1,200 @@
+/**
+  * Classe 
+  * @see https://redmine.ryxeo.com/projects/
+  * @author 2012 Eric Seigne <eric.seigne@ryxeo.com>
+  * @see The GNU Public License (GNU/GPL) v3
+  *
+  *
+  *
+  * 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 3 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 <http://www.gnu.org/licenses/>.
+  */
+
+
+#include "tools.h"
+
+tools::tools(QDir basedir, QObject *parent) :
+    QObject(parent)
+{
+    m_baseDir = basedir;
+}
+
+QFtp *tools::ftpConnect(QString serveur, QString login, QString passwd)
+{
+    m_currentFTPFileUpload = -1;
+
+    m_ftp = new QFtp(this);
+    connect(m_ftp, SIGNAL(commandFinished(int,bool)),
+            this, SLOT(ftpCommandFinished(int,bool)));
+    connect(m_ftp, SIGNAL(listInfo(QUrlInfo)),
+            this, SLOT(addToList(QUrlInfo)));
+    connect(m_ftp, SIGNAL(dataTransferProgress(qint64,qint64)),
+            this, SLOT(updateDataTransferProgress(qint64,qint64)));
+
+    qDebug() << "aaaaaaaaaaaaaa";
+    m_ftp->connectToHost(serveur, 21);
+    m_ftp->setTransferMode(QFtp::Passive);
+
+    qDebug() << "bbbbbbbbbbbbb";
+
+    m_ftp->login(login, passwd);
+
+    qDebug() << "Listing FTP: ";
+    //ftp->cd(url.path());
+    //On uploade l'album en cours
+    //m_ftp->put()
+
+    return m_ftp;
+}
+
+void tools::ftpCommandFinished(int commandId, bool error)
+{
+    qDebug() << "ftpCommandFinished";
+    if(error)
+        qDebug() << "ftpCommandFinished ERROR : " << commandId << "(" << QFtp::Put << ") : " << m_ftp->currentCommand();
+    //setCursor(Qt::ArrowCursor);
+
+    if (m_ftp->currentCommand() == QFtp::ConnectToHost) {
+        qDebug() << "Logged onto server error : " << error;
+    }
+
+    if (m_ftp->currentCommand() == QFtp::Login) {
+        qDebug() << "Login ...";
+        m_ftp->list();
+    }
+
+    if (m_ftp->currentCommand() == QFtp::Put) {
+        qDebug() << "Put ...";
+    }
+
+    if (m_ftp->currentCommand() == QFtp::Get) {
+        qDebug() << "Get ...";
+        if (error) {
+        } else {
+        }
+    } else if (m_ftp->currentCommand() == QFtp::List) {
+        qDebug() << "List ...";
+    }
+
+    //on passe au suivant
+    if(m_currentFTPFileUpload >= 0 && m_fileListToUploadIndex.count() > 0) {
+        qDebug() << "Il en reste encore a envoyer ";
+        if(m_typeUploadRecursif == "PHP")
+            uploadRecursifPHP(m_destDirBase);
+        else
+            uploadRecursifGallery(m_destDirBase);
+    }
+    else {
+        qDebug() << "Tout a ete expedie ";
+    }
+}
+
+void tools::updateDataTransferProgress(qint64 readBytes, qint64 totalBytes)
+{
+//    qDebug() << "Transfert: " << readBytes << " sur " << totalBytes;
+    emit signalUploadData(totalBytes, readBytes);
+}
+
+void tools::clear()
+{
+    m_fileListToUpload.clear();
+    m_fileListToUploadIndex.clear();
+    m_currentFTPFileUpload = 0;
+}
+
+int tools::nbTotalUpload()
+{
+    return m_fileListToUpload.count();
+}
+
+int tools::nbResteUpload()
+{
+    return m_fileListToUploadIndex.count();
+}
+
+void tools::parcoursRecursif(QString rep, QString repertoireServeur)
+{
+    qDebug() << "parcoursRecursif : " << rep;
+
+    QDir dir(rep);
+    dir.setFilter(QDir::Hidden | QDir::Files | QDir::Dirs | QDir::NoSymLinks | QDir::NoDotAndDotDot);
+    QFileInfoList list = dir.entryInfoList();
+    for(int i = 0; i < list.count(); i++) {
+        qDebug() << "Ajout de " << list.at(i).absoluteFilePath() << " rep serveur : " << repertoireServeur;
+        m_fileListToUpload.insert(list.at(i).absoluteFilePath(), repertoireServeur);
+        m_fileListToUploadIndex << list.at(i).absoluteFilePath();
+        if(list.at(i).isDir()) {
+            parcoursRecursif(list.at(i).absoluteFilePath(), list.at(i).absoluteFilePath().remove(m_baseDir.absolutePath()).remove("/www"));
+        }
+    }
+}
+
+
+void tools::uploadRecursifGallery(QString destDirBase)
+{
+    qDebug() << "uploadRecursifGallery : ";
+    m_typeUploadRecursif = "Gallery";
+    m_destDirBase = destDirBase;
+    if(m_currentFTPFileUpload < m_fileListToUploadIndex.count()) {
+        QFileInfo fi(m_fileListToUploadIndex.at(m_currentFTPFileUpload));
+        if(fi.isDir()) {
+            QString ladest = destDirBase + "/galleries/" + fi.absoluteFilePath().remove(m_baseDir.absolutePath()).remove("/www");
+            qDebug() << "mkdir : " << ladest;
+            m_ftp->mkdir(ladest);
+        }
+        else {
+            QFile *fic = new QFile(fi.absoluteFilePath());
+            fic->open(QIODevice::ReadOnly);
+            QString ladest = destDirBase + "/galleries/" + m_fileListToUpload.value(fi.absoluteFilePath()) + "/" + fi.fileName();
+            qDebug() << "Upload : " << fi.absoluteFilePath() << " -> " << ladest;
+            m_ftp->put(fic,ladest);
+            fic->close();
+        }
+        m_currentFTPFileUpload++;
+    }
+}
+
+
+void tools::uploadRecursifPHP(QString destDirBase)
+{
+    qDebug() << "uploadRecursif : " << m_fileListToUploadIndex.count() ;
+    emit signalUpload(nbTotalUpload(), nbTotalUpload()-nbResteUpload()+1);
+    m_destDirBase = destDirBase;
+    m_typeUploadRecursif = "PHP";
+
+    if(m_fileListToUploadIndex.count()>0) {
+        QString s(m_fileListToUploadIndex.takeFirst());
+        qDebug() << " -> " << s;
+        QFileInfo fi(s);
+        if(fi.isDir()) {
+            QString ladest = m_destDirBase + fi.absoluteFilePath().remove(m_baseDir.absolutePath()).remove("/www");
+            qDebug() << "mkdir : " << ladest;
+            m_ftp->mkdir(ladest);
+        }
+        else {
+            QFile *fic = new QFile(fi.absoluteFilePath());
+            fic->open(QIODevice::ReadOnly);
+            QString ladest = m_destDirBase + m_fileListToUpload.value(fi.absoluteFilePath()) + "/" + fi.fileName();
+            qDebug() << "Upload : " << fi.fileName() << " -> " << ladest;
+            m_ftp->put(fic,ladest);
+            fic->close();
+        }
+        m_currentFTPFileUpload++;
+    }
+}
+
+void tools::addToList(const QUrlInfo &urlInfo)
+{
+    qDebug() << urlInfo.name();
+}
+
diff --git a/tools.h b/tools.h
new file mode 100644
index 0000000..4771128
--- /dev/null
+++ b/tools.h
@@ -0,0 +1,71 @@
+/**
+  * Classe 
+  * @see https://redmine.ryxeo.com/projects/
+  * @author 2012 Eric Seigne <eric.seigne@ryxeo.com>
+  * @see The GNU Public License (GNU/GPL) v3
+  *
+  *
+  *
+  * 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 3 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 <http://www.gnu.org/licenses/>.
+  */
+
+
+#ifndef TOOLS_H
+#define TOOLS_H
+
+#include <QFtp>
+#include <QObject>
+#include <QStringList>
+#include <QMap>
+#include <QDebug>
+#include <QApplication>
+#include <QDir>
+
+class tools : public QObject
+{
+    Q_OBJECT
+public:
+    explicit tools(QDir basedir, QObject *parent = 0);
+
+signals:
+    void signalUpload(int,int);
+    void signalUploadData(int,int);
+
+public slots:
+    QFtp *ftpConnect(QString serveur, QString login, QString passwd);
+    void parcoursRecursif(QString rep, QString repertoireServeur);
+    void ftpCommandFinished(int commandId, bool error);
+    void uploadRecursifPHP(QString destDirBase);
+    void uploadRecursifGallery(QString destDirBase);
+    void updateDataTransferProgress(qint64 readBytes,
+                                    qint64 totalBytes);
+    void addToList(const QUrlInfo &urlInfo);
+    void clear();
+    int nbTotalUpload();
+    int nbResteUpload();
+
+private:
+    QFtp *m_ftp;
+    QDir m_baseDir;
+    QString m_destDirBase;
+    QString m_currentProjectDir;
+    QString m_typeUploadRecursif;
+    QStringList m_fileListToUploadIndex;
+    QMap<QString,QString> m_fileListToUpload;
+    int m_currentProjectPictureNumber;
+    int m_currentFTPFileUpload;
+
+};
+
+#endif // TOOLS_H
