-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathipodconversationrecorvermainwindowsapp.cpp
320 lines (253 loc) · 8.35 KB
/
ipodconversationrecorvermainwindowsapp.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
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
#include "ipodconversationrecorvermainwindowsapp.h"
#include "ui_ipodconversationrecorvermainwindowsapp.h"
#include <QtGui>
#include "helpwindows.h"
#include "tohtmldialog.h"
#include "itunesmsdialog.h"
#ifdef _WIN32
QString stringOS = "WIN32";
#endif
#ifdef __APPLE__
QString stringOS = "APPLE";
#endif
#ifdef __linux__
QString stringOS = "WIN32";
#endif
IpodConversationRecorverMainWindowsApp::IpodConversationRecorverMainWindowsApp(QWidget *parent, QSqlDatabase db) :
QMainWindow(parent),
ui(new Ui::IpodConversationRecorverMainWindowsApp)
{
ui->setupUi(this);
db_windwso2 = db;
query_windows2 = new QSqlQuery(db_windwso2);
sqlitedb = QSqlDatabase::addDatabase("QSQLITE", "dateFile");
query_sqlitedb = new QSqlQuery(sqlitedb);
ui->widget->hide();
ui->ContactList->hide();
ui->ConversationView->hide();
ui->lableConvPres->hide();
ui->labelContenu->hide();
ui->actionTo_html_format->setEnabled(false);
ui->actionChoose_the_file->setShortcut(Qt::CTRL+Qt::Key_O);
ui->actionDownload_a_File_from_server->setShortcut(Qt::CTRL+Qt::Key_D);
ui->actionQuit->setShortcut(Qt::CTRL+Qt::Key_Q);
ui->actionUpload_File_To_server->setShortcut(Qt::CTRL+Qt::Key_U );
ui->actionPreferences->setShortcut(Qt::CTRL+Qt::Key_P);
}
void IpodConversationRecorverMainWindowsApp::getUserInfo()
{
}
void IpodConversationRecorverMainWindowsApp::on_actionTo_html_format_triggered()
{
ToHtmlDialog *htmldialog = new ToHtmlDialog(this, sqlitedb);
htmldialog->show();
}
void IpodConversationRecorverMainWindowsApp::on_actionChoose_the_file_triggered()
{
QString path_toFile = QFileDialog::getOpenFileName(this,"Ouvrir");
QFile file(path_toFile);
if (file.fileName().contains(".db", Qt::CaseInsensitive))
{
IpodConversationRecorverMainWindowsApp::VerifyFile(path_toFile);
}
else
{
QMessageBox::critical(this, "Erreur", "Pour focntionner le format doit etre .db");
ui->actionTo_html_format->setEnabled(false);
}
}
void IpodConversationRecorverMainWindowsApp::VerifyFile(QString db_file)
{
sqlitedb.setDatabaseName(db_file);
int valid = 0;
if (sqlitedb.open())
{
query_sqlitedb->clear();
query_sqlitedb->prepare("SELECT * FROM madrid_chat;");
if (query_sqlitedb->exec())
{
valid = 0;
query_sqlitedb->prepare("SELECT * FROM message;");
if (query_sqlitedb->exec())
{
valid = 0;
query_sqlitedb->prepare("SELECT * FROM group_member;");
if (query_sqlitedb->exec())
{
valid = 0;
query_sqlitedb->prepare("SELECT * FROM madrid_attachment;");
if (query_sqlitedb->exec())
{
valid = 0;
}
else
{
valid = 1;
}
}
else
{
valid = 1;
}
}
else
{
valid = 1;
}
}
else
{
valid = 1;
}
}
if (valid)
{
QMessageBox::critical(this, "Fichier Invalide", "Le fichier que vous avez entre n'est pas utilisable !");
ui->actionTo_html_format->setEnabled(false);
}
else
{
IpodConversationRecorverMainWindowsApp::Get_Conv_List();
ui->textBrowser->hide();
ui->ContactList->show();
ui->ConversationView->show();
ui->labelContenu->show();
ui->lableConvPres->show();
ui->actionTo_html_format->setEnabled(true);
}
sqlitedb.close();
}
void IpodConversationRecorverMainWindowsApp::Get_Conv_List()
{
if (sqlitedb.open())
{
query_sqlitedb->clear();
query_sqlitedb->prepare("SELECT * FROM madrid_chat;");
if (query_sqlitedb->exec())
{
while(query_sqlitedb->next())
{
QVariant test2 = query_sqlitedb->value(5);
ui->ContactList->addItem(test2.toString());
}
}
else
{
QMessageBox::information(this, "Erreur", "Une erreur s'est produite, le fichier est peut etre endomage \n" + query_sqlitedb->lastError().text());
}
}
else
{
QMessageBox::information(this, "Erreur", "Une erreur s'est produite, le fichier est peut etre endomage \n" + query_sqlitedb->lastError().text());
}
sqlitedb.close();
}
void IpodConversationRecorverMainWindowsApp::on_ContactList_clicked()
{
QString currentSelection = ui->ContactList->currentItem()->text();
IpodConversationRecorverMainWindowsApp::GetConversations(currentSelection);
}
void IpodConversationRecorverMainWindowsApp::on_actionDonate_triggered()
{
HelpWindows *b = new HelpWindows(this, "Don");
b->show();
}
void IpodConversationRecorverMainWindowsApp::on_actionHelp_triggered()
{
HelpWindows *b = new HelpWindows(this, "hel");
b->show();
}
void IpodConversationRecorverMainWindowsApp::on_actionUpdates_triggered()
{
}
void IpodConversationRecorverMainWindowsApp::on_actionVersions_triggered()
{
HelpWindows *b = new HelpWindows(this, "vers");
b->show();
}
void IpodConversationRecorverMainWindowsApp::on_actionAbout_triggered()
{
HelpWindows *b = new HelpWindows(this, "Abo");
b->show();
}
void IpodConversationRecorverMainWindowsApp::GetConversations(QString contact)
{
ui->widget->show();
ui->ConversationView->clear();
if (sqlitedb.open())
{
query_sqlitedb->clear();
query_sqlitedb->prepare("SELECT COUNT(*) AS nb_field FROM message WHERE madrid_handle = ?");
query_sqlitedb->addBindValue(contact);
int testintforhqdfbsdf = 0;
if (query_sqlitedb->exec())
{
while(query_sqlitedb->next())
{
testintforhqdfbsdf = query_sqlitedb->record().value("nb_field").toInt();
qDebug() << query_sqlitedb->record().value("nb_field");
}
}
ui->Progress->setMinimum(0);
ui->Progress->setMaximum(testintforhqdfbsdf);
query_sqlitedb->clear();
query_sqlitedb->prepare("SELECT * FROM message WHERE madrid_handle = ? ORDER BY ROWID");
query_sqlitedb->addBindValue(contact);
if (query_sqlitedb->exec())
{
int iteratorcanevol = 0;
QString FullLine = " ";
int x = 3;
int x2 = 31;
int totallines = 0;
while(query_sqlitedb->next())
{
if ( query_sqlitedb->value(x2) == "0")
{
QString toAppend = "<p>" + query_sqlitedb->value(x).toString() + "</p>";
qDebug() << "deux :" << query_sqlitedb->value(x).toString() ;
FullLine += toAppend;
iteratorcanevol++;
totallines++;
}
else
{
QString ToAppend = "<p align='right'>" + query_sqlitedb->value(x).toString() + "</p>";
qDebug() << query_sqlitedb->value(x).toString() ;
FullLine += ToAppend;
iteratorcanevol++;
totallines++;
}
ui->Progress->setValue(iteratorcanevol);
}
FullLine += "</body></html>";
ui->ConversationView->insertHtml(FullLine);
ui->widget->hide();
qDebug() << totallines;
}
else
{
QMessageBox::critical(this, "Erreur", "Impossile d'ourvire la base ... querry \n" + query_sqlitedb->lastError().text());
}
}
else
{
QMessageBox::critical(this, "Erreur", "Impossile d'ourvire la base ... \n" + query_sqlitedb->lastError().text());
}
}
void IpodConversationRecorverMainWindowsApp::on_actionSMS_db_from_an_Itune_Save_triggered()
{
if (stringOS == "LINUX")
{
QMessageBox::information(this, "Attention !", "Cette fonctionalite n'est pas disponnible pour les Systeme Linux\n (temps que Itune n'existe pas pour Linux)");
}
else
{
ItuneSMSDialog *SMSItunes = new ItuneSMSDialog(this);
SMSItunes->show();
}
}
IpodConversationRecorverMainWindowsApp::~IpodConversationRecorverMainWindowsApp()
{
delete ui;
}