Projet

Général

Profil

Révision d4a9c7c8

Voir les différences:

assistant.cpp
1 1
/**
2
  * Classe 
2
  * Classe
3 3
  * @see https://redmine.ryxeo.com/projects/
4 4
  * @author 2012 Eric Seigne <eric.seigne@ryxeo.com>
5 5
  * @see The GNU Public License (GNU/GPL) v3
......
41 41
{
42 42
    qDebug() << "Assistant::on_btnUploadPHP_clicked";
43 43

  
44
    m_ftp = m_tools->ftpConnect(ui->leFTPServeur->text(),
45
                                ui->leFTPLogin->text(),
46
                                ui->leFTPPass->text());
44
    m_tools->ftpConnect(ui->leFTPServeur->text(),
45
                        ui->leFTPLogin->text(),
46
                        ui->leFTPPass->text());
47 47

  
48
    m_ftp->mkdir(ui->leFTPDirectory->text());
49
    m_ftp->mkdir(ui->leFTPDirectory->text() + "/galleries");
48
    m_tools->ftpMkdir(ui->leFTPDirectory->text());
49
    m_tools->ftpMkdir(ui->leFTPDirectory->text() + "/galleries");
50 50

  
51 51
    //On uploade le code php
52
    m_ftp->cd(ui->leFTPDirectory->text());
52
    //m_ftp->cd(ui->leFTPDirectory->text());
53 53
    QDir dir("www");
54 54
    m_tools->clear();
55 55
    m_tools->parcoursRecursif(dir.absolutePath(),"");
assistant.h
50 50
private:
51 51
    Ui::Assistant *ui;
52 52
    tools *m_tools;
53
    QFtp  *m_ftp;
54 53
    QString m_currentProjectDir;
55 54
    QString m_typeUploadRecursif;
56 55
    QStringList m_fileListToUploadIndex;
newalbumdialog.cpp
1
/**
2
  * Classe 
3
  * @see https://redmine.ryxeo.com/projects/
4
  * @author 2012 Eric Seigne <eric.seigne@ryxeo.com>
5
  * @see The GNU Public License (GNU/GPL) v3
6
  *
7
  *
8
  *
9
  * This program is free software; you can redistribute it and/or modify
10
  * it under the terms of the GNU General Public License as published by
11
  * the Free Software Foundation; either version 3 of the License, or
12
  * (at your option) any later version.
13
  *
14
  * This program is distributed in the hope that it will be useful, but
15
  * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
16
  * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
17
  * for more details.
18
  *
19
  * You should have received a copy of the GNU General Public License along
20
  * with this program. If not, see <http://www.gnu.org/licenses/>.
21
  */
22

  
23

  
24
#include "newalbumdialog.h"
25
#include "ui_newalbumdialog.h"
26

  
27
NewAlbumDialog::NewAlbumDialog(QWidget *parent) :
28
    QDialog(parent),
29
    ui(new Ui::NewAlbumDialog)
30
{
31
    ui->setupUi(this);
32
    QRegExp expressionReguliere("[a-zA-Z0-9_-]*");
33
    ui->leNom->setValidator(new QRegExpValidator(expressionReguliere, this));
34
}
35

  
36
NewAlbumDialog::~NewAlbumDialog()
37
{
38
    delete ui;
39
}
40

  
41
QString NewAlbumDialog::getValue(QWidget *parent)
42
{
43
    NewAlbumDialog dialog(parent);
44
    int ret = dialog.exec();
45
    return dialog.textValue();
46
}
47

  
48
QString NewAlbumDialog::textValue()
49
{
50
    return ui->leNom->text();
51
}
newalbumdialog.h
1
/**
2
  * Classe 
3
  * @see https://redmine.ryxeo.com/projects/
4
  * @author 2012 Eric Seigne <eric.seigne@ryxeo.com>
5
  * @see The GNU Public License (GNU/GPL) v3
6
  *
7
  *
8
  *
9
  * This program is free software; you can redistribute it and/or modify
10
  * it under the terms of the GNU General Public License as published by
11
  * the Free Software Foundation; either version 3 of the License, or
12
  * (at your option) any later version.
13
  *
14
  * This program is distributed in the hope that it will be useful, but
15
  * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
16
  * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
17
  * for more details.
18
  *
19
  * You should have received a copy of the GNU General Public License along
20
  * with this program. If not, see <http://www.gnu.org/licenses/>.
21
  */
