forked from Michael33881/adbLink
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrestdialog.cpp
174 lines (109 loc) · 3.55 KB
/
restdialog.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
#include "restdialog.h"
#include "ui_restdialog.h"
#include <QProcess>
#include <QFile>
#include <QString>
#include <QMessageBox>
#include <QStringList>
#include <QTextStream>
#ifdef Q_OS_LINUX
int os_restore=0;
#elif defined(Q_OS_WIN)
int os_restore=1;
#elif defined(Q_OS_MAC)
int os_restore=2;
#endif
QString data_root_restore;
QString tmpdir_restore;
QString adb_restore;
QString partition_restore;
///////////////////////////////////////////////
QString RunProcess_restore(QString cstring)
{
QProcess run_command;
run_command.setProcessChannelMode(QProcess::MergedChannels);
run_command.start(cstring);
run_command.waitForStarted();
while(run_command.state() != QProcess::NotRunning)
qApp->processEvents();
QString command=run_command.readAll();
return command;
}
restDialog::restDialog(QWidget *parent) :
QDialog(parent),
ui(new Ui::restDialog)
{
ui->setupUi(this);
if (os_restore == 1)
{
tmpdir_restore = "./";
//adb_restore = tmpdir_restore+"adb.exe";
}
else
{
tmpdir_restore = QCoreApplication::applicationDirPath()+"/adbfiles/";
//adb_restore = tmpdir_restore+"adb";
}
}
restDialog::~restDialog()
{
delete ui;
}
void restDialog::on_listDirectories_restore_clicked()
{
data_root_restore = ui->listDirectories_restore->currentItem()->text();
}
void restDialog::setadb_restore(const QString &adb_restore)
{
QString command;
QString cstring;
QString mounted;
QString fline;
cstring=adb_restore+" shell /data/local/tmp/adblink/busybox find /storage/ -type d -maxdepth 2 -perm 0771";
command=RunProcess_restore(cstring);
//QMessageBox::information(0,"",cstring);
QFile file21(tmpdir_restore+"temp.txt");
if(!file21.open(QFile::WriteOnly))
{
QMessageBox::critical(this,"","Error creating file!");
return;
}
QTextStream out1(&file21);
out1 << command << endl;
file21.flush();
file21.close();
QString tmpstr2 = tmpdir_restore+"temp.txt";
QString fline2;
QFile file32(tmpstr2);
if (!file32.open(QIODevice::ReadOnly | QIODevice::Text))
{QMessageBox::critical(0,"","Error reading file!");
return; }
QTextStream in1(&file32);
ui->listDirectories_restore->addItem("/sdcard/");
while (!in1.atEnd())
{
fline2 = in1.readLine();
if( (!fline2.contains("Android"))
&& (!fline2.contains("."))
&& (!fline2.contains("Permission denied"))
&& (!fline2.contains("emulated"))
&& (!fline2.isEmpty())
) // endif
{
ui->listDirectories_restore->addItem(fline2+"/");
}
}
file32.close();
QFile::remove(tmpstr2);
ui->listDirectories_restore->setCurrentRow(0);
data_root_restore = ui->listDirectories_restore->currentItem()->text();
}
QString restDialog::restore_data_root() {
return data_root_restore;
}
QString restDialog::on_listDirectories_restore_doubleClicked()
{
data_root_restore = ui->listDirectories_restore->currentItem()->text();
return data_root_restore;
restDialog::accept();
}