522 |
522 |
|
523 |
523 |
void original::on_btnFTPPublish_clicked()
|
524 |
524 |
{
|
|
525 |
m_currentFTPFileUpload = -1;
|
|
526 |
|
525 |
527 |
m_ftp = new QFtp(this);
|
526 |
528 |
connect(m_ftp, SIGNAL(commandFinished(int,bool)),
|
527 |
529 |
this, SLOT(ftpCommandFinished(int,bool)));
|
... | ... | |
548 |
550 |
//On uploade l'album en cours
|
549 |
551 |
//m_ftp->put()
|
550 |
552 |
|
551 |
|
m_currentFTPFileUpload = 0;
|
552 |
553 |
|
553 |
554 |
}
|
554 |
555 |
|
555 |
556 |
void original::ftpCommandFinished(int commandId, bool error)
|
556 |
557 |
{
|
|
558 |
qDebug() << "ftpCommandFinished : " << commandId << "(" << QFtp::Put << ") : " << m_ftp->currentCommand();
|
557 |
559 |
#ifndef QT_NO_CURSOR
|
558 |
560 |
setCursor(Qt::ArrowCursor);
|
559 |
561 |
#endif
|
... | ... | |
569 |
571 |
|
570 |
572 |
if (m_ftp->currentCommand() == QFtp::Put) {
|
571 |
573 |
qDebug() << "Put ...";
|
572 |
|
//on passe au suivant
|
573 |
|
on_btnPHP_clicked();
|
574 |
574 |
}
|
575 |
575 |
|
576 |
576 |
if (m_ftp->currentCommand() == QFtp::Get) {
|
... | ... | |
581 |
581 |
} else if (m_ftp->currentCommand() == QFtp::List) {
|
582 |
582 |
qDebug() << "List ...";
|
583 |
583 |
}
|
|
584 |
|
|
585 |
//on passe au suivant
|
|
586 |
if(m_currentFTPFileUpload >= 0 && m_currentFTPFileUpload < m_fileListToUploadIndex.count()) {
|
|
587 |
uploadRecursif();
|
|
588 |
}
|
584 |
589 |
}
|
585 |
590 |
|
586 |
591 |
void original::addToList(const QUrlInfo &urlInfo)
|
... | ... | |
595 |
600 |
|
596 |
601 |
void original::on_btnPHP_clicked()
|
597 |
602 |
{
|
|
603 |
qDebug() << "on_btnPHP_clicked";
|
598 |
604 |
//On uploade le code php
|
599 |
605 |
m_ftp->cd(ui->leFTPDirectory->text());
|
600 |
606 |
QDir dir(m_baseDir.absolutePath() + "/www");
|
601 |
|
dir.setFilter(QDir::Files | QDir::NoSymLinks | QDir::NoDotAndDotDot);
|
602 |
|
QFileInfoList list = dir.entryInfoList();
|
603 |
|
if(m_currentFTPFileUpload < list.count()) {
|
604 |
|
qDebug() << "Upload ... " << list.at(m_currentFTPFileUpload).fileName();
|
605 |
|
QFile *fic = new QFile(list.at(m_currentFTPFileUpload).absoluteFilePath());
|
606 |
|
fic->open(QIODevice::ReadOnly);
|
607 |
|
m_ftp->put(fic,list.at(m_currentFTPFileUpload).fileName());
|
608 |
|
fic->close();
|
|
607 |
m_fileListToUpload.clear();
|
|
608 |
m_fileListToUploadIndex.clear();
|
|
609 |
m_currentFTPFileUpload = 0;
|
|
610 |
parcoursRecursif(dir.absolutePath(),"");
|
|
611 |
qDebug() << m_fileListToUpload;
|
|
612 |
}
|
|
613 |
|
|
614 |
void original::uploadRecursif()
|
|
615 |
{
|
|
616 |
qDebug() << "uploadRecursif : ";
|
|
617 |
if(m_currentFTPFileUpload < m_fileListToUploadIndex.count()) {
|
|
618 |
QFileInfo fi(m_fileListToUploadIndex.at(m_currentFTPFileUpload));
|
|
619 |
if(fi.isDir()) {
|
|
620 |
QString ladest = ui->leFTPDirectory->text() + "/" + fi.absoluteFilePath().remove(m_baseDir.absolutePath() + "/www");
|
|
621 |
qDebug() << "mkdir : " << ladest;
|
|
622 |
m_ftp->mkdir(ladest);
|
|
623 |
}
|
|
624 |
else {
|
|
625 |
QFile *fic = new QFile(fi.absoluteFilePath());
|
|
626 |
fic->open(QIODevice::ReadOnly);
|
|
627 |
QString ladest = ui->leFTPDirectory->text() + "/" + m_fileListToUpload.value(fi.absoluteFilePath()) + "/" + fi.fileName();
|
|
628 |
qDebug() << "Upload : " << fi.fileName() << " -> " << ladest;
|
|
629 |
m_ftp->put(fic,ladest);
|
|
630 |
fic->close();
|
|
631 |
}
|
609 |
632 |
m_currentFTPFileUpload++;
|
610 |
633 |
}
|
|
634 |
}
|
|
635 |
|
|
636 |
void original::parcoursRecursif(QString rep, QString repertoireServeur)
|
|
637 |
{
|
|
638 |
qDebug() << "parcoursRecursif : " << rep;
|
|
639 |
QDir dir(rep);
|
|
640 |
dir.setFilter(QDir::Files | QDir::Dirs | QDir::NoSymLinks | QDir::NoDotAndDotDot);
|
|
641 |
QFileInfoList list = dir.entryInfoList();
|
|
642 |
for(int i = 0; i < list.count(); i++) {
|
|
643 |
qDebug() << "Ajout de ... " << list.at(i).absoluteFilePath();
|
|
644 |
m_fileListToUpload.insert(list.at(i).absoluteFilePath(), repertoireServeur);
|
|
645 |
m_fileListToUploadIndex << list.at(i).absoluteFilePath();
|
|
646 |
if(list.at(i).isDir()) {
|
|
647 |
parcoursRecursif(list.at(i).absoluteFilePath(), list.at(i).absoluteFilePath().remove(m_baseDir.absolutePath() + "/www"));
|
|
648 |
}
|
|
649 |
}
|
|
650 |
}
|
611 |
651 |
|
|
652 |
void original::on_btnUpload_clicked()
|
|
653 |
{
|
|
654 |
uploadRecursif();
|
612 |
655 |
}
|