22

  
23

  
24
#ifndef NEWALBUMDIALOG_H
25
#define NEWALBUMDIALOG_H
26

  
27
#include <QDialog>
28

  
29
namespace Ui {
30
class NewAlbumDialog;
31
}
32

  
33
class NewAlbumDialog : public QDialog
34
{
35
    Q_OBJECT
36
    
37
public:
38
    explicit NewAlbumDialog(QWidget *parent = 0);
39
    ~NewAlbumDialog();
40
    static QString getValue(QWidget *parent);
41
    QString textValue();
42
    
43
private slots:
44

  
45
private:
46
    Ui::NewAlbumDialog *ui;
47
};
48

  
49
#endif // NEWALBUMDIALOG_H
newalbumdialog.ui
1
<?xml version="1.0" encoding="UTF-8"?>
2
<ui version="4.0">
3
 <class>NewAlbumDialog</class>
4
 <widget class="QDialog" name="NewAlbumDialog">
5
  <property name="geometry">
6
   <rect>
7
    <x>0</x>
8
    <y>0</y>
9
    <width>400</width>
10
    <height>83</height>
11
   </rect>
12
  </property>
13
  <property name="windowTitle">
14
   <string>Dialog</string>
15
  </property>
16
  <layout class="QGridLayout" name="gridLayout">
17
   <item row="0" column="0">
18
    <widget class="QLabel" name="lblNom">
19
     <property name="text">
20
      <string>Nom de l'album</string>
21
     </property>
22
    </widget>
23
   </item>
24
   <item row="0" column="1">
25
    <widget class="QLineEdit" name="leNom">
26
     <property name="maxLength">
27
      <number>50</number>
28
     </property>
29
    </widget>
30
   </item>
31
   <item row="1" column="0" colspan="2">
32
    <widget class="QDialogButtonBox" name="buttonBox">
33
     <property name="orientation">
34
      <enum>Qt::Horizontal</enum>
35
     </property>
36
     <property name="standardButtons">
37
      <set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
38
     </property>
39
    </widget>
40
   </item>
41
  </layout>
42
 </widget>
43
 <resources/>
44
 <connections>
45
  <connection>
46
   <sender>buttonBox</sender>
47
   <signal>accepted()</signal>
48
   <receiver>NewAlbumDialog</receiver>
49
   <slot>accept()</slot>
50
   <hints>
51
    <hint type="sourcelabel">
52
     <x>248</x>
53
     <y>254</y>
54
    </hint>
55
    <hint type="destinationlabel">
56
     <x>157</x>
57
     <y>274</y>
58
    </hint>
59
   </hints>
60
  </connection>
61
  <connection>
62
   <sender>buttonBox</sender>
63
   <signal>rejected()</signal>
64
   <receiver>NewAlbumDialog</receiver>
65
   <slot>reject()</slot>
66
   <hints>
67
    <hint type="sourcelabel">
68
     <x>316</x>
69
     <y>260</y>
70
    </hint>
71
    <hint type="destinationlabel">
72
     <x>286</x>
73
     <y>274</y>
74
    </hint>
75
   </hints>
76
  </connection>
77
 </connections>
78
</ui>
original.cpp
67 67
        item->setText(0, list.at(i).fileName());
68 68
        item->setData(1,0,list.at(i).absoluteFilePath());
69 69
    }
70

  
71
    ui->dateEdit->setDate(QDate::currentDate());
70 72
    m_tools = new tools(m_baseDir, this);
71 73

  
72 74
    //============== l'étiquette invitant a déposer des images
......
110 112
{
111 113
    m_currentProjectPictureNumber = 0;
112 114
    bool ok;
113
    QString text = QInputDialog::getText(this, trUtf8("Nom du nouvel album à créer"),
114
                                         trUtf8("Nom du nouvel album à créer"), QLineEdit::Normal,
115
                                         QDir::home().dirName(), &ok);
115
    QString text = NewAlbumDialog::getValue(this);
116 116
    //Si ce nom n'existe pas déjà ...
117 117
    QTreeWidgetItem *i = new QTreeWidgetItem(ui->treeWidget);
118 118
    i->setText(0, text);
......
166 166
                ui->leAuthor->setText(tab.at(1));
167 167
            if(tab.at(0) == "description")
168 168
                ui->leDesc->setText(tab.at(1));
169
            if(tab.at(0) == "date")
170
                ui->dateEdit->setDate(QDate::fromString(tab.at(1)));
169
            if(tab.at(0) == "date") {
170
                qDebug() << "**************** DATE : " << tab.at(1).trimmed();
171
                ui->dateEdit->setDate(QDate::fromString(tab.at(1).trimmed(),"dd.MM.yyyy"));
172
            }
171 173
            if(tab.at(0) == "restricted_user")
172 174
                ui->leLogin->setText(tab.at(1));
173 175
            if(tab.at(0) == "restricted_password")
......
176 178
        }
