-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathimportgmaildialog.cpp
100 lines (87 loc) · 3.7 KB
/
importgmaildialog.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
/*
Copyright (C) <2011>
<enrico bacis> <[email protected]>
<ivan vaccari> <[email protected]>
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 "importgmaildialog.h"
#include "ui_importgmaildialog.h"
importGmailDialog::importGmailDialog(QString _lid, libJackSMS::dataTypes::phoneBookType &_phoneBook, QWidget *parent) :
QDialog(parent),
ui(new Ui::importGmailDialog),
logid(_lid),
phoneBook(_phoneBook)
{
ui->setupUi(this);
ui->labelImport->setPixmap(QPixmap(":/resource/ball-grey.png","png"));
ui->labelUpdateBook->setPixmap(QPixmap(":/resource/ball-grey.png","png"));
spinner=new QMovie(":/resource/loading-spinner.gif",QByteArray("gif"),this);
spinner->setScaledSize(QSize(16,16));
spinner->start();
}
importGmailDialog::~importGmailDialog()
{
delete ui;
}
void importGmailDialog::changeEvent(QEvent *e)
{
QDialog::changeEvent(e);
switch (e->type()) {
case QEvent::LanguageChange:
ui->retranslateUi(this);
break;
default:
break;
}
}
void importGmailDialog::on_pushButton_clicked()
{
close();
}
void importGmailDialog::phoneBookReloaded(libJackSMS::dataTypes::phoneBookType _r){
phoneBook=_r;
ui->labelUpdateBook->setPixmap(QPixmap(":/resource/jms-active.png","png"));
emit rewritePhoneBook();
}
void importGmailDialog::errorReload(){
//ui->labelUpdateBook->setText(e);
ui->labelUpdateBook->setPixmap(QPixmap(":/resource/jms-not-active.png","png"));
}
void importGmailDialog::importDone(int count){
ui->labelCount->setText(QString::number(count)+" contatti importati");
ui->labelImport->setPixmap(QPixmap(":/resource/jms-active.png","png"));
reloader = new libJackSMS::serverApi::reloader(logid);
connect(reloader,SIGNAL(phoneBookReloaded(libJackSMS::dataTypes::phoneBookType)),this,SLOT(phoneBookReloaded(libJackSMS::dataTypes::phoneBookType)));
connect(reloader,SIGNAL(errorReload()),this,SLOT(errorReload()));
ui->labelUpdateBook->setMovie(spinner);
reloader->reloadPhoneBook();
}
void importGmailDialog::importError(QString e){
ui->labelCount->setText(e);
ui->labelImport->setPixmap(QPixmap(":/resource/jms-not-active.png","png"));
}
void importGmailDialog::wrongCredentials(){
ui->labelCount->setText("Username o password errate");
ui->labelImport->setPixmap(QPixmap(":/resource/jms-not-active.png","png"));
}
void importGmailDialog::on_importButton_clicked()
{
ui->labelImport->setPixmap(QPixmap(":/resource/ball-grey.png","png"));
ui->labelUpdateBook->setPixmap(QPixmap(":/resource/ball-grey.png","png"));
ui->labelCount->setText("");
importer = new libJackSMS::serverApi::gmailAddressBookImporter(logid);
connect(importer,SIGNAL(importDone(int)),this,SLOT(importDone(int)));
connect(importer,SIGNAL(importError(QString)),this,SLOT(importError(QString)));
connect(importer,SIGNAL(wrongCredentials()),this,SLOT(wrongCredentials()));
ui->labelImport->setMovie(spinner);
importer->import(ui->user->text(), ui->password->text());
}