Révision 293017f7
assistant.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 "assistant.h" |
|
25 |
#include "ui_assistant.h" |
|
26 |
|
|
27 |
Assistant::Assistant(QWidget *parent) : |
|
28 |
QWizard(parent), |
|
29 |
ui(new Ui::Assistant) |
|
30 |
{ |
|
31 |
ui->setupUi(this); |
|
32 |
m_tools = new tools(QDir("."),this); |
|
33 |
} |
|
34 |
|
|
35 |
Assistant::~Assistant() |
|
36 |
{ |
|
37 |
delete ui; |
|
38 |
} |
|
39 |
|
|
40 |
void Assistant::on_btnUploadPHP_clicked() |
|
41 |
{ |
|
42 |
qDebug() << "Assistant::on_btnUploadPHP_clicked"; |
|
43 |
|
|
44 |
m_ftp = m_tools->ftpConnect(ui->leFTPServeur->text(), |
|
45 |
ui->leFTPLogin->text(), |
|
46 |
ui->leFTPPass->text()); |
|
47 |
|
|
48 |
m_ftp->mkdir(ui->leFTPDirectory->text()); |
|
49 |
m_ftp->mkdir(ui->leFTPDirectory->text() + "/galleries"); |
|
50 |
|
|
51 |
//On uploade le code php |
|
52 |
m_ftp->cd(ui->leFTPDirectory->text()); |
|
53 |
QDir dir("www"); |
|
54 |
m_tools->clear(); |
|
55 |
m_tools->parcoursRecursif(dir.absolutePath(),""); |
|
56 |
//qDebug() << m_fileListToUpload; |
|
57 |
m_tools->uploadRecursifPHP(ui->leFTPDirectory->text()); |
|
58 |
connect(m_tools, SIGNAL(signalUpload(int,int)), this, SLOT(updateProgressFichier(int,int))); |
|
59 |
connect(m_tools, SIGNAL(signalUploadData(int,int)), this, SLOT(updateProgressData(int,int))); |
|
60 |
} |
|
61 |
|
|
62 |
void Assistant::updateProgressFichier(int total, int current) |
|
63 |
{ |
|
64 |
ui->pbFTPFichier->setMaximum(total); |
|
65 |
ui->pbFTPFichier->setValue(current); |
|
66 |
} |
|
67 |
|
|
68 |
void Assistant::updateProgressData(int total, int current) |
|
69 |
{ |
|
70 |
ui->pbFTPProgress->setMaximum(total); |
|
71 |
ui->pbFTPProgress->setValue(current); |
|
72 |
} |
assistant.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 ASSISTANT_H |
|
25 |
#define ASSISTANT_H |
|
26 |
|
|
27 |
#include <QWizard> |
|
28 |
#include <QFtp> |
|
29 |
#include <QDebug> |
|
30 |
#include <QDir> |
|
31 |
#include "tools.h" |
|
32 |
|
|
33 |
namespace Ui { |
|
34 |
class Assistant; |
|
35 |
} |
|
36 |
|
|
37 |
class Assistant : public QWizard |
|
38 |
{ |
|
39 |
Q_OBJECT |
|
40 |
|
|
41 |
public: |
|
42 |
explicit Assistant(QWidget *parent = 0); |
|
43 |
~Assistant(); |
|
44 |
|
|
45 |
private slots: |
|
46 |
void on_btnUploadPHP_clicked(); |
|
47 |
void updateProgressFichier(int total, int current); |
|
48 |
void updateProgressData(int total, int current); |
|
49 |
|
|
50 |
private: |
|
51 |
Ui::Assistant *ui; |
|
52 |
tools *m_tools; |
|
53 |
QFtp *m_ftp; |
|
54 |
QString m_currentProjectDir; |
|
55 |
QString m_typeUploadRecursif; |
|
56 |
QStringList m_fileListToUploadIndex; |
|
57 |
QMap<QString,QString> m_fileListToUpload; |
|
58 |
int m_currentProjectPictureNumber; |
|
59 |
int m_currentFTPFileUpload; |
|
60 |
|
|
61 |
}; |
|
62 |
|
|
63 |
#endif // ASSISTANT_H |
assistant.ui | ||
---|---|---|
1 |
<?xml version="1.0" encoding="UTF-8"?> |
|
2 |
<ui version="4.0"> |
|
3 |
<class>Assistant</class> |
|
4 |
<widget class="QWizard" name="Assistant"> |
|
5 |
<property name="geometry"> |
|
6 |
<rect> |
|
7 |
<x>0</x> |
|
8 |
<y>0</y> |
|
9 |
<width>450</width> |
|
10 |
<height>310</height> |
|
11 |
</rect> |
|
12 |
</property> |
|
13 |
<property name="windowTitle"> |
|
14 |
<string>Wizard</string> |
|
15 |
</property> |
|
16 |
<widget class="QWizardPage" name="wizardPage1"> |
|
17 |
<layout class="QGridLayout" name="gridLayout"> |
|
18 |
<item row="0" column="0"> |
|
19 |
<widget class="QLabel" name="lblBonjour"> |
|
20 |
<property name="text"> |
|
21 |
<string>Bonjour et bienvenue dans cet assistant qui va vous permettre d'initialiser votre album photo en ligne. |
|
22 |
|
|
23 |
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 :) |
|
24 |
- Free.fr (pages perso) |
|
25 |
- Herbergratuit.com |
|
26 |
- Serveur FTP générique |
|
27 |
|
|
28 |
Cliquez sur le bouton Suivant pour passer à l'étape suivante. |
|
29 |
|
|
30 |
Si vous voulez relancer cet assistant vous pourrez le faire depuis le menu Options du logiciel.</string> |
|
31 |
</property> |
|
32 |
<property name="scaledContents"> |
|
33 |
<bool>true</bool> |
|
34 |
</property> |
|
35 |
<property name="wordWrap"> |
|
36 |
<bool>true</bool> |
|
37 |
</property> |
|
38 |
</widget> |
|
39 |
</item> |
|
40 |
</layout> |
|
41 |
</widget> |
|
42 |
<widget class="QWizardPage" name="wizardPage2"> |
|
43 |
<layout class="QFormLayout" name="formLayout"> |
|
44 |
<property name="fieldGrowthPolicy"> |
|
45 |
<enum>QFormLayout::AllNonFixedFieldsGrow</enum> |
|
46 |
</property> |
|
47 |
<item row="0" column="0"> |
|
48 |
<widget class="QLabel" name="lblFTPLogin"> |
|
49 |
<property name="text"> |
|
50 |
<string>Identifiant :</string> |
|
51 |
</property> |
|
52 |
</widget> |
|
53 |
</item> |
|
54 |
<item row="0" column="1"> |
|
55 |
<widget class="QLineEdit" name="leFTPLogin"> |
|
56 |
<property name="text"> |
|
57 |
<string>webopenphoto</string> |
|
58 |
</property> |
|
59 |
</widget> |
|
60 |
</item> |
|
61 |
<item row="1" column="0"> |
|
62 |
<widget class="QLabel" name="lblFTPPass"> |
|
63 |
<property name="text"> |
|
64 |
<string>Mot de passe :</string> |
|
65 |
</property> |
|
66 |
</widget> |
|
67 |
</item> |
|
68 |
<item row="1" column="1"> |
|
69 |
<widget class="QLineEdit" name="leFTPPass"> |
|
70 |
<property name="text"> |
|
71 |
<string>MowlUcDyach6</string> |
|
72 |
</property> |
|
73 |
<property name="echoMode"> |
|
74 |
<enum>QLineEdit::PasswordEchoOnEdit</enum> |
|
75 |
</property> |
|
76 |
</widget> |
|
77 |
</item> |
|
78 |
<item row="2" column="0"> |
|
79 |
<widget class="QLabel" name="lblFTPServeur"> |
|
80 |
<property name="text"> |
|
81 |
<string>Serveur FTP :</string> |
|
82 |
</property> |
|
83 |
</widget> |
|
84 |
</item> |
|
85 |
<item row="2" column="1"> |
|
86 |
<widget class="QLineEdit" name="leFTPServeur"> |
|
87 |
<property name="text"> |
|
88 |
<string>ftpperso.free.fr</string> |
|
89 |
</property> |
|
90 |
</widget> |
|
91 |
</item> |
|
92 |
<item row="3" column="0"> |
|
93 |
<widget class="QLabel" name="lblFTPDirectory"> |
|
94 |
<property name="text"> |
|
95 |
<string>Répertoire d'installation :</string> |
|
96 |
</property> |
|
97 |
</widget> |
|
98 |
</item> |
|
99 |
<item row="3" column="1"> |
|
100 |
<widget class="QLineEdit" name="leFTPDirectory"> |
|
101 |
<property name="text"> |
|
102 |
<string>/album</string> |
|
103 |
</property> |
|
104 |
</widget> |
|
105 |
</item> |
|
106 |
<item row="5" column="1"> |
|
107 |
<widget class="QProgressBar" name="pbFTPFichier"> |
|
108 |
<property name="value"> |
|
109 |
<number>0</number> |
|
110 |
</property> |
|
111 |
<property name="format"> |
|
112 |
<string>%v / %m</string> |
|
113 |
</property> |
|
114 |
</widget> |
|
115 |
</item> |
|
116 |
<item row="5" column="0"> |
|
117 |
<widget class="QLabel" name="lblFTPProgress"> |
|
118 |
<property name="text"> |
|
119 |
<string>Fichier :</string> |
|
120 |
</property> |
|
121 |
</widget> |
|
122 |
</item> |
|
123 |
<item row="7" column="0" colspan="2"> |
|
124 |
<widget class="QPushButton" name="btnUploadPHP"> |
|
125 |
<property name="text"> |
|
126 |
<string>&Initialiser l'album photo</string> |
|
127 |
</property> |
|
128 |
</widget> |
|
129 |
</item> |
|
130 |
<item row="6" column="0"> |
|
131 |
<widget class="QLabel" name="label"> |
|
132 |
<property name="text"> |
|
133 |
<string>Progression :</string> |
|
134 |
</property> |
|
135 |
</widget> |
|
136 |
</item> |
|
137 |
<item row="6" column="1"> |
|
138 |
<widget class="QProgressBar" name="pbFTPProgress"> |
|
139 |
<property name="value"> |
|
140 |
<number>0</number> |
|
141 |
</property> |
|
142 |
</widget> |
|
143 |
</item> |
|
144 |
</layout> |
|
145 |
</widget> |
|
146 |
</widget> |
|
147 |
<resources/> |
|
148 |
<connections/> |
|
149 |
</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 |
m_tools = new tools(m_baseDir, this); |
|
70 | 71 |
|
71 | 72 |
//============== l'étiquette invitant a déposer des images |
72 | 73 |
m_labelDeposez = new QLabel(trUtf8("Glissez-déposez ici les photos que vous voulez ajouter à cet album ..."),ui->lwPictures); |
... | ... | |
402 | 403 |
} |
403 | 404 |
} |
404 | 405 |
|
405 |
void original::ftpConnect() |
|
406 |
{ |
|
407 |
m_currentFTPFileUpload = -1; |
|
408 |
|
|
409 |
m_ftp = new QFtp(this); |
|
410 |
connect(m_ftp, SIGNAL(commandFinished(int,bool)), |
|
411 |
this, SLOT(ftpCommandFinished(int,bool))); |
|
412 |
connect(m_ftp, SIGNAL(listInfo(QUrlInfo)), |
|
413 |
this, SLOT(addToList(QUrlInfo))); |
|
414 |
connect(m_ftp, SIGNAL(dataTransferProgress(qint64,qint64)), |
|
415 |
this, SLOT(updateDataTransferProgress(qint64,qint64))); |
|
416 |
|
|
417 |
qDebug() << "aaaaaaaaaaaaaa"; |
|
418 |
m_ftp->connectToHost(ui->leFTPServeur->text(), 21); |
|
419 |
m_ftp->setTransferMode(QFtp::Passive); |
|
420 |
|
|
421 |
qDebug() << "bbbbbbbbbbbbb"; |
|
422 |
|
|
423 |
m_ftp->login(ui->leFTPLogin->text(), ui->leFTPPass->text()); |
|
424 |
|
|
425 |
qDebug() << "Listing FTP: "; |
|
426 |
//ftp->cd(url.path()); |
|
427 |
m_ftp->mkdir(ui->leFTPDirectory->text()); |
|
428 |
m_ftp->mkdir(ui->leFTPDirectory->text() + "/galleries"); |
|
429 |
|
|
430 |
//On uploade l'album en cours |
|
431 |
//m_ftp->put() |
|
432 |
} |
|
433 |
|
|
434 |
void original::ftpCommandFinished(int commandId, bool error) |
|
435 |
{ |
|
436 |
qDebug() << "ftpCommandFinished : " << commandId << "(" << QFtp::Put << ") : " << m_ftp->currentCommand(); |
|
437 |
#ifndef QT_NO_CURSOR |
|
438 |
setCursor(Qt::ArrowCursor); |
|
439 |
#endif |
|
440 |
|
|
441 |
if (m_ftp->currentCommand() == QFtp::ConnectToHost) { |
|
442 |
qDebug() << "Logged onto " << ui->leFTPServeur->text() << " error : " << error; |
|
443 |
} |
|
444 |
|
|
445 |
if (m_ftp->currentCommand() == QFtp::Login) { |
|
446 |
qDebug() << "Login ..."; |
|
447 |
m_ftp->list(); |
|
448 |
} |
|
449 |
|
|
450 |
if (m_ftp->currentCommand() == QFtp::Put) { |
|
451 |
qDebug() << "Put ..."; |
|
452 |
} |
|
453 |
|
|
454 |
if (m_ftp->currentCommand() == QFtp::Get) { |
|
455 |
qDebug() << "Get ..."; |
|
456 |
if (error) { |
|
457 |
} else { |
|
458 |
} |
|
459 |
} else if (m_ftp->currentCommand() == QFtp::List) { |
|
460 |
qDebug() << "List ..."; |
|
461 |
} |
|
462 |
|
|
463 |
//on passe au suivant |
|
464 |
if(m_currentFTPFileUpload >= 0 && m_fileListToUploadIndex.count() > 0) { |
|
465 |
qDebug() << "Il en reste encore a envoyer "; |
|
466 |
if(m_typeUploadRecursif == "PHP") |
|
467 |
uploadRecursifPHP(); |
|
468 |
else |
|
469 |
uploadRecursifGallery(); |
|
470 |
} |
|
471 |
else { |
|
472 |
qDebug() << "Tout a ete expedie "; |
|
473 |
} |
|
474 |
} |
|
475 |
|
|
476 |
void original::addToList(const QUrlInfo &urlInfo) |
|
477 |
{ |
|
478 |
qDebug() << urlInfo.name(); |
|
479 |
} |
|
480 |
|
|
481 |
void original::updateDataTransferProgress(qint64 readBytes, qint64 totalBytes) |
|
482 |
{ |
|
483 |
qDebug() << "Transfert: " << readBytes << " sur " << totalBytes; |
|
484 |
} |
|
485 |
|
|
486 |
void original::on_btnPHP_clicked() |
|
487 |
{ |
|
488 |
ftpConnect(); |
|
489 |
qDebug() << "on_btnPHP_clicked"; |
|
490 |
//On uploade le code php |
|
491 |
m_ftp->cd(ui->leFTPDirectory->text()); |
|
492 |
QDir dir(m_baseDir.absolutePath() + "/www"); |
|
493 |
m_fileListToUpload.clear(); |
|
494 |
m_fileListToUploadIndex.clear(); |
|
495 |
m_currentFTPFileUpload = 0; |
|
496 |
parcoursRecursif(dir.absolutePath(),""); |
|
497 |
//qDebug() << m_fileListToUpload; |
|
498 |
m_typeUploadRecursif = "PHP"; |
|
499 |
uploadRecursifPHP(); |
|
500 |
} |
|
501 |
|
|
502 |
void original::uploadRecursifPHP() |
|
503 |
{ |
|
504 |
qDebug() << "uploadRecursif : " << m_fileListToUploadIndex.count() ; |
|
505 |
if(m_fileListToUploadIndex.count()>0) { |
|
506 |
QFileInfo fi(m_fileListToUploadIndex.takeFirst()); |
|
507 |
if(fi.isDir()) { |
|
508 |
QString ladest = ui->leFTPDirectory->text() + "/" + fi.absoluteFilePath().remove(m_baseDir.absolutePath()).remove("/www"); |
|
509 |
qDebug() << "mkdir : " << ladest; |
|
510 |
m_ftp->mkdir(ladest); |
|
511 |
} |
|
512 |
else { |
|
513 |
QFile *fic = new QFile(fi.absoluteFilePath()); |
|
514 |
fic->open(QIODevice::ReadOnly); |
|
515 |
QString ladest = ui->leFTPDirectory->text() + "/" + m_fileListToUpload.value(fi.absoluteFilePath()) + "/" + fi.fileName(); |
|
516 |
qDebug() << "Upload : " << fi.fileName() << " -> " << ladest; |
|
517 |
m_ftp->put(fic,ladest); |
|
518 |
fic->close(); |
|
519 |
} |
|
520 |
m_currentFTPFileUpload++; |
|
521 |
} |
|
522 |
} |
|
523 |
|
|
524 |
void original::uploadRecursifGallery() |
|
525 |
{ |
|
526 |
qDebug() << "uploadRecursifGallery : "; |
|
527 |
if(m_currentFTPFileUpload < m_fileListToUploadIndex.count()) { |
|
528 |
QFileInfo fi(m_fileListToUploadIndex.at(m_currentFTPFileUpload)); |
|
529 |
if(fi.isDir()) { |
|
530 |
QString ladest = ui->leFTPDirectory->text() + "/galleries/" + fi.absoluteFilePath().remove(m_baseDir.absolutePath()).remove("/www"); |
|
531 |
qDebug() << "mkdir : " << ladest; |
|
532 |
m_ftp->mkdir(ladest); |
|
533 |
} |
|
534 |
else { |
|
535 |
QFile *fic = new QFile(fi.absoluteFilePath()); |
|
536 |
fic->open(QIODevice::ReadOnly); |
|
537 |
QString ladest = ui->leFTPDirectory->text() + "/galleries/" + m_fileListToUpload.value(fi.absoluteFilePath()) + "/" + fi.fileName(); |
|
538 |
qDebug() << "Upload : " << fi.fileName() << " -> " << ladest; |
|
539 |
m_ftp->put(fic,ladest); |
|
540 |
fic->close(); |
|
541 |
} |
|
542 |
m_currentFTPFileUpload++; |
|
543 |
} |
|
544 |
} |
|
545 |
|
|
546 |
void original::parcoursRecursif(QString rep, QString repertoireServeur) |
|
547 |
{ |
|
548 |
qDebug() << "parcoursRecursif : " << rep; |
|
549 |
QDir dir(rep); |
|
550 |
dir.setFilter(QDir::Hidden | QDir::Files | QDir::Dirs | QDir::NoSymLinks | QDir::NoDotAndDotDot); |
|
551 |
QFileInfoList list = dir.entryInfoList(); |
|
552 |
for(int i = 0; i < list.count(); i++) { |
|
553 |
qDebug() << "Ajout de ... " << list.at(i).absoluteFilePath(); |
|
554 |
m_fileListToUpload.insert(list.at(i).absoluteFilePath(), repertoireServeur); |
|
555 |
m_fileListToUploadIndex << list.at(i).absoluteFilePath(); |
|
556 |
if(list.at(i).isDir()) { |
|
557 |
parcoursRecursif(list.at(i).absoluteFilePath(), list.at(i).absoluteFilePath().remove(m_baseDir.absolutePath()).remove("/www")); |
|
558 |
} |
|
559 |
} |
|
560 |
} |
|
561 |
|
|
562 | 406 |
void original::on_btnUpload_clicked() |
563 | 407 |
{ |
564 |
ftpConnect(); |
|
408 |
m_ftp = m_tools->ftpConnect(ui->leFTPServeur->text(), |
|
409 |
ui->leFTPLogin->text(), |
|
410 |
ui->leFTPPass->text()); |
|
565 | 411 |
qDebug() << "on_btnUpload_clicked : " << ui->treeWidget->currentItem()->data(1,0).toString(); |
566 | 412 |
QFileInfo fi(ui->treeWidget->currentItem()->data(1,0).toString()); |
567 | 413 |
QDir dir(fi.absoluteFilePath()); |
568 |
m_fileListToUpload.clear(); |
|
569 |
m_fileListToUploadIndex.clear(); |
|
570 |
m_currentFTPFileUpload = 0; |
|
571 |
parcoursRecursif(dir.absolutePath(),ui->treeWidget->currentItem()->text(0)); |
|
414 |
m_tools->clear(); |
|
415 |
m_tools->parcoursRecursif(dir.absolutePath(),ui->treeWidget->currentItem()->text(0)); |
|
572 | 416 |
// qDebug() << m_fileListToUpload; |
573 |
m_typeUploadRecursif = "Gallery"; |
|
574 | 417 |
|
575 | 418 |
QString ladest = ui->leFTPDirectory->text() + "/galleries/" + ui->treeWidget->currentItem()->text(0); |
576 | 419 |
qDebug() << "mkdir : " << ladest; |
577 | 420 |
m_ftp->mkdir(ladest); |
578 | 421 |
// uploadRecursifGallery(); |
579 | 422 |
} |
423 |
|
|
424 |
void original::on_action_Assistant_d_installation_triggered() |
|
425 |
{ |
|
426 |
Assistant *a = new Assistant(this); |
|
427 |
a->show(); |
|
428 |
} |
original.h | ||
---|---|---|
36 | 36 |
#include <QDragEnterEvent> |
37 | 37 |
#include <QUrl> |
38 | 38 |
#include <QLabel> |
39 |
#include <QFtp> |
|
40 | 39 |
#include <QMessageBox> |
40 |
#include "tools.h" |
|
41 |
#include "assistant.h" |
|
41 | 42 |
|
42 | 43 |
namespace Ui { |
43 | 44 |
class original; |
... | ... | |
61 | 62 |
void dropEvent(QDropEvent *event); |
62 | 63 |
void addPictureToProject(QString fic); |
63 | 64 |
void refreshPictureList(); |
64 |
void ftpConnect(); |
|
65 |
|
|
66 | 65 |
// void connectOrDisconnect(); |
67 | 66 |
// void uploadFile(); |
68 | 67 |
// void cancelUpload(); |
69 |
|
|
70 |
void ftpCommandFinished(int commandId, bool error); |
|
71 |
void addToList(const QUrlInfo &urlInfo); |
|
72 | 68 |
// void processItem(QTreeWidgetItem *item, int column); |
73 |
void updateDataTransferProgress(qint64 readBytes, |
|
74 |
qint64 totalBytes); |
|
75 |
|
|
76 |
void on_btnPHP_clicked(); |
|
77 |
void uploadRecursifPHP(); |
|
78 |
void uploadRecursifGallery(); |
|
79 |
void parcoursRecursif(QString rep, QString repertoireServeur); |
|
80 |
|
|
81 | 69 |
void on_btnUpload_clicked(); |
82 | 70 |
|
71 |
void on_action_Assistant_d_installation_triggered(); |
|
72 |
|
|
83 | 73 |
private: |
84 | 74 |
Ui::original *ui; |
85 | 75 |
QDir m_baseDir; |
... | ... | |
92 | 82 |
int m_currentProjectPictureNumber; |
93 | 83 |
int m_currentFTPFileUpload; |
94 | 84 |
QFtp *m_ftp; |
85 |
tools *m_tools; |
|
95 | 86 |
|
96 | 87 |
}; |
97 | 88 |
|
original.ui | ||
---|---|---|
262 | 262 |
<item row="3" column="1"> |
263 | 263 |
<widget class="QLineEdit" name="leFTPDirectory"> |
264 | 264 |
<property name="text"> |
265 |
<string>/gallery</string>
|
|
265 |
<string>/album</string>
|
|
266 | 266 |
</property> |
267 | 267 |
</widget> |
268 | 268 |
</item> |
269 |
<item row="4" column="4">
|
|
269 |
<item row="4" 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="QPushButton" name="btnPHP"> |
|
278 |
<property name="text"> |
|
279 |
<string>Envoyer le code PHP</string> |
|
280 |
</property> |
|
281 |
</widget> |
|
282 |
</item> |
|
283 | 276 |
</layout> |
284 | 277 |
</widget> |
285 | 278 |
</widget> |
... | ... | |
309 | 302 |
<string>&Édition</string> |
310 | 303 |
</property> |
311 | 304 |
<addaction name="action_Pr_f_rences"/> |
305 |
<addaction name="action_Assistant_d_installation"/> |
|
312 | 306 |
</widget> |
313 | 307 |
<addaction name="menu_Fichier"/> |
314 | 308 |
<addaction name="menu_dition"/> |
... | ... | |
342 | 336 |
<string>&Préférences</string> |
343 | 337 |
</property> |
344 | 338 |
</action> |
339 |
<action name="action_Assistant_d_installation"> |
|
340 |
<property name="text"> |
|
341 |
<string>&Assistant d'installation</string> |
|
342 |
</property> |
|
343 |
</action> |
|
345 | 344 |
</widget> |
346 | 345 |
<layoutdefault spacing="6" margin="11"/> |
347 | 346 |
<tabstops> |
ryxeo-webphotoalbum.pro | ||
---|---|---|
11 | 11 |
|
12 | 12 |
SOURCES += main.cpp\ |
13 | 13 |
original.cpp \ |
14 |
assistant.cpp \ |
|
15 |
tools.cpp |
|
14 | 16 |
|
15 |
HEADERS += original.h |
|
17 |
HEADERS += original.h \ |
|
18 |
assistant.h \ |
|
19 |
tools.h |
|
16 | 20 |
|
17 |
FORMS += original.ui |
|
21 |
FORMS += original.ui \ |
|
22 |
assistant.ui |
|
18 | 23 |
|
19 | 24 |
unix:LIBS += -lexiv2 |
20 | 25 |
win32:LIBS += -lexiv2 |
tools.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 "tools.h" |
|
25 |
|
|
26 |
tools::tools(QDir basedir, QObject *parent) : |
|
27 |
QObject(parent) |
|
28 |
{ |
|
29 |
m_baseDir = basedir; |
|
30 |
} |
|
31 |
|
|
32 |
QFtp *tools::ftpConnect(QString serveur, QString login, QString passwd) |
|
33 |
{ |
|
34 |
m_currentFTPFileUpload = -1; |
|
35 |
|
|
36 |
m_ftp = new QFtp(this); |
|
37 |
connect(m_ftp, SIGNAL(commandFinished(int,bool)), |
|
38 |
this, SLOT(ftpCommandFinished(int,bool))); |
|
39 |
connect(m_ftp, SIGNAL(listInfo(QUrlInfo)), |
|
40 |
this, SLOT(addToList(QUrlInfo))); |
|
41 |
connect(m_ftp, SIGNAL(dataTransferProgress(qint64,qint64)), |
|
42 |
this, SLOT(updateDataTransferProgress(qint64,qint64))); |
|
43 |
|
|
44 |
qDebug() << "aaaaaaaaaaaaaa"; |
|
45 |
m_ftp->connectToHost(serveur, 21); |
|
46 |
m_ftp->setTransferMode(QFtp::Passive); |
|
47 |
|
|
48 |
qDebug() << "bbbbbbbbbbbbb"; |
|
49 |
|
|
50 |
m_ftp->login(login, passwd); |
|
51 |
|
|
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 |
} |
|
59 |
|
|
60 |
void tools::ftpCommandFinished(int commandId, bool error) |
|
61 |
{ |
|
62 |
qDebug() << "ftpCommandFinished"; |
|
63 |
if(error) |
|
64 |
qDebug() << "ftpCommandFinished ERROR : " << commandId << "(" << QFtp::Put << ") : " << m_ftp->currentCommand(); |
|
65 |
//setCursor(Qt::ArrowCursor); |
|
66 |
|
|
67 |
if (m_ftp->currentCommand() == QFtp::ConnectToHost) { |
|
68 |
qDebug() << "Logged onto server error : " << error; |
|
69 |
} |
|
70 |
|
|
71 |
if (m_ftp->currentCommand() == QFtp::Login) { |
|
72 |
qDebug() << "Login ..."; |
|
73 |
m_ftp->list(); |
|
74 |
} |
|
75 |
|
|
76 |
if (m_ftp->currentCommand() == QFtp::Put) { |
|
77 |
qDebug() << "Put ..."; |
|
78 |
} |
|
79 |
|
|
80 |
if (m_ftp->currentCommand() == QFtp::Get) { |
|
81 |
qDebug() << "Get ..."; |
|
82 |
if (error) { |
|
83 |
} else { |
|
84 |
} |
|
85 |
} else if (m_ftp->currentCommand() == QFtp::List) { |
|
86 |
qDebug() << "List ..."; |
|
87 |
} |
|
88 |
|
|
89 |
//on passe au suivant |
|
90 |
if(m_currentFTPFileUpload >= 0 && m_fileListToUploadIndex.count() > 0) { |
|
91 |
qDebug() << "Il en reste encore a envoyer "; |
|
92 |
if(m_typeUploadRecursif == "PHP") |
|
93 |
uploadRecursifPHP(m_destDirBase); |
|
94 |
else |
|
95 |
uploadRecursifGallery(m_destDirBase); |
|
96 |
} |
|
97 |
else { |
|
98 |
qDebug() << "Tout a ete expedie "; |
|
99 |
} |
|
100 |
} |
|
101 |
|
|
102 |
void tools::updateDataTransferProgress(qint64 readBytes, qint64 totalBytes) |
|
103 |
{ |
|
104 |
// qDebug() << "Transfert: " << readBytes << " sur " << totalBytes; |
|
105 |
emit signalUploadData(totalBytes, readBytes); |
|
106 |
} |
|
107 |
|
|
108 |
void tools::clear() |
|
109 |
{ |
|
110 |
m_fileListToUpload.clear(); |
|
111 |
m_fileListToUploadIndex.clear(); |
|
112 |
m_currentFTPFileUpload = 0; |
|
113 |
} |
|
114 |
|
|
115 |
int tools::nbTotalUpload() |
|
116 |
{ |
|
117 |
return m_fileListToUpload.count(); |
|
118 |
} |
|
119 |
|
|
120 |
int tools::nbResteUpload() |
|
121 |
{ |
|
122 |
return m_fileListToUploadIndex.count(); |
|
123 |
} |
|
124 |
|
|
125 |
void tools::parcoursRecursif(QString rep, QString repertoireServeur) |
|
126 |
{ |
|
127 |
qDebug() << "parcoursRecursif : " << rep; |
|
128 |
|
|
129 |
QDir dir(rep); |
|
130 |
dir.setFilter(QDir::Hidden | QDir::Files | QDir::Dirs | QDir::NoSymLinks | QDir::NoDotAndDotDot); |
|
131 |
QFileInfoList list = dir.entryInfoList(); |
|
132 |
for(int i = 0; i < list.count(); i++) { |
|
133 |
qDebug() << "Ajout de " << list.at(i).absoluteFilePath() << " rep serveur : " << repertoireServeur; |
|
134 |
m_fileListToUpload.insert(list.at(i).absoluteFilePath(), repertoireServeur); |
|
135 |
m_fileListToUploadIndex << list.at(i).absoluteFilePath(); |
|
136 |
if(list.at(i).isDir()) { |
|
137 |
parcoursRecursif(list.at(i).absoluteFilePath(), list.at(i).absoluteFilePath().remove(m_baseDir.absolutePath()).remove("/www")); |
|
138 |
} |
|
139 |
} |
|
140 |
} |
|
141 |
|
|
142 |
|
|
143 |
void tools::uploadRecursifGallery(QString destDirBase) |
|
144 |
{ |
|
145 |
qDebug() << "uploadRecursifGallery : "; |
|
146 |
m_typeUploadRecursif = "Gallery"; |
|
147 |
m_destDirBase = destDirBase; |
|
148 |
if(m_currentFTPFileUpload < m_fileListToUploadIndex.count()) { |
|
149 |
QFileInfo fi(m_fileListToUploadIndex.at(m_currentFTPFileUpload)); |
|
150 |
if(fi.isDir()) { |
|
151 |
QString ladest = destDirBase + "/galleries/" + fi.absoluteFilePath().remove(m_baseDir.absolutePath()).remove("/www"); |
|
152 |
qDebug() << "mkdir : " << ladest; |
|
153 |
m_ftp->mkdir(ladest); |
|
154 |
} |
|
155 |
else { |
|
156 |
QFile *fic = new QFile(fi.absoluteFilePath()); |
|
157 |
fic->open(QIODevice::ReadOnly); |
|
158 |
QString ladest = destDirBase + "/galleries/" + m_fileListToUpload.value(fi.absoluteFilePath()) + "/" + fi.fileName(); |
|
159 |
qDebug() << "Upload : " << fi.absoluteFilePath() << " -> " << ladest; |
|
160 |
m_ftp->put(fic,ladest); |
|
161 |
fic->close(); |
|
162 |
} |
|
163 |
m_currentFTPFileUpload++; |
|
164 |
} |
|
165 |
} |
|
166 |
|
|
167 |
|
|
168 |
void tools::uploadRecursifPHP(QString destDirBase) |
|
169 |
{ |
|
170 |
qDebug() << "uploadRecursif : " << m_fileListToUploadIndex.count() ; |
|
171 |
emit signalUpload(nbTotalUpload(), nbTotalUpload()-nbResteUpload()+1); |
|
172 |
m_destDirBase = destDirBase; |
|
173 |
m_typeUploadRecursif = "PHP"; |
|
174 |
|
|
175 |
if(m_fileListToUploadIndex.count()>0) { |
|
176 |
QString s(m_fileListToUploadIndex.takeFirst()); |
|
177 |
qDebug() << " -> " << s; |
|
178 |
QFileInfo fi(s); |
|
179 |
if(fi.isDir()) { |
|
180 |
QString ladest = m_destDirBase + fi.absoluteFilePath().remove(m_baseDir.absolutePath()).remove("/www"); |
|
181 |
qDebug() << "mkdir : " << ladest; |
|
182 |
m_ftp->mkdir(ladest); |
|
183 |
} |
|
184 |
else { |
|
185 |
QFile *fic = new QFile(fi.absoluteFilePath()); |
|
186 |
fic->open(QIODevice::ReadOnly); |
|
187 |
QString ladest = m_destDirBase + m_fileListToUpload.value(fi.absoluteFilePath()) + "/" + fi.fileName(); |
|
188 |
qDebug() << "Upload : " << fi.fileName() << " -> " << ladest; |
|
189 |
m_ftp->put(fic,ladest); |
|
190 |
fic->close(); |
|
191 |
} |
|
192 |
m_currentFTPFileUpload++; |
|
193 |
} |
|
194 |
} |
|
195 |
|
|
196 |
void tools::addToList(const QUrlInfo &urlInfo) |
|
197 |
{ |
|
198 |
qDebug() << urlInfo.name(); |
|
199 |
} |
|
200 |
|
tools.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 TOOLS_H |
|
25 |
#define TOOLS_H |
|
26 |
|
|
27 |
#include <QFtp> |
|
28 |
#include <QObject> |
|
29 |
#include <QStringList> |
|
30 |
#include <QMap> |
|
31 |
#include <QDebug> |
|
32 |
#include <QApplication> |
|
33 |
#include <QDir> |
|
34 |
|
|
35 |
class tools : public QObject |
|
36 |
{ |
|
37 |
Q_OBJECT |
|
38 |
public: |
|
39 |
explicit tools(QDir basedir, QObject *parent = 0); |
|
40 |
|
|
41 |
signals: |
|
42 |
void signalUpload(int,int); |
|
43 |
void signalUploadData(int,int); |
|
44 |
|
|
45 |
public slots: |
|
46 |
QFtp *ftpConnect(QString serveur, QString login, QString passwd); |
|
47 |
void parcoursRecursif(QString rep, QString repertoireServeur); |
|
48 |
void ftpCommandFinished(int commandId, bool error); |
|
49 |
void uploadRecursifPHP(QString destDirBase); |
|
50 |
void uploadRecursifGallery(QString destDirBase); |
|
51 |
void updateDataTransferProgress(qint64 readBytes, |
|
52 |
qint64 totalBytes); |
|
53 |
void addToList(const QUrlInfo &urlInfo); |
|
54 |
void clear(); |
|
55 |
int nbTotalUpload(); |
|
56 |
int nbResteUpload(); |
|
57 |
|
|
58 |
private: |
|
59 |
QFtp *m_ftp; |
|
60 |
QDir m_baseDir; |
|
61 |
QString m_destDirBase; |
|
62 |
QString m_currentProjectDir; |
|
63 |
QString m_typeUploadRecursif; |
|
64 |
QStringList m_fileListToUploadIndex; |
|
65 |
QMap<QString,QString> m_fileListToUpload; |
|
66 |
int m_currentProjectPictureNumber; |
|
67 |
int m_currentFTPFileUpload; |
|
68 |
|
|
69 |
}; |
|
70 |
|
|
71 |
#endif // TOOLS_H |
Formats disponibles : Unified diff