177 179

  
178 180
    }
179
m_currentProjectPictureNumber++;
181
    m_currentProjectPictureNumber++;
180 182
    refreshPictureList();
181 183
    qDebug() << "On continue la numerotation a " << m_currentProjectPictureNumber;
182 184
    qDebug() << "Espace de stockage du projet " << m_currentProjectDir;
......
188 190
    data.append(QString("name|%1\n").arg(ui->leTitre->text().trimmed()));
189 191
    data.append(QString("author|%1\n").arg(ui->leAuthor->text().trimmed()));
190 192
    data.append(QString("description|%1\n").arg(ui->leDesc->text().trimmed()));
191
    data.append(QString("date|%1\n").arg(ui->dateEdit->text().trimmed()));
193
    data.append(QString("date|%1\n").arg(ui->dateEdit->date().toString("dd.MM.yyyy")));
192 194
    if(ui->leLogin->text().trimmed() != "") {
193 195
        data.append(QString("restricted_user|%1\n").arg(ui->leLogin->text().trimmed()));
194 196
        data.append(QString("restricted_password|%1\n").arg(ui->lePasswd->text().trimmed()));
......
298 300
                bool setCopyright = false;
299 301
                bool setSoftware = false;
300 302
                Exiv2::ExifData::const_iterator end = exifData.end();
301
//                qDebug() << "============================ DEBUT ===============================";
303
                //                qDebug() << "============================ DEBUT ===============================";
302 304
                for (Exiv2::ExifData::const_iterator i = exifData.begin(); i != end; ++i)
303 305
                {
304
//                    qDebug() << i->key().c_str() << " = " << i->value().toString().c_str();
306
                    //                    qDebug() << i->key().c_str() << " = " << i->value().toString().c_str();
305 307
                    if (i->key() == "Exif.Image.Artist") {
306 308
                        exifData["Exif.Image.Artist"]    = "Eric S.";
307 309
                        setArtist = true;
......
339 341
                    exifData.add(k3,v3.get());
340 342
                }
341 343

  
342
//                qDebug() << "============================ APRES ===============================";
344
                //                qDebug() << "============================ APRES ===============================";
343 345
                Exiv2::ExifData::const_iterator end2 = exifData.end();
344
//                for (Exiv2::ExifData::const_iterator i2 = exifData.begin(); i2 != end2; ++i2)
345
//                {
346
//                    qDebug() << i2->key().c_str() << " = " << i2->value().toString().c_str();
347
//                }
348
//                qDebug() << "============================ FIN ===============================";
346
                //                for (Exiv2::ExifData::const_iterator i2 = exifData.begin(); i2 != end2; ++i2)
347
                //                {
348
                //                    qDebug() << i2->key().c_str() << " = " << i2->value().toString().c_str();
349
                //                }
350
                //                qDebug() << "============================ FIN ===============================";
349 351

  
350 352
                imageLQ->setExifData(exifData);
351 353
                imageLQ->writeMetadata();
......
365 367
        qDebug() << "Erreur EXIV2";
366 368
    }
367 369
    ui->statusBar->showMessage(trUtf8("Fichier en cours: %1 [hq] [mq] [lq] [meta] ... terminé").arg(fic),3000);
368
m_currentProjectPictureNumber++;
370
    m_currentProjectPictureNumber++;
369 371
    refreshPictureList();
370 372
}
371 373

  
......
401 403
    else {
402 404
        m_labelDeposez->hide();
403 405
    }
406
    m_currentProjectPictureNumber = currentProjectPictureNumber+1;
