Projet

Général

Profil

Paste
Statistiques
| Branche: | Révision:

ryxeo-webphotoalbum-git / assistant.cpp @ 83a77071

Historique | Voir | Annoter | Télécharger (3,48 ko)

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

    
21

    
22
#include "assistant.h"
23
#include "ui_assistant.h"
24

    
25
Assistant::Assistant(QWidget *parent) :
26
    QWizard(parent),
27
    ui(new Ui::Assistant)
28
{
29
    ui->setupUi(this);
30
    m_tools = new tools(QDir("."),this);
31
    connect(m_tools, SIGNAL(signalUploadEnd()), this, SLOT(uploadEnd()));
32

    
33
    //Es-ce qu'on a deja des valeurs ?
34
    QSettings settings;
35
    settings.beginGroup("FTP");
36
    ui->leFTPLogin->setText(settings.value("FTPLogin","identifiant").toString());
37
    ui->leFTPPass->setText(settings.value("FTPPass","").toString());
38
    ui->leFTPServeur->setText(settings.value("FTPServeur","ftpperso.free.fr").toString());
39
    ui->leFTPDirectory->setText(settings.value("FTPDirectory","/album").toString());
40
}
41

    
42
Assistant::~Assistant()
43
{
44
    delete ui;
45
}
46

    
47
void Assistant::on_btnUploadPHP_clicked()
48
{
49
    qDebug() << "Assistant::on_btnUploadPHP_clicked";
50

    
51
    QSettings settings;
52
    settings.beginGroup("FTP");
53
    settings.setValue("FTPLogin",ui->leFTPLogin->text());
54
    settings.setValue("FTPPass",ui->leFTPPass->text());
55
    settings.setValue("FTPServeur",ui->leFTPServeur->text());
56
    settings.setValue("FTPDirectory",ui->leFTPDirectory->text());
57

    
58
    if(ui->leFTPServeur->text().trimmed() == "") {
59
        ui->leFTPServeur->setFocus();
60
        return;
61
    }
62
    if(ui->leFTPLogin->text().trimmed() == "") {
63
        ui->leFTPLogin->setFocus();
64
        return;
65
    }
66
    if(ui->leFTPPass->text().trimmed() == "") {
67
        ui->leFTPPass->setFocus();
68
        return;
69
    }
70

    
71
//    ui->btnUploadPHP->setEnabled(false);
72
    m_tools->ftpConnect(ui->leFTPServeur->text(),
73
                        ui->leFTPLogin->text(),
74
                        ui->leFTPPass->text());
75

    
76
    m_tools->ftpMkdir(ui->leFTPDirectory->text());
77
    m_tools->ftpMkdir(ui->leFTPDirectory->text() + "/galleries");
78

    
79
    //On uploade le code php
80
    //m_ftp->cd(ui->leFTPDirectory->text());
81
    QDir dir("data/www");
82
    m_tools->clear();
83
    m_tools->parcoursRecursif(dir.absolutePath(),"");
84
    //qDebug() << m_fileListToUpload;
85
    m_tools->uploadRecursifPHP(ui->leFTPDirectory->text());
86
    connect(m_tools, SIGNAL(signalUpload(int,int,QString)), this, SLOT(updateProgressFichier(int,int,QString)));
87
    connect(m_tools, SIGNAL(signalUploadData(int,int)), this, SLOT(updateProgressData(int,int)));
88
}
89

    
90
void Assistant::updateProgressFichier(int total, int current, QString fileName)
91
{
92
    ui->pbFTPFichier->setMaximum(total);
93
    ui->pbFTPFichier->setValue(current);
94
}
95

    
96
void Assistant::updateProgressData(int total, int current)
97
{
98
    ui->pbFTPProgress->setMaximum(total);
99
    ui->pbFTPProgress->setValue(current);
100
}
101

    
102
void Assistant::uploadEnd()
103
{
104
    ui->btnUploadPHP->setText(trUtf8("Téléchargement terminé !"));
105
}
Redmine Appliance - Powered by TurnKey Linux