404 407
}
405 408

  
406 409
void original::on_btnUpload_clicked()
407 410
{
408
    m_ftp = m_tools->ftpConnect(ui->leFTPServeur->text(),
409
                                ui->leFTPLogin->text(),
410
                                ui->leFTPPass->text());
411 411
    qDebug() << "on_btnUpload_clicked : " << ui->treeWidget->currentItem()->data(1,0).toString();
412
    QFileInfo fi(ui->treeWidget->currentItem()->data(1,0).toString());
413
    QDir dir(fi.absoluteFilePath());
414 412
    m_tools->clear();
415
    m_tools->parcoursRecursif(dir.absolutePath(),ui->treeWidget->currentItem()->text(0));
416
//    qDebug() << m_fileListToUpload;
417 413

  
418
    QString ladest = ui->leFTPDirectory->text() + "/galleries/" + ui->treeWidget->currentItem()->text(0);
419
    qDebug() << "mkdir : " << ladest;
420
    m_ftp->mkdir(ladest);
421
//    uploadRecursifGallery();
414
    m_tools->ftpConnect(ui->leFTPServeur->text(),
415
                        ui->leFTPLogin->text(),
416
                        ui->leFTPPass->text());
417

  
418
    m_tools->ftpMkdir(ui->leFTPDirectory->text());
419
    m_tools->ftpMkdir(ui->leFTPDirectory->text() + "/galleries");
420
    m_tools->ftpMkdir(ui->leFTPDirectory->text() + "/galleries/" + ui->treeWidget->currentItem()->text(0));
421

  
422
    //On uploade la gallerie
423
    //m_ftp->cd(ui->leFTPDirectory->text());
424

  
425
    QFileInfo fi(ui->treeWidget->currentItem()->data(1,0).toString());
426
    QDir dir(fi.absoluteFilePath());
427
    m_tools->parcoursRecursif(dir.absolutePath(),"");
428
    //qDebug() << m_fileListToUpload;
429
    m_tools->uploadRecursifGallery(ui->leFTPDirectory->text());
430
    connect(m_tools, SIGNAL(signalUpload(int,int)), this, SLOT(updateProgressFichier(int,int)));
431
    connect(m_tools, SIGNAL(signalUploadData(int,int)), this, SLOT(updateProgressData(int,int)));
422 432
}
423 433

  
424 434
void original::on_action_Assistant_d_installation_triggered()
......
426 436
    Assistant *a = new Assistant(this);
427 437
    a->show();
428 438
}
439

  
440
void original::updateProgressFichier(int total, int current)
441
{
442
    ui->pbFTPFichier->setMaximum(total);
443
    ui->pbFTPFichier->setValue(current);
444
}
445

  
446
void original::updateProgressData(int total, int current)
447
{
448
    ui->pbFTPProgress->setMaximum(total);
449
    ui->pbFTPProgress->setValue(current);
450
}
original.h
39 39
#include <QMessageBox>
40 40
#include "tools.h"
41 41
#include "assistant.h"
42
#include "newalbumdialog.h"
42 43

  
43 44
namespace Ui {
44 45
class original;
......
67 68
//    void cancelUpload();
68 69
//    void processItem(QTreeWidgetItem *item, int column);
69 70
    void on_btnUpload_clicked();
70

  
71 71
    void on_action_Assistant_d_installation_triggered();
72
    void updateProgressFichier(int total, int current);
73
    void updateProgressData(int total, int current);
72 74

  
73 75
private:
74 76
    Ui::original *ui;
......
81 83
    QMap<QString,QString> m_fileListToUpload;
82 84
    int m_currentProjectPictureNumber;
83 85
    int m_currentFTPFileUpload;
84
    QFtp *m_ftp;
85 86
    tools *m_tools;
86

  
87 87
};
88 88

  
89 89
#endif // ORIGINAL_H
original.ui
76 76
       <property name="currentIndex">
77 77
        <number>0</number>
78 78
       </property>
79
       <widget class="QWidget" name="tab_2">
79
       <widget class="QWidget" name="tabProprietes">
80 80
        <attribute name="title">
81 81
         <string>1. Propriétés</string>
82 82
        </attribute>
83 83
        <layout class="QGridLayout" name="gridLayout_4">
84 84
         <item row="0" column="0">
85
          <widget class="QLabel" name="label_5">
85
          <widget class="QLabel" name="lblTitre">
86 86
           <property name="text">
87 87
            <string>Titre</string>
88 88
           </property>
......
92 92
          <widget class="QLineEdit" name="leTitre"/>
93 93
         </item>
94 94
         <item row="1" column="0">
95
          <widget class="QLabel" name="label_3">
95
          <widget class="QLabel" name="lblDesc">
96 96
           <property name="text">
97 97
            <string>Description</string>
98 98
           </property>
......
102 102
          <widget class="QLineEdit" name="leDesc"/>
103 103
         </item>
104 104
         <item row="2" column="0">
105
          <widget class="QLabel" name="label_6">
105
          <widget class="QLabel" name="lblAuthor">
106 106
           <property name="text">
107 107
            <string>Auteur</string>
108 108
           </property>
......
112 112
          <widget class="QLineEdit" name="leAuthor"/>
113 113
         </item>
114 114
         <item row="2" column="2">
115
          <widget class="QLabel" name="label">
115
          <widget class="QLabel" name="lblDate">
116 116
           <property name="text">
117 117
            <string>Date</string>
118 118
           </property>
......
132 132
           </property>
133 133
           <layout class="QFormLayout" name="formLayout">
134 134
            <item row="1" column="0">
135
             <widget class="QLabel" name="label_4">
135
             <widget class="QLabel" name="lblIdentifiant">
136 136
              <property name="text">
137 137
               <string>Identifiant</string>
138 138
              </property>
......
142 142
             <widget class="QLineEdit" name="leLogin"/>
143 143
            </item>
144 144
            <item row="2" column="0">
145
             <widget class="QLabel" name="label_2">
145
             <widget class="QLabel" name="lblPasswd">
146 146
              <property name="text">
147 147
               <string>Mot de passe</string>
148 148
              </property>
......
152 152
             <widget class="QLineEdit" name="lePasswd"/>
153 153
            </item>
154 154
            <item row="0" column="0" colspan="2">
155
             <widget class="QLabel" name="label_7">
155
             <widget class="QLabel" name="lblCompletez">
156 156
              <property name="text">
157 157
               <string>Complétez les deux champs ci-dessous si vous voulez protéger l'accès (lorsqu'il sera publié sur internet) à cet album photo par un identifiant et un mot de passe.</string>
158 158
              </property>
......
173 173
         </item>
174 174
        </layout>
175 175
       </widget>
176
       <widget class="QWidget" name="tab_3">
176
       <widget class="QWidget" name="tabPhotos">
177 177
        <attribute name="title">
178 178
         <string>2. Photos</string>
179 179
        </attribute>
......
202 202
         </item>
203 203
        </layout>
204 204
       </widget>
205
       <widget class="QWidget" name="tab">
205
       <widget class="QWidget" name="tabPublier">
206 206
        <attribute name="title">
207 207
         <string>3. Publier sur internet</string>
208 208
        </attribute>
209 209
        <layout class="QGridLayout" name="gridLayout_2">
210 210
         <item row="0" column="0">
211
          <widget class="QLabel" name="label_8">
211
          <widget class="QLabel" name="lblLogin">
212 212
           <property name="text">
213 213
            <string>Identifiant</string>
214 214
           </property>
......
222 222
          </widget>
223 223
         </item>
224 224
         <item row="1" column="0">
225
          <widget class="QLabel" name="label_9">
225
          <widget class="QLabel" name="lblPass">
226 226
           <property name="text">
227 227
            <string>Mot de passe</string>
228 228
           </property>
......
239 239
          </widget>
240 240
         </item>
241 241
         <item row="2" column="0">
242
          <widget class="QLabel" name="label_10">
242
          <widget class="QLabel" name="lblFTP">
243 243
           <property name="text">
244 244
            <string>Serveur FTP</string>
245 245
           </property>
......
253 253
          </widget>
254 254
         </item>
255 255
         <item row="3" column="0">
256
          <widget class="QLabel" name="label_11">
256
          <widget class="QLabel" name="lblDest">
257 257
           <property name="text">
258 258
            <string>Répertoire d'installation</string>
259 259
           </property>
......
266 266
           </property>
267 267
          </widget>
268 268
         </item>
269
         <item row="4" column="1">
269
         <item row="6" column="1">
270 270
          <widget class="QPushButton" name="btnUpload">
271 271
           <property name="text">
272 272
            <string>Upload gallerie en cours</string>
273 273
           </property>
274 274
          </widget>
275 275
         </item>
276
         <item row="4" column="1">
277
          <widget class="QProgressBar" name="pbFTPFichier">
278
           <property name="value">
279
            <number>0</number>
280
           </property>
281
           <property name="format">
282
            <string>%v / %m</string>
283
           </property>
284
          </widget>
285
         </item>
286
         <item row="5" column="1">
287
          <widget class="QProgressBar" name="pbFTPProgress">
288
           <property name="value">
289
            <number>24</number>
290
           </property>
291
          </widget>
292
         </item>
293
         <item row="4" column="0">
294
          <widget class="QLabel" name="lblFichiers">
295
           <property name="text">
296
            <string>Fichiers:</string>
297
           </property>
298
          </widget>
299
         </item>
300
         <item row="5" column="0">
301
          <widget class="QLabel" name="lblProgression">
302
           <property name="text">
303
            <string>Progression</string>
304
           </property>
305
          </widget>
306
         </item>
276 307
        </layout>
277 308
       </widget>
278 309
      </widget>
ryxeo-webphotoalbum.pro
12 12
SOURCES += main.cpp\
13 13
        original.cpp \
14 14
    assistant.cpp \
15
    tools.cpp
15
    tools.cpp \
16
    newalbumdialog.cpp
16 17

  
17 18
HEADERS  += original.h \
18 19
    assistant.h \
19
    tools.h
20
    tools.h \
21
    newalbumdialog.h
20 22

  
21 23
FORMS    += original.ui \
22
    assistant.ui
24
    assistant.ui \
25
    newalbumdialog.ui
23 26

  
24 27
unix:LIBS += -lexiv2
25 28
win32:LIBS += -lexiv2
tools.cpp
1
/**
2
  * Classe 
1
/** Classe tools: regroupe ce qui est mutualisable entre assistant et appli
3 2
  * @see https://redmine.ryxeo.com/projects/
4 3
  * @author 2012 Eric Seigne <eric.seigne@ryxeo.com>
5 4
  * @see The GNU Public License (GNU/GPL) v3
6 5
  *
7 6
  *
8
  *
9 7
  * This program is free software; you can redistribute it and/or modify
10 8
  * it under the terms of the GNU General Public License as published by
11 9
  * the Free Software Foundation; either version 3 of the License, or
......
23 21

  
24 22
#include "tools.h"
25 23

  
24
class AbulEduSleeperThread : public QThread
25
{
26
public:
27
    static void msleep(unsigned long msecs) {QThread::msleep(msecs);}
28
};
29

  
30

  
26 31
tools::tools(QDir basedir, QObject *parent) :
27 32
    QObject(parent)
28 33
{
29 34
    m_baseDir = basedir;
30 35
}
31 36

  
32
QFtp *tools::ftpConnect(QString serveur, QString login, QString passwd)
37
void tools::ftpConnect(QString serveur, QString login, QString passwd)
33 38
{
39
    qDebug() << "tools::ftpConnect (0)";
34 40
    m_currentFTPFileUpload = -1;
35 41

  
36 42
    m_ftp = new QFtp(this);
37 43
    connect(m_ftp, SIGNAL(commandFinished(int,bool)),
38 44
            this, SLOT(ftpCommandFinished(int,bool)));
45
    connect(m_ftp, SIGNAL(done(bool)),
46
            this, SLOT(ftpDone(bool)));
47
    connect(m_ftp, SIGNAL(stateChanged(int)),
48
            this, SLOT(ftpStateChanged(int)));
39 49
    connect(m_ftp, SIGNAL(listInfo(QUrlInfo)),
40 50
            this, SLOT(addToList(QUrlInfo)));
41 51
    connect(m_ftp, SIGNAL(dataTransferProgress(qint64,qint64)),
42 52
            this, SLOT(updateDataTransferProgress(qint64,qint64)));
43 53

  
44
    qDebug() << "aaaaaaaaaaaaaa";
45 54
    m_ftp->connectToHost(serveur, 21);
46 55
    m_ftp->setTransferMode(QFtp::Passive);
47

  
48
    qDebug() << "bbbbbbbbbbbbb";
49

  
50 56
    m_ftp->login(login, passwd);
51 57

  
52
    qDebug() << "Listing FTP: ";
53
    //ftp->cd(url.path());
54
    //On uploade l'album en cours
55
    //m_ftp->put()
56

  
57
    return m_ftp;
58
    qDebug() << "tools::ftpConnect (1)";
58 59
}
59 60

  
60 61
void tools::ftpCommandFinished(int commandId, bool error)
61 62
{
62
//    qDebug() << "ftpCommandFinished";
63
    if(error) {
64
        qDebug() << "ftpCommandFinished ERROR : " << commandId << " " << m_ftp->errorString();
65

  
66
    }
67
    //setCursor(Qt::ArrowCursor);
63
    //    if(error) {
64
    qDebug() << "======================= BEGIN FTP INFO ======================= ";
65
    qDebug() << "  Numero de commande : " << commandId;
66
    //    }
68 67

  
69 68
    if (m_ftp->currentCommand() == QFtp::ConnectToHost) {
70
        qDebug() << "Logged onto server error : " << error;
69
        qDebug() << "  Command: Connect to host";
71 70
    }
72 71

  
73 72
    if (m_ftp->currentCommand() == QFtp::Login) {
74
        qDebug() << "Login ...";
75
        m_ftp->list();
73
        qDebug() << "  Command: Login";
76 74
    }
77 75

  
78 76
    if (m_ftp->currentCommand() == QFtp::Put) {
79
//        qDebug() << "Put ...";
77
        QFile *file = static_cast<QFile*>(m_ftp->currentDevice());
78
        if(file) {
79
            file->deleteLater();
80
        }
81
        qDebug() << "  Command: Put";
80 82
    }
81 83

  
82 84
    if (m_ftp->currentCommand() == QFtp::Get) {
83
        qDebug() << "Get ...";
84
        if (error) {
85
        } else {
86
        }
87
    } else if (m_ftp->currentCommand() == QFtp::List) {
88
        qDebug() << "List ...";
85
        qDebug() << "  Command: Get";
89 86
    }
90 87

  
91
    //on passe au suivant
92
    if(m_currentFTPFileUpload >= 0 && m_fileListToUploadIndex.count() > 0) {
93
//        qDebug() << "Il en reste encore a envoyer ";
94
        if(m_typeUploadRecursif == "PHP")
95
            uploadRecursifPHP(m_destDirBase);
96
        else
97
            uploadRecursifGallery(m_destDirBase);
88
    if (m_ftp->currentCommand() == QFtp::List) {
89
        qDebug() << "  Command: List";
90
    }
91
    if(error) {
92
        qDebug() << "  Description de l'erreur " << m_ftp->errorString().trimmed();
93
        qDebug() << "  Abort command and clear pending commands !";
94
        //grosse ruse pour remettre un peu a zero les erreurs de QFTP qui est quand meme
95
        //bien capricieux !
96
        m_ftp->cd("/");
97
        m_ftp->list("/");
98
        m_ftp->clearPendingCommands();
99
        AbulEduSleeperThread::msleep(2000);
98 100
    }
99
    else {
100
        qDebug() << "Tout a ete expedie ";
101
    qDebug() << "======================= END FTP INFO ======================= ";
102

  
103
    //    if(m_currentFTPFileUpload >= 0 && m_fileListToUploadIndex.count() > 0) {
104
    //        if(m_typeUploadRecursif == "PHP")
105
    //            uploadRecursifPHP(m_destDirBase);
106
    //        else
107
    //            uploadRecursifGallery(m_destDirBase);
108
    //    }
109
    //    else {
110
    //        qDebug() << "Tout a ete expedie ";
111
    //    }
112
}
113

  
114
void tools::ftpDone(bool error)
115
{
116
    qDebug() << "tools::ftpDone : " << error;
117
    //if(error)
118
    qDebug() << "   " << m_ftp->errorString();
119

  
120
    //on passe a la commande FTP suivante et on nettoie au passage
121
    //    m_ftp->clearPendingCommands();
122
    ftpNextCommand();
123
}
124

  
125
void tools::ftpStateChanged(int state)
126
{
127
    qDebug() << "tools::ftpStateChanged : code " << state;
128
    if(state == QFtp::Closing) {
129
        m_ftpCommands.clear();
101 130
    }
102 131
}
103 132

  
104 133
void tools::updateDataTransferProgress(qint64 readBytes, qint64 totalBytes)
105 134
{
106
//    qDebug() << "Transfert: " << readBytes << " sur " << totalBytes;
135
    //    qDebug() << "Transfert: " << readBytes << " sur " << totalBytes;
107 136
    emit signalUploadData(totalBytes, readBytes);
108 137
}
109 138

  
......
124 153
    return m_fileListToUploadIndex.count();
125 154
}
126 155

  
156
void tools::ftpNextCommand()
157
{
158
    if(!m_ftpCommands.isEmpty()) {
159
        QStringList cmd(m_ftpCommands.takeFirst().split(";"));
160
        if(cmd.at(0) == "mkdir") {
161
            m_ftp->mkdir(cmd.at(1));
162
        }
163
        if(cmd.at(0) == "put") {
164
            QFile *fic = new QFile(cmd.at(1));
165
            if(fic->open(QIODevice::ReadOnly)) {
166
                qDebug() << "       Upload : " << cmd.at(1) << " -> " << cmd.at(2);
167
                m_ftp->put(fic,cmd.at(2));
168
            }
169
            else {
170
                //erreur
171
            }
172
        }
173
        m_currentFTPFileUpload++;
174
        emit signalUpload(nbTotalUpload(), m_currentFTPFileUpload);
175
    }
176
}
177

  
178
void tools::ftpMkdir(QString rep)
179
{
180
    //Avant de faire un mkdir il faut verifier si le repertoire n'existe pas deja
181
    //sinon la pile des commandes FTP est remise a zero !!!
182
    m_ftpCommands << "mkdir;" + rep;
183
}
184

  
185
void tools::ftpPut(QString source, QString ladest)
186
{
187
    m_ftpCommands << "put;" + source + ";" + ladest;
188
}
189

  
127 190
void tools::parcoursRecursif(QString rep, QString repertoireServeur)
128 191
{
129 192
    qDebug() << "parcoursRecursif : " << rep;
......
144 207

  
145 208
void tools::uploadRecursifGallery(QString destDirBase)
146 209
{
147
    qDebug() << "uploadRecursifGallery : ";
148
    m_typeUploadRecursif = "Gallery";
210
    qDebug() << " ** uploadRecursifGallery : " << m_fileListToUploadIndex.count() ;
149 211
    m_destDirBase = destDirBase;
150
    if(m_currentFTPFileUpload < m_fileListToUploadIndex.count()) {
151
        QFileInfo fi(m_fileListToUploadIndex.at(m_currentFTPFileUpload));
212
    m_typeUploadRecursif = "Gallery";
213
    while(m_fileListToUploadIndex.count()>0) {
214
        QString s(m_fileListToUploadIndex.takeFirst());
215
        qDebug() << "     -> " << s;
216
        QFileInfo fi(s);
152 217
        if(fi.isDir()) {
153
            QString ladest = destDirBase + "/galleries/" + fi.absoluteFilePath().remove(m_baseDir.absolutePath()).remove("/www");
154
            qDebug() << "mkdir : " << ladest;
155
            m_ftp->mkdir(ladest);
218
            QString ladest = m_destDirBase + "/galleries" + fi.absoluteFilePath().remove(m_baseDir.absolutePath());
219
            qDebug() << "       mkdir : " << ladest;
220
            ftpMkdir(ladest);
156 221
        }
157 222
        else {
158
            QFile *fic = new QFile(fi.absoluteFilePath());
159
            fic->open(QIODevice::ReadOnly);
160 223
            QString ladest = destDirBase + "/galleries/" + m_fileListToUpload.value(fi.absoluteFilePath()) + "/" + fi.fileName();
161
            qDebug() << "Upload : " << fi.absoluteFilePath() << " -> " << ladest;
162
            m_ftp->put(fic,ladest);
163
            fic->close();
224
            ftpPut(fi.absoluteFilePath(),ladest);
164 225
        }
165
        m_currentFTPFileUpload++;
166 226
    }
167 227
}
168 228

  
......
181 241
        if(fi.isDir()) {
182 242
            QString ladest = m_destDirBase + fi.absoluteFilePath().remove(m_baseDir.absolutePath()).remove("/www");
183 243
            qDebug() << "mkdir : " << ladest;
184
            m_ftp->mkdir(ladest);
244
            ftpMkdir(ladest);
185 245
        }
186 246
        else {
187
            QFile *fic = new QFile(fi.absoluteFilePath());
188
            fic->open(QIODevice::ReadOnly);
189 247
            QString ladest = m_destDirBase + m_fileListToUpload.value(fi.absoluteFilePath()) + "/" + fi.fileName();
190
            qDebug() << "Upload : " << fi.fileName() << " -> " << ladest;
191
            m_ftp->put(fic,ladest);
192
            fic->close();
248
            ftpPut(fi.absoluteFilePath(),ladest);
193 249
        }
194 250
        m_currentFTPFileUpload++;
195 251
    }
......
197 253

  
198 254
void tools::addToList(const QUrlInfo &urlInfo)
199 255
{
256
    qDebug() << "tools::addToList";
200 257
    qDebug() << urlInfo.name();
201 258
}
202

  
tools.h
31 31
#include <QDebug>
32 32
#include <QApplication>
33 33
#include <QDir>
34
#include <QThread>
34 35

  
35 36
class tools : public QObject
36 37
{
......
43 44
    void signalUploadData(int,int);
44 45

  
45 46
public slots:
46
    QFtp *ftpConnect(QString serveur, QString login, QString passwd);
47
    void ftpConnect(QString serveur, QString login, QString passwd);
47 48
    void parcoursRecursif(QString rep, QString repertoireServeur);
48 49
    void ftpCommandFinished(int commandId, bool error);
50
    void ftpDone(bool error);
51
    void ftpStateChanged(int state);
49 52
    void uploadRecursifPHP(QString destDirBase);
50 53
    void uploadRecursifGallery(QString destDirBase);
51 54
    void updateDataTransferProgress(qint64 readBytes,
......
54 57
    void clear();
55 58
    int nbTotalUpload();
56 59
    int nbResteUpload();
60
    void ftpMkdir(QString rep);
61
    void ftpPut(QString source, QString ladest);
62
    void ftpNextCommand();
57 63

  
58 64
private:
59 65
    QFtp *m_ftp;
......
65 71
    QMap<QString,QString> m_fileListToUpload;
66 72
    int m_currentProjectPictureNumber;
67 73
    int m_currentFTPFileUpload;
68

  
74
    QStringList m_ftpCommands;
69 75
};
70 76

  
71 77
#endif // TOOLS_H

Formats disponibles : Unified diff

Redmine Appliance - Powered by TurnKey Linux