diff --git a/Changes.txt b/Changes.txt new file mode 100644 index 0000000..65f1a7e --- /dev/null +++ b/Changes.txt @@ -0,0 +1,36 @@ +What is different from current official build 0.8.1: + +Files Page: + -double click on phone file (both panes) opens file in PC with the associated program for that extension with option to edit the file and save it back to phone; + -added "Properties" in phone files/folders right click context menu with permissions changing capabilities; + -switching left pane between PC/phone files now remembers last folder view for both; + -left paths combo box now works for phone files too when switching left pane to phone files; + +Apps Page: + -major speedup displaying apps after the initial first run when apps info is collected; + -fixed all functions, now all buttons and actions works as they should; + -now you can backup and restore apps and data to any folder on /sdcard or PC, set backup folder location in Settings first; + -option added to Backups context menu to add app/data if missing from existing previous backup; + +New CWM Page replaces current Recovery Page if CWM Recovery is installed on phone and detected. If CWM Recovery is not detected, the current Recovery Page is used. What can be done in the New CWM Page: + -run fix_permissions in Android OS mode, not in recovery mode. As you may know fix_permissions in CWM recovery is broken; + -Fix/Undo Fix Market Cache Download; + -Flash new Recovery; + -Mount/Unmount any partition in recovery mode, Remount /system with read-write/read-only access in Android OS mode; + -Repartitioning SD Card with /sd-ext partition (your choice of size and type) with option to backup /sdcard content before, and restoring it after the operation; + -Wipe data/factory reset, cache, dalvik-cache, battery stats (your choice) in recovery mode; + -Install zip of your choice from /sdcard; + -Backup ROM to any folder on /sdcard or to default CWM location with option for Backup md5 sum validation after phone reboots back to Android OS, ensures proper backup is done; + -Restore nandroid Backup with option to choose which partitions to restore(select all for full restore) and preliminary md5 sum validation for double safety; + -One click Update ROM function which wipes cache and dalvik-cache before flashing. If Link2SD is detected on your phone you have an option to automatically copy its sd-ext mount script from current ROM to the new updated ROM saving you one reboot. Link2SD will not even know you updated the ROM; + -One click ROM Flash with full wipe and options to install zips before/after(or both) the flash - this procedure reboots phone to Recovery, wipes dalvik-cache, formats /boot, /system, /data and /cache partitions, installs zip before(if selected), installs the new ROM, installs zip after(if selected) and reboots back to Android OS. + + Detailed information in Status Window is displayed for all operations taking place in real time. After phone reboots back to Android OS, the last CWM recovery log is displayed so you can spot any errors occurred during the last operation. + +And probably something else I forgot about; + +All bugs fixed(I believe). + +I want to thank and give credits to the guys (couldn't find their names) created some of the tools I'm using to make the new features works. + + \ No newline at end of file diff --git a/QtADB.pro b/QtADB.pro index a1e5807..1436757 100644 --- a/QtADB.pro +++ b/QtADB.pro @@ -53,7 +53,9 @@ SOURCES += main.cpp \ classes/models/logcatmodel.cpp \ classes/ecwin7.cpp \ classes/mytableview.cpp \ - dialogs/registerdialog.cpp + dialogs/registerdialog.cpp \ + dialogs/fipdialog.cpp \ + widgets/cwmwidget.cpp HEADERS += ./dialogs/mainwindow.h \ ./dialogs/dialogkopiuj.h \ ./classes/phone.h \ @@ -86,7 +88,9 @@ HEADERS += ./dialogs/mainwindow.h \ classes/models/logcatmodel.h \ classes/ecwin7.h \ classes/mytableview.h \ - dialogs/registerdialog.h + dialogs/registerdialog.h \ + dialogs/fipdialog.h \ + widgets/cwmwidget.h FORMS += ./dialogs/mainwindow.ui \ ./dialogs/dialogkopiuj.ui \ ./dialogs/connectWifi.ui \ @@ -104,7 +108,9 @@ FORMS += ./dialogs/mainwindow.ui \ widgets/messagewidget.ui \ widgets/contactwidget.ui \ dialogs/logcatdialog.ui \ - dialogs/registerdialog.ui + dialogs/registerdialog.ui \ + dialogs/fipdialog.ui \ + widgets/cwmwidget.ui RC_FILE = ikonka.rc RESOURCES += zasoby.qrc OTHER_FILES += otherFiles/changes.txt diff --git a/QtADB.pro.user b/QtADB.pro.user index d4c736e..011dd78 100644 --- a/QtADB.pro.user +++ b/QtADB.pro.user @@ -1,4 +1,6 @@ + + ProjectExplorer.Project.ActiveTarget @@ -7,166 +9,313 @@ ProjectExplorer.Project.EditorSettings - true - false - System - false - false - 4 - true - 1 - true - false - true - 0 - 8 - true - 1 - true - true - true - false + true + false + + Cpp + + CppGlobal + + + + QmlJS + + QmlJSGlobal + + + 2 + System + false + 4 + true + 1 + true + 0 + true + 0 + 8 + true + 1 + true + true + true + false + + ProjectExplorer.Project.PluginSettings + + ProjectExplorer.Project.Target.0 - Desktop - Desktop - Qt4ProjectManager.Target.DesktopTarget - 1 - 0 - 0 - - ProjectExplorer.ToolChain.Mingw:C:/QtSDK/mingw/bin/g++.exe.x86-windows-msys-pe-32bit.C:/QtSDK/pythongdb/python_2.7based/gdb-i686-pc-mingw32.exe - - - qmake - - QtProjectManager.QMakeBuildStep - false - - false + Desktop + Desktop + Qt4ProjectManager.Target.DesktopTarget + 0 + 0 + 0 + + ProjectExplorer.ToolChain.Mingw:D:/Downloads/QtSDK/mingw/bin/mingw32-g++.exe.x86-windows-msys-pe-32bit.D:/Downloads/QtSDK/pythongdb/python_2.7based/gdb-i686-pc-mingw32.exe + + + qmake + + QtProjectManager.QMakeBuildStep + false + true + + false + + + Make + + Qt4ProjectManager.MakeStep + false + + D:/Downloads/QtSDK/mingw/bin/mingw32-make.exe - - Make - - Qt4ProjectManager.MakeStep - false - - + 2 + Build + + ProjectExplorer.BuildSteps.Build + + + + Make + + Qt4ProjectManager.MakeStep + true + clean + + + + + %{buildDir}/del_Makefile.bat + true + %{buildDir} + Custom Process Step + + ProjectExplorer.ProcessStep - 2 - Build - - ProjectExplorer.BuildSteps.Build + 2 + Clean + + ProjectExplorer.BuildSteps.Clean - - - Make - - Qt4ProjectManager.MakeStep - true - clean - + 2 + false + + Qt 4.7.4 for Desktop - MinGW 4.4 (Qt SDK) Release + + Qt4ProjectManager.Qt4BuildConfiguration + 0 + D:/Downloads/IE9 Downloads/Optimus V/APK Tools/Projects/QtADB-build-desktop-Qt_4_7_4_for_Desktop_-_MinGW_4_4__Qt_SDK__Release + 2 + false + + + ProjectExplorer.ToolChain.Mingw:D:/Downloads/QtSDK/mingw/bin/mingw32-g++.exe.x86-windows-msys-pe-32bit.D:/Downloads/QtSDK/pythongdb/python_2.7based/gdb-i686-pc-mingw32.exe + + + qmake + + QtProjectManager.QMakeBuildStep + false + true + + false + + + Make + + Qt4ProjectManager.MakeStep + false + + + + 2 + Build + + ProjectExplorer.BuildSteps.Build + + + + Make + + Qt4ProjectManager.MakeStep + true + clean + + + + + %{buildDir}/del_Makefile.bat + true + %{buildDir} + Custom Process Step + + ProjectExplorer.ProcessStep - 1 - Clean - - ProjectExplorer.BuildSteps.Clean + 2 + Clean + + ProjectExplorer.BuildSteps.Clean - 2 - false - - Qt 4.7.3 for Desktop - MinGW 4.4 (Qt SDK) Debug - - Qt4ProjectManager.Qt4BuildConfiguration - 2 - C:/Users/7ymekk/Documents/Qt/QtADB/QtADB-build-desktop - 2 - ProjectExplorer.ToolChain.Mingw:C:/QtSDK/mingw/bin/g++.exe.x86-windows-msys-pe-32bit.C:/QtSDK/pythongdb/python_2.7based/gdb-i686-pc-mingw32.exe - true + 2 + false + + Qt 4.7.4 for Desktop - MinGW 4.4 (Qt SDK) Debug + + Qt4ProjectManager.Qt4BuildConfiguration + 2 + D:/Downloads/QtSDK/Projects/cwm_edition-debug + 2 + true - - ProjectExplorer.ToolChain.Mingw:C:/QtSDK/mingw/bin/g++.exe.x86-windows-msys-pe-32bit.C:/QtSDK/pythongdb/python_2.7based/gdb-i686-pc-mingw32.exe - - - qmake - - QtProjectManager.QMakeBuildStep - false - - false + + ProjectExplorer.ToolChain.Mingw:D:/Downloads/QtSDK/mingw/bin/mingw32-g++.exe.x86-windows-msys-pe-32bit.D:/Downloads/QtSDK/pythongdb/python_2.7based/gdb-i686-pc-mingw32.exe + + + qmake + + QtProjectManager.QMakeBuildStep + false + true + + false - - Make - - Qt4ProjectManager.MakeStep - false - - jom + + Make + + Qt4ProjectManager.MakeStep + false + + - 2 - Build - - ProjectExplorer.BuildSteps.Build + 2 + Build + + ProjectExplorer.BuildSteps.Build - - - Make - - Qt4ProjectManager.MakeStep - true - clean - jom + + + Make + + Qt4ProjectManager.MakeStep + true + clean + - 1 - Clean - - ProjectExplorer.BuildSteps.Clean + 1 + Clean + + ProjectExplorer.BuildSteps.Clean - 2 - false - - Qt 4.7.3 for Desktop - MinGW 4.4 (Qt SDK) Release - - Qt4ProjectManager.Qt4BuildConfiguration - 0 - C:/Users/7ymekk/Documents/Qt/QtADB/QtADB-build-desktop - 2 - ProjectExplorer.ToolChain.Mingw:C:/QtSDK/mingw/bin/g++.exe.x86-windows-msys-pe-32bit.C:/QtSDK/pythongdb/python_2.7based/gdb-i686-pc-mingw32.exe - true + 2 + false + + Qt 4.7.4 for Desktop - MinGW 4.4 (Qt SDK) Release2 + + Qt4ProjectManager.Qt4BuildConfiguration + 0 + + 2 + true - 2 - - - 0 - Deploy - - ProjectExplorer.BuildSteps.Deploy + 3 + + + 0 + Deploy + + ProjectExplorer.BuildSteps.Deploy - 1 - No deployment - - ProjectExplorer.DefaultDeployConfiguration + 1 + No deployment + + ProjectExplorer.DefaultDeployConfiguration - 1 - - QtADB - - Qt4ProjectManager.Qt4RunConfiguration - 2 - - QtADB.pro - false - false - - - 3768 - true - false + 1 + + true + true + + + false + false + false + false + false + false + false + false + true + true + 0.01 + 0.01 + 10 + 10 + true + true + 25 + 25 + + + true + true + valgrind + valgrind + + 0 + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + 11 + 12 + 13 + 14 + + + 0 + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + 11 + 12 + 13 + 14 + + QtADB + + Qt4ProjectManager.Qt4RunConfiguration + 2 + + QtADB.pro + false + false + + + 3768 + true + false + false - 1 + 1 @@ -175,10 +324,10 @@ ProjectExplorer.Project.Updater.EnvironmentId - {dd80744a-d175-44cb-8a31-c3f9c7983630} + {8beb4f91-a657-4601-9314-0dd80f1fd840} ProjectExplorer.Project.Updater.FileVersion - 9 + 10 diff --git a/classes/computer.cpp b/classes/computer.cpp index 0c6537f..bc81972 100644 --- a/classes/computer.cpp +++ b/classes/computer.cpp @@ -253,5 +253,4 @@ bool Computer::deleteDir(QString dirName) } return !error; - } diff --git a/classes/models/apptablemodel.cpp b/classes/models/apptablemodel.cpp index 1e10a5e..7d88f3d 100644 --- a/classes/models/apptablemodel.cpp +++ b/classes/models/apptablemodel.cpp @@ -120,11 +120,11 @@ QVariant AppTableModel::data(const QModelIndex &index, int role) const case 1: return QVariant(Qt::AlignLeft | Qt::AlignVCenter); case 2: - return QVariant(Qt::AlignLeft | Qt::AlignVCenter); + return QVariant(Qt::AlignCenter | Qt::AlignVCenter); case 3: return QVariant(Qt::AlignRight | Qt::AlignVCenter); case 4: - return QVariant(Qt::AlignLeft | Qt::AlignVCenter); + return QVariant(Qt::AlignCenter | Qt::AlignVCenter); case 5: return QVariant(Qt::AlignLeft | Qt::AlignVCenter); case 6: @@ -149,13 +149,15 @@ QVariant AppTableModel::data(const QModelIndex &index, int role) const tmp = tmp.left(15)+"..."; return tmp; case 3: - return AppTableModel::humanReadableSize(app.appSize); + tmp = AppTableModel::humanReadableSize(app.appSize) + " "; + return tmp; case 4: - return app.packageName; + return app.location; case 5: - return app.appFile; + return app.packageName; case 6: - return app.location; + tmp = " " + app.appFile; + return tmp; default: return QVariant(); } @@ -163,8 +165,12 @@ QVariant AppTableModel::data(const QModelIndex &index, int role) const else if (role == Qt::BackgroundColorRole) { App app = this->appList.at(index.row()); - if (app.appVersion < app.cyrketVer) + if (app.appVersion < app.cyrketVer && app.cyrketVer.contains("Varies with device")) return QVariant::fromValue(QBrush(Qt::green, Qt::SolidPattern)); + else if (app.cyrketVer.contains("app not found on Android Market")) + { + return QVariant::fromValue(QBrush(Qt::yellow, Qt::SolidPattern)); + } } return QVariant(); @@ -180,17 +186,17 @@ QVariant AppTableModel::headerData(int section, Qt::Orientation orientation, int case 0: return ""; case 1: - return tr("Name", "application table name"); + return tr("app Name", "application table name"); case 2: - return tr("Version", "application table version"); + return tr("app Version", "application table version"); case 3: - return tr("Size", "applications table size"); + return tr("app Size", "applications table size"); case 4: - return tr("Package", "application table package"); + return tr("app Location", "application table location"); case 5: - return tr("File", "application table file"); + return tr("app Package Name", "application table package"); case 6: - return tr("Location", "application table location"); + return tr("app File Path", "application table file"); default: return QVariant(); } @@ -231,13 +237,13 @@ bool AppTableModel::setData(const QModelIndex &index, const QVariant &value, int app.appSize = value.toString(); break; case 4: - app.packageName = value.toString(); + app.location = value.toString(); break; case 5: - app.appFile = value.toString(); + app.packageName = value.toString(); break; case 6: - app.location = value.toString(); + app.appFile = value.toString(); break; default: return false; @@ -488,3 +494,4 @@ bool AppSortModel::lessThan(const QModelIndex &left, const QModelIndex &right) c return leftName.toLower() < rightName.toLower(); } } + diff --git a/classes/models/backuptablemodel.cpp b/classes/models/backuptablemodel.cpp index 5fbd6af..2c34e4a 100644 --- a/classes/models/backuptablemodel.cpp +++ b/classes/models/backuptablemodel.cpp @@ -110,13 +110,13 @@ QVariant BackupTableModel::data(const QModelIndex &index, int role) const case 1: return QVariant(Qt::AlignLeft | Qt::AlignVCenter); case 2: - return QVariant(Qt::AlignLeft | Qt::AlignVCenter); + return QVariant(Qt::AlignCenter | Qt::AlignVCenter); case 3: return QVariant(Qt::AlignRight | Qt::AlignVCenter); case 4: - return QVariant(Qt::AlignLeft | Qt::AlignVCenter); + return QVariant(Qt::AlignCenter | Qt::AlignVCenter); case 5: - return QVariant(Qt::AlignLeft | Qt::AlignVCenter); + return QVariant(Qt::AlignCenter | Qt::AlignVCenter); case 6: return QVariant(Qt::AlignLeft | Qt::AlignVCenter); default: @@ -139,19 +139,20 @@ QVariant BackupTableModel::data(const QModelIndex &index, int role) const tmp = tmp.left(15)+"..."; return tmp; case 3: - return BackupTableModel::humanReadableSize(backup.appSize); + tmp = BackupTableModel::humanReadableSize(backup.appSize) + " "; + return tmp; case 4: - return backup.packageName; - case 5: if (backup.withApk) - return QString(tr("yes")); + return QString(tr("YES")); else - return QString(tr("no")); - case 6: + return QString(tr("NO")); + case 5: if (backup.withData) - return QString(tr("yes")); + return QString(tr("YES")); else - return QString(tr("no")); + return QString(tr("NO")); + case 6: + return backup.packageName; default: return QVariant(); } @@ -170,17 +171,17 @@ QVariant BackupTableModel::headerData(int section, Qt::Orientation orientation, case 0: return ""; case 1: - return tr("Name", "backup table header app name"); + return tr("app Name", "backup table header app name"); case 2: - return tr("Version", "backup table header app version"); + return tr("app Version", "backup table header app version"); case 3: - return tr("Size", "backup table header app size"); + return tr("app Size", "backup table header app size"); case 4: - return tr("Package", "backup table header app package"); + return tr("app Backed up?", "backup table header apk file"); case 5: - return tr("App", "backup table header apk file"); + return tr("data Backed up?", "backup table header data"); case 6: - return tr("Data", "backup table header data"); + return tr("app Package Name", "backup table header app package"); default: return QVariant(); } @@ -221,13 +222,13 @@ bool BackupTableModel::setData(const QModelIndex &index, const QVariant &value, backup.appSize = value.toString(); break; case 4: - backup.packageName = value.toString(); + backup.withApk = value.toBool(); break; case 5: - backup.withApk = value.toBool(); + backup.withData = value.toBool(); break; case 6: - backup.withData = value.toBool(); + backup.packageName = value.toString(); break; default: return false; diff --git a/classes/models/filetablemodel.cpp b/classes/models/filetablemodel.cpp index a140cf8..06a70df 100644 --- a/classes/models/filetablemodel.cpp +++ b/classes/models/filetablemodel.cpp @@ -541,4 +541,3 @@ bool FileSortModel::lessThan(const QModelIndex &left, const QModelIndex &right) return leftName.toLower() < rightName.toLower(); } } - diff --git a/classes/models/messagethreadmodel.cpp b/classes/models/messagethreadmodel.cpp index 927a8db..8275b69 100644 --- a/classes/models/messagethreadmodel.cpp +++ b/classes/models/messagethreadmodel.cpp @@ -115,8 +115,8 @@ MessageThread MessageThreadModel::getThread(QString threadId) return MessageThread(); } -QString MessageThreadModel::getThreadID(QString number) -{ +//QString MessageThreadModel::getThreadID(QString number) +//{ /* foreach (MessageThread thread, this->threads) { @@ -125,7 +125,7 @@ QString MessageThreadModel::getThreadID(QString number) } return MessageThread(); */ -} +//} void MessageThreadModel::updateThread(QString id, QString timestamp,QString lastBody, QString messageCount, QString read) { diff --git a/classes/mytableview.cpp b/classes/mytableview.cpp index 23f9a04..9c86627 100644 --- a/classes/mytableview.cpp +++ b/classes/mytableview.cpp @@ -76,12 +76,22 @@ void MyTableView::mousePressEvent(QMouseEvent *event) this->selectRow(index.row()); else { - for (int i=0; i< list.size(); i++) - this->selectionModel()->select(list.at(i), QItemSelectionModel::Select); - for (int i=0; ifileModel.columnCount(QModelIndex()); i++) - this->selectionModel()->select(this->model()->index(index.row(),i, QModelIndex()), QItemSelectionModel::Select); + if (list.size() == 1) + { + for (int i=0; i< list.size(); i++) + this->selectionModel()->select(list.at(i), QItemSelectionModel::Clear); + for (int i=0; ifileModel.columnCount(QModelIndex()); i++) + this->selectionModel()->select(this->model()->index(index.row(),i, QModelIndex()), QItemSelectionModel::Select); + } + else + { + for (int i=0; i< list.size(); i++) + this->selectionModel()->select(list.at(i), QItemSelectionModel::Select); + for (int i=0; ifileModel.columnCount(QModelIndex()); i++) + this->selectionModel()->select(this->model()->index(index.row(),i, QModelIndex()), QItemSelectionModel::Select); + } } - emit customContextMenuRequested(event->pos()); + // emit customContextMenuRequested(event->pos()); } } diff --git a/classes/mytableview.h b/classes/mytableview.h index 1b327df..12d0380 100644 --- a/classes/mytableview.h +++ b/classes/mytableview.h @@ -23,6 +23,7 @@ #include #include +//#include #include "../classes/models/filetablemodel.h" class MyTableView : public QTableView @@ -41,7 +42,6 @@ class MyTableView : public QTableView void mousePressEvent(QMouseEvent *event); // void mouseReleaseEvent(QMouseEvent *event); // void mouseMoveEvent(QMouseEvent *event); - signals: public slots: diff --git a/classes/phone.cpp b/classes/phone.cpp index 217f984..76ebdc3 100644 --- a/classes/phone.cpp +++ b/classes/phone.cpp @@ -97,7 +97,7 @@ Phone::Phone(QString sdk,bool isThreadNecessary) qDebug()<<"Phone::Phone - sdk="<sdk; fastboot.setProcessChannelMode(QProcess::MergedChannels); - fastboot.start("\"" + this->sdk + "\"adb remount"); + fastboot.start("\"" + this->sdk + "\"adb shell mount -o remount,rw /system"); fastboot.waitForFinished(); qDebug()<<"Phone::Phone - adb start-server: "< *Phone::getFileList() qDebug()<getPath(); if (this->hiddenFiles) - command="\""+this->sdk+"\""+"adb shell \"busybox ls -l -a \'"+this->codec->toUnicode(this->getPath().toUtf8())+"\'\""; + command="\""+this->sdk+"\""+"adb shell ls -l -a \""+this->codec->toUnicode(this->getPath().toUtf8())+"\""; else - command="\""+this->sdk+"\""+"adb shell \"busybox ls -l \'"+this->codec->toUnicode(this->getPath().toUtf8())+"\'\""; + command="\""+this->sdk+"\""+"adb shell ls -l \""+this->codec->toUnicode(this->getPath().toUtf8())+"\""; qDebug()<<"Phone::getFileList() - "<start(command); @@ -326,6 +326,7 @@ QList *Phone::getFileList() tmpFile.fileName = QString::fromUtf8(name.toAscii()); tmpFile.filePath = this->getPath() + tmpFile.fileName; + qDebug()<<"fileName = QString::fromUtf8(name.toAscii());"< *Phone::getFileList() else if (lineParts.first()[0]=='-'||lineParts.first()[0]=='s') tmpFile.fileType = "file"; else if (lineParts.first()[0]=='l') + { tmpFile.fileType = "link"; + tmpFile.fileName = tmpFile.fileName.left(tmpFile.fileName.indexOf("->")-1); + tmpFile.filePath = this->getPath() + tmpFile.fileName; + } else if (lineParts.first()[0]=='c'||lineParts.first()[0]=='b'||lineParts.first()[0]=='p') tmpFile.fileType = "device"; @@ -342,6 +347,7 @@ QList *Phone::getFileList() name.remove(QString("%1[0m").arg( QChar( 0x1b ))); name.remove(QChar( 0x1b ), Qt::CaseInsensitive); name.remove(QRegExp("\\[\\d;\\d+m")); + if (tmpFile.fileType == "file" || tmpFile.fileType == "device") { plik.setFileName(QDir::currentPath()+"/tmp/"+name); @@ -388,9 +394,9 @@ QList *Phone::getFileList(QString filter) qDebug()<getPath(); if (this->hiddenFiles) - command="\""+this->sdk+"\""+"adb shell \"busybox ls -l -a \'"+this->codec->toUnicode(this->getPath().toUtf8())+"\' | grep \'" + filter + "\'\""; + command="\""+this->sdk+"\""+"adb shell ls -l -a \""+this->codec->toUnicode(this->getPath().toUtf8())+"\" | grep \"" + filter + "\""; else - command="\""+this->sdk+"\""+"adb shell \"busybox ls -l \'"+this->codec->toUnicode(this->getPath().toUtf8())+"\' | grep \'" + filter + "\'\""; + command="\""+this->sdk+"\""+"adb shell ls -l \""+this->codec->toUnicode(this->getPath().toUtf8())+"\" | grep \"" + filter + "\""; qDebug()<<"Phone::getFileList() - "<start(command); @@ -573,9 +579,9 @@ FileList *Phone::getStaticFileList(QString path, QString sdk, bool hiddenFiles) qDebug()<toUnicode(path.toAscii())+"\'\""; + command="\""+sdk+"\""+"adb shell ls -l -a \""+codec->toUnicode(path.toAscii())+"\""; else - command="\""+sdk+"\""+"adb shell \"busybox ls -l \'"+codec->toUnicode(path.toAscii())+"\'\""; + command="\""+sdk+"\""+"adb shell ls -l \""+codec->toUnicode(path.toAscii())+"\""; qDebug()<<"Phone::getFileList() - "<start(command); @@ -696,7 +702,7 @@ bool Phone::makeDir(QString newDir) QString command; newDir.prepend(this->getPath()); - command="\""+this->sdk+"\""+"adb shell busybox mkdir \""+this->codec->toUnicode(newDir.toUtf8())+"\""; + command="\""+this->sdk+"\""+"adb shell mkdir \""+this->codec->toUnicode(newDir.toUtf8())+"\""; phone->start(command); phone->waitForReadyRead(-1); @@ -804,7 +810,7 @@ bool Phone::remove(QString name) phone->setProcessChannelMode(QProcess::MergedChannels); QString command; - command="\""+this->sdk+"\""+"adb shell busybox rm -r "+"\""+this->codec->toUnicode(this->getPath().toUtf8())+ + command="\""+this->sdk+"\""+"adb shell rm -r \""+this->codec->toUnicode(this->getPath().toUtf8())+ this->codec->toUnicode(name.toUtf8())+"\""; phone->start(command); @@ -828,7 +834,7 @@ bool Phone::rename(QString oldName, QString newName) phone->setProcessChannelMode(QProcess::MergedChannels); QString command; - command="\""+this->sdk+"\""+"adb shell busybox mv \""+this->codec->toUnicode(this->getPath().toUtf8())+this->codec->toUnicode(oldName.toUtf8())+ + command="\""+this->sdk+"\""+"adb shell mv \""+this->codec->toUnicode(this->getPath().toUtf8())+this->codec->toUnicode(oldName.toUtf8())+ "\" \""+this->codec->toUnicode(this->getPath().toUtf8())+this->codec->toUnicode(newName.toUtf8())+"\""; phone->start(command); @@ -916,7 +922,7 @@ QStringList Phone::getGoogleAccounts() QString output; QSettings settings; sdk = settings.value("sdkPath").toString(); - QString operation = "\""+sdk+"\""+ "adb shell busybox grep gmail-ls /data/system/sync/accounts.xml"; + QString operation = "\""+sdk+"\""+ "adb shell grep gmail-ls /data/system/sync/accounts.xml"; // QString operation = "\""+sdk+"\""+ "adb shell su -c 'busybox grep gmail-ls /data/system/sync/accounts.xml'"; //su -c 'busybox grep gmail-ls /data/system/sync/accounts.xml' QProcess *proces=new QProcess; @@ -927,7 +933,7 @@ QStringList Phone::getGoogleAccounts() delete proces; if (output.contains("permission") && !output.contains("account"))//////////////////////////////zmeinic { - operation = "\""+sdk+"\""+ "adb shell su -c 'busybox grep gmail-ls /data/system/sync/accounts.xml'"; + operation = "\""+sdk+"\""+ "adb shell su -c 'grep gmail-ls /data/system/sync/accounts.xml'"; proces = new QProcess; proces->start(operation); proces->waitForFinished(-1); @@ -951,7 +957,7 @@ QString Phone::getIp() {//? (192.168.2.1) at d8:5d:4c:de:85:94 [ether] on tiwlan0 QProcess *proces=new QProcess; QSettings settings; - proces->start("\"" + settings.value("sdkPath").toString() + "\"adb shell busybox arp"); + proces->start("\"" + settings.value("sdkPath").toString() + "\"adb shell arp"); QString tmp; proces->waitForFinished(-1); tmp = proces->readAll(); @@ -965,7 +971,7 @@ QString Phone::getIp() tmp.remove(0,tmp.lastIndexOf(" ")); tmp.remove("\n"); - proces->start("\"" + settings.value("sdkPath").toString() + "\"adb shell busybox ifconfig "+tmp); + proces->start("\"" + settings.value("sdkPath").toString() + "\"adb shell ifconfig "+tmp); proces->waitForFinished(-1); tmp = proces->readAll(); tmp.remove(QRegExp(".*inet addr:")); diff --git a/classes/updateapp.cpp b/classes/updateapp.cpp index 79f9982..137c4d5 100644 --- a/classes/updateapp.cpp +++ b/classes/updateapp.cpp @@ -73,5 +73,5 @@ void UpdateApp::gotWWW(QNetworkReply * pReply) void UpdateApp::checkUpdates() { - this->reply = this->updateMan->get(QNetworkRequest(QUrl("http://qtadb.com/wordpress/download"))); + this->reply = this->updateMan->get(QNetworkRequest(QUrl("http://qtadb.wordpress.com/download/"))); } diff --git a/dialogs/aboutdialog.cpp b/dialogs/aboutdialog.cpp index c6b9252..1f93b97 100644 --- a/dialogs/aboutdialog.cpp +++ b/dialogs/aboutdialog.cpp @@ -25,6 +25,8 @@ AboutDialog::AboutDialog(QWidget *parent) : { setupUi(this); this->setLayout(this->gridLayout); + this->setFixedSize(this->width(),this->height()); + setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint); QString version = QCoreApplication::applicationVersion(); this->versionLabel->setText(version); diff --git a/dialogs/aboutdialog.ui b/dialogs/aboutdialog.ui index 6691931..826b2b1 100644 --- a/dialogs/aboutdialog.ui +++ b/dialogs/aboutdialog.ui @@ -28,12 +28,15 @@ Qt::LeftToRight + + true + -10 0 - 417 + 446 208 @@ -131,7 +134,7 @@ Qt::LeftToRight - 2010-07-07 + 2012-03-14 diff --git a/dialogs/appdialog.cpp b/dialogs/appdialog.cpp index 56d7277..68a6206 100644 --- a/dialogs/appdialog.cpp +++ b/dialogs/appdialog.cpp @@ -26,6 +26,8 @@ appDialog::appDialog(QWidget *parent,QList appList, int operation, int mode ui(new Ui::appDialog) { QSettings settings; + // this->setFixedSize(this->width(),this->height()); + setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint); ui->setupUi(this); this->end=false; this->setWindowTitle(operation+" window"); @@ -96,7 +98,8 @@ appDialog::appDialog(QWidget *parent,QList appList, int operation, int mode { this->setWindowTitle(tr("Restore apps and data")); ui->label->setText(tr("Restore apps and data")); - }this->restore(); + } + this->restore(); } this->timer->start(50); this->clock->start(100); @@ -178,7 +181,8 @@ appDialog::appDialog(QList appList, int operation, int mode) : { this->setWindowTitle(tr("Restore apps and data")); ui->label->setText(tr("Restore apps and data", "label text")); - }this->restore(); + } + this->restore(); } this->timer->start(50); this->clock->start(100); @@ -241,7 +245,7 @@ void appDialog::closeEvent(QCloseEvent *event) } else { - if (QMessageBox::question(this, tr("Cancel operation??"), tr("Are you sure You want to cancel operation??"), QMessageBox::Yes | QMessageBox::No) == QMessageBox::No) + if (QMessageBox::question(this, tr("Cancel operation?"), tr("Are you sure you want to cancel operation??"), QMessageBox::Yes | QMessageBox::No) == QMessageBox::No) { event->ignore(); } @@ -424,89 +428,159 @@ void ThreadBackup::run() { QTextCodec *codec = QTextCodec::codecForLocale(); QProcess *proces = new QProcess; - QString output; + QString output, iconfile; QSettings settings; + QString backuponpc; + bool onsdcard; + QString appsBackupFolder = settings.value("appsBackupFolder").toString(); QByteArray ba; App app; - proces->start("\"" + this->sdk + "\"" + "adb shell busybox mkdir /sdcard/QtADB/backup"); + if (!appsBackupFolder.contains("/sdcard/")) + { + backuponpc = appsBackupFolder.append("/"); + appsBackupFolder = "/sdcard/tmpAppsBackup/"; + onsdcard = false; + qDebug()<<"1----------Backup app on PC - "<start("\"" + this->sdk + "\"" + "adb shell mkdir \"" + codec->toUnicode(appsBackupFolder.toUtf8()) +"\""); proces->waitForFinished(-1); qDebug()<<"mkdir - "<readAll(); while (this->appList.size() > 0) { app = this->appList.takeFirst(); -// name = this->appList.name.takeFirst(); -// package = this->appList.package.takeFirst(); -// file = this->appList.filename.takeFirst(); -// size = this->appList.size.takeFirst(); -// version = this->appList.version.takeFirst(); - + proces->start("\"" + this->sdk + "\"" + "adb shell mkdir \"" + codec->toUnicode(appsBackupFolder.toUtf8()) + codec->toUnicode(app.appName.append("/").toUtf8())+"\""); + proces->waitForFinished(-1); emit this->nextApp(app); - proces->start("\""+this->sdk+"\""+"adb shell echo -e \"app.name="+codec->toUnicode(app.appName.toUtf8())+"\" > /sdcard/QtADB/backup/"+app.packageName+".txt"); + proces->start("\""+this->sdk+"\""+"adb shell echo -e \"app.name="+codec->toUnicode(app.appName.left(app.appName.size()-1).toUtf8())+"\" > \""+ codec->toUnicode(appsBackupFolder.toUtf8())+codec->toUnicode(app.appName.toUtf8())+codec->toUnicode(app.packageName.toUtf8())+".txt\""); proces->waitForFinished(-1); - proces->start("\""+this->sdk+"\""+"adb shell echo -e \"app.size="+app.appSize+"\" >> /sdcard/QtADB/backup/"+app.packageName+".txt"); + proces->start("\""+this->sdk+"\""+"adb shell echo -e \"app.size="+app.appSize+"\" >> \""+ codec->toUnicode(appsBackupFolder.toUtf8())+codec->toUnicode(app.appName.toUtf8())+codec->toUnicode(app.packageName.toUtf8())+".txt\""); proces->waitForFinished(-1); - proces->start("\""+this->sdk+"\""+"adb shell echo -e \"app.version="+app.appVersion+"\" >> /sdcard/QtADB/backup/"+app.packageName+".txt"); + proces->start("\""+this->sdk+"\""+"adb shell echo -e \"app.version="+app.appVersion+"\" >> \""+ codec->toUnicode(appsBackupFolder.toUtf8())+codec->toUnicode(app.appName.toUtf8())+codec->toUnicode(app.packageName.toUtf8())+".txt\""); proces->waitForFinished(-1); ba = settings.value("apps/"+app.packageName+"/icon").toByteArray(); - QFile ikona(QDir::currentPath()+"/icons/"+app.packageName+".png"); + if (onsdcard == false) + { + QDir dir; + dir.mkdir(codec->toUnicode(backuponpc.toUtf8())+codec->toUnicode(app.appName.toUtf8())); + iconfile = codec->toUnicode(backuponpc.toUtf8())+codec->toUnicode(app.appName.append("/").toUtf8())+codec->toUnicode(app.packageName.toUtf8())+".png"; + } + else + iconfile = QDir::currentPath()+"/tmp/"+codec->toUnicode(app.packageName.toUtf8())+".png"; + QFile ikona(iconfile); if (ikona.open(QIODevice::WriteOnly)) { ikona.write(ba); } ikona.close(); - proces->start("\""+this->sdk+"\""+"adb push \""+QDir::currentPath()+"/icons/"+app.packageName+".png\" /sdcard/QtADB/backup/"); + if (onsdcard == true) + { + proces->start("\""+this->sdk+"\""+"adb push \""+QDir::currentPath()+"/tmp/"+codec->toUnicode(app.packageName.toUtf8())+".png\" \""+ codec->toUnicode(appsBackupFolder.toUtf8())+codec->toUnicode(app.appName.toUtf8())+codec->toUnicode(app.packageName.toUtf8())+".png\""); proces->waitForFinished(-1); output = proces->readAll(); - qDebug()<<"Backup app - "<withData) { - proces->start("\""+this->sdk+"\""+"adb shell tar -zcf /sdcard/QtADB/backup/"+app.packageName+".DATA.tar.gz /data/data/"+app.packageName); + proces->start("\""+this->sdk+"\""+"adb shell tar -zchf \"" + codec->toUnicode(appsBackupFolder.toUtf8())+codec->toUnicode(app.appName.toUtf8())+codec->toUnicode(app.packageName.toUtf8())+".DATA.tar.gz\" \"/data/data/"+codec->toUnicode(app.packageName.toUtf8())+"\""); proces->waitForFinished(-1); output = proces->readAll(); qDebug()<<"Backup app - "<withApk) { - proces->start("\""+this->sdk+"\""+"adb shell cp "+app.appFile+ " /sdcard/QtADB/backup/"+app.packageName+".apk"); + if (onsdcard == false) + proces->start("\""+this->sdk+"\""+"adb pull \""+codec->toUnicode(app.appFile.toUtf8())+ "\" \"" + codec->toUnicode(backuponpc.toUtf8())+codec->toUnicode(app.appName.toUtf8())+codec->toUnicode(app.packageName.toUtf8())+".apk\""); + else + proces->start("\""+this->sdk+"\""+"adb shell cp \""+codec->toUnicode(app.appFile.toUtf8())+ "\" \"" + codec->toUnicode(appsBackupFolder.toUtf8())+codec->toUnicode(app.appName.toUtf8())+codec->toUnicode(app.packageName.toUtf8())+".apk\""); proces->waitForFinished(-1); output = proces->readAll(); qDebug()<<"Backup app - "<start("\""+this->sdk+"\""+"adb pull \""+codec->toUnicode(appsBackupFolder.toUtf8())+"\" \""+ codec->toUnicode(backuponpc.toUtf8())+"\""); + proces->waitForFinished(-1); + output = proces->readAll(); + qDebug()<<"Backup app - adb pull "<start("\""+this->sdk+"\""+"adb shell rm -r \""+codec->toUnicode(appsBackupFolder.toUtf8()) + codec->toUnicode(app.appName.toUtf8())+"\""); + proces->waitForFinished(-1); + output = proces->readAll(); + qDebug()<<"Backup app - rm -r "<backedUp(tr("SUCCESS"), ""); } + if (onsdcard == false) + { + proces->start("\""+this->sdk+"\""+"adb shell rm -r \""+codec->toUnicode(appsBackupFolder.toUtf8())+"\""); + proces->waitForFinished(-1); + output = proces->readAll(); + qDebug()<<"Backup app - rm -r "<backedUp("finished", ""); return; } void ThreadRestore::run() { + QTextCodec *codec = QTextCodec::codecForLocale(); QProcess *proces = new QProcess; QString output, userId; App app; + QSettings settings; + QString backuponpc, namedir; + bool onsdcard; + QString appsBackupFolder = settings.value("appsBackupFolder").toString(); + if (!appsBackupFolder.contains("/sdcard/")) + { + backuponpc = appsBackupFolder.append("/"); + appsBackupFolder = "/sdcard/tmpAppsBackup/"; + proces->start("\"" + this->sdk + "\"" + "adb shell mkdir \"" + codec->toUnicode(appsBackupFolder.toUtf8()) +"\""); + proces->waitForFinished(-1); + qDebug()<<"mkdir /sdcard/tmpAppsBackup/ - "<readAll(); + onsdcard = false; + qDebug()<<"1----------Backup app on PC - "<appList.size() > 0) { // package = this->appList.package.takeFirst(); app = this->appList.takeFirst(); emit this->nextApp(app); + namedir = app.appName.append("/"); + if (onsdcard == false) + { + proces->start("\"" + this->sdk + "\"" + "adb shell mkdir \"" + codec->toUnicode(appsBackupFolder.toUtf8()) + codec->toUnicode(namedir.toUtf8())+"\""); + proces->waitForFinished(-1); + qDebug()<<"mkdir /sdcard/tmpAppsBackup/appName/ - "<readAll(); + } if (this->withApk) { - proces->start("\""+this->sdk+"\""+"adb shell pm install /sdcard/QtADB/backup/" +app.packageName + ".apk"); + if (onsdcard == false) + { + proces->start("\""+this->sdk+"\""+"adb push \"" + codec->toUnicode(backuponpc.toUtf8()) + codec->toUnicode(namedir.toUtf8()) +codec->toUnicode(app.packageName.toUtf8()) + ".apk\" \""+codec->toUnicode(appsBackupFolder.toUtf8()) + codec->toUnicode(namedir.toUtf8()) + "\""); + proces->waitForFinished(-1); + } + proces->start("\""+this->sdk+"\""+"adb shell pm install \"" + codec->toUnicode(appsBackupFolder.toUtf8()) + codec->toUnicode(namedir.toUtf8()) +codec->toUnicode(app.packageName.toUtf8()) + ".apk\""); proces->waitForFinished(-1); output = proces->readAll(); qDebug()<<"Restore pm - "<start("\""+this->sdk+"\""+"adb shell cp /sdcard/QtADB/backup/" +app.packageName + ".apk /data/local/tmp/"); + proces->start("\""+this->sdk+"\""+"adb shell cp \"" + codec->toUnicode(appsBackupFolder.toUtf8()) + codec->toUnicode(namedir.toUtf8()) +codec->toUnicode(app.packageName.toUtf8()) + ".apk\" /data/local/tmp/"); proces->waitForFinished(-1); output = proces->readAll(); qDebug()<<"Restore cp - "<start("\""+this->sdk+"\""+"adb shell pm install /data/local/tmp/" +app.packageName + ".apk"); + proces->start("\""+this->sdk+"\""+"adb shell pm install /data/local/tmp/" +codec->toUnicode(app.packageName.toUtf8()) + ".apk"); proces->waitForFinished(-1); output = proces->readAll(); qDebug()<<"Restore pm - "<start("\""+this->sdk+"\""+"adb shell busybox rm -f /data/local/tmp/" +app.packageName + ".apk"); + proces->start("\""+this->sdk+"\""+"adb shell rm -f /data/local/tmp/" +codec->toUnicode(app.packageName.toUtf8()) + ".apk"); proces->waitForFinished(-1); } if (output.contains("Failure")) @@ -519,15 +593,20 @@ void ThreadRestore::run() { if (this->withData) { - proces->start("\""+this->sdk+"\""+"adb shell busybox rm -rf /data/data/"+app.packageName); + proces->start("\""+this->sdk+"\""+"adb shell rm -rf /data/data/"+codec->toUnicode(app.packageName.toUtf8())); proces->waitForFinished(-1); output = proces->readAll(); qDebug()<<"Restore rm - "<start("\""+this->sdk+"\""+"adb shell busybox tar -xzf /sdcard/QtADB/backup/"+app.packageName+".DATA.tar.gz -C /"); + if (onsdcard == false) + { + proces->start("\""+this->sdk+"\""+"adb push \"" + codec->toUnicode(backuponpc.toUtf8()) + codec->toUnicode(namedir.toUtf8()) +codec->toUnicode(app.packageName.toUtf8()) + ".DATA.tar.gz\" \""+codec->toUnicode(appsBackupFolder.toUtf8()) + codec->toUnicode(namedir.toUtf8()) + "\""); + proces->waitForFinished(-1); + } + proces->start("\""+this->sdk+"\""+"adb shell tar -xzf \""+codec->toUnicode(appsBackupFolder.toUtf8()) + codec->toUnicode(namedir.toUtf8()) +codec->toUnicode(app.packageName.toUtf8())+".DATA.tar.gz\" -C /"); proces->waitForFinished(-1); output = proces->readAll(); qDebug()<<"Restore tar - "<start("\""+this->sdk+"\""+"adb shell \"cat /data/system/packages.xml|busybox grep '^start("\""+this->sdk+"\""+"adb shell \"cat /data/system/packages.xml | grep '^toUnicode(app.packageName.toUtf8())+"'\""); proces->waitForFinished(-1); output = proces->readAll(); qDebug()<<"Restore cat - "< 7) { userId = output.mid(start, output.indexOf("\"", start) - start); - proces->start("\""+this->sdk+"\""+"adb shell busybox chown -R "+userId+":"+userId+" /data/data/"+app.packageName); + proces->start("\""+this->sdk+"\""+"adb shell chown -R "+userId+":"+userId+" /data/data/"+codec->toUnicode(app.packageName.toUtf8())); proces->waitForFinished(-1); output = proces->readAll(); qDebug()<<"Restore chown - "<start("\""+this->sdk+"\""+"adb shell busybox chmod -R 775 /data/data/"+app.packageName); + proces->start("\""+this->sdk+"\""+"adb shell chmod -R 775 /data/data/"+codec->toUnicode(app.packageName.toUtf8())); proces->waitForFinished(-1); output = proces->readAll(); qDebug()<<"Restore chmod - "<withData) { - proces->start("\""+this->sdk+"\""+"adb shell busybox rm -rf /data/data/"+app.packageName); + proces->start("\""+this->sdk+"\""+"adb shell rm -rf /data/data/"+codec->toUnicode(app.packageName.toUtf8())); proces->waitForFinished(-1); output = proces->readAll(); qDebug()<<"Restore rm - "<start("\""+this->sdk+"\""+"adb shell busybox tar -xzf /sdcard/QtADB/backup/"+app.packageName+".DATA.tar.gz -C /"); + if (onsdcard == false) + { + proces->start("\""+this->sdk+"\""+"adb push \"" + codec->toUnicode(backuponpc.toUtf8()) + codec->toUnicode(namedir.toUtf8()) +codec->toUnicode(app.packageName.toUtf8()) + ".DATA.tar.gz\" \""+codec->toUnicode(appsBackupFolder.toUtf8()) + codec->toUnicode(namedir.toUtf8()) + "\""); + proces->waitForFinished(-1); + } + proces->start("\""+this->sdk+"\""+"adb shell tar -xzf \""+codec->toUnicode(appsBackupFolder.toUtf8()) + codec->toUnicode(namedir.toUtf8()) +codec->toUnicode(app.packageName.toUtf8())+".DATA.tar.gz\" -C /"); proces->waitForFinished(-1); output = proces->readAll(); qDebug()<<"Restore tar - "<start("\""+this->sdk+"\""+"adb shell \"cat /data/system/packages.xml|busybox grep '^start("\""+this->sdk+"\""+"adb shell \"cat /data/system/packages.xml | grep '^toUnicode(app.packageName.toUtf8())+"'\""); proces->waitForFinished(-1); output = proces->readAll(); qDebug()<<"Restore cat - "< 7) { userId = output.mid(start, output.indexOf("\"", start) - start); - proces->start("\""+this->sdk+"\""+"adb shell busybox chown -R "+userId+":"+userId+" /data/data/"+app.packageName); + proces->start("\""+this->sdk+"\""+"adb shell chown -R "+userId+":"+userId+" /data/data/"+codec->toUnicode(app.packageName.toUtf8())); proces->waitForFinished(-1); output = proces->readAll(); qDebug()<<"Restore chown - "<start("\""+this->sdk+"\""+"adb shell busybox chmod -R 775 /data/data/"+app.packageName); + proces->start("\""+this->sdk+"\""+"adb shell chmod -R 775 /data/data/"+codec->toUnicode(app.packageName.toUtf8())); proces->waitForFinished(-1); output = proces->readAll(); qDebug()<<"Restore chmod - "<restored(tr("FAILURE"), ""); } } + if (onsdcard == false) + { + proces->start("\""+this->sdk+"\""+"adb shell rm -r \"" + codec->toUnicode(appsBackupFolder.toUtf8()) + codec->toUnicode(namedir.toUtf8())+"\""); + proces->waitForFinished(-1); + output = proces->readAll(); + qDebug()<<"Backup app - rm -r "<start("\""+this->sdk+"\""+"adb shell rm -r \""+codec->toUnicode(appsBackupFolder.toUtf8())+"\""); + proces->waitForFinished(-1); + output = proces->readAll(); + qDebug()<<"Backup app - rm -r "<restored("finished", ""); } void ThreadInstall::run() { + QTextCodec *codec = QTextCodec::codecForLocale(); QProcess *proces = new QProcess; QString output; @@ -603,7 +702,7 @@ void ThreadInstall::run() // file = this->appList.package.takeFirst(); app = this->appList.takeFirst(); emit this->nextApp(app); - QString cmd = "\""+this->sdk+"\""+"adb install " + (this->reinstall ? "-r " : "") + "\""+app.appFile+"\""; + QString cmd = "\""+this->sdk+"\""+"adb install " + (this->reinstall ? "-r " : "") + "\""+codec->toUnicode(app.appFile.toUtf8())+"\""; proces->start(cmd); proces->waitForFinished(-1); output = proces->readAll(); @@ -623,6 +722,7 @@ void ThreadInstall::run() void ThreadUninstall::run() { + QTextCodec *codec = QTextCodec::codecForLocale(); QString output; QProcess *proces = new QProcess; @@ -639,25 +739,25 @@ void ThreadUninstall::run() if (this->system) { - proces->start("\""+this->sdk+"\""+"adb remount"); + proces->start("\""+this->sdk+"\""+"adb shell mount -o remount,rw /system"); proces->waitForFinished(-1); output = proces->readAll(); qDebug()<<"Remove system - "<keepData) { - proces->start("\""+this->sdk+"\""+"adb shell busybox rm -rf /data/data/"+app.packageName); + proces->start("\""+this->sdk+"\""+"adb shell rm -rf /data/data/"+codec->toUnicode(app.packageName.toUtf8())); proces->waitForFinished(-1); output = proces->readAll(); qDebug()<<"Remove system - "<start("\""+this->sdk+"\""+"adb shell busybox rm -rf "+app.appFile); + proces->start("\""+this->sdk+"\""+"adb shell rm -rf "+app.appFile); } else { if (this->keepData) - proces->start("\""+this->sdk+"\""+"adb uninstall -k "+app.packageName); + proces->start("\""+this->sdk+"\""+"adb uninstall -k "+codec->toUnicode(app.packageName.toUtf8())); else - proces->start("\""+this->sdk+"\""+"adb uninstall "+app.packageName); + proces->start("\""+this->sdk+"\""+"adb uninstall "+codec->toUnicode(app.packageName.toUtf8())); } proces->waitForFinished(-1); output = proces->readAll(); @@ -676,6 +776,11 @@ void ThreadUninstall::run() { emit this->uninstalled(tr("SUCCESS"), ""); } + if (this->system) + { + proces->start("\""+this->sdk+"\""+"adb shell mount -o remount,ro,noatime /system"); + proces->waitForFinished(-1); + } } delete proces; emit this->uninstalled("finished", ""); diff --git a/dialogs/appdialog.ui b/dialogs/appdialog.ui index 6179bfb..d444fa1 100644 --- a/dialogs/appdialog.ui +++ b/dialogs/appdialog.ui @@ -13,6 +13,9 @@ + + true + diff --git a/dialogs/appinfo.cpp b/dialogs/appinfo.cpp index bb12762..cd714d9 100644 --- a/dialogs/appinfo.cpp +++ b/dialogs/appinfo.cpp @@ -30,13 +30,47 @@ appInfo::appInfo(QWidget *parent, App *app) : this->setLayout(this->ui->gridLayout); this->resize(350, 280); this->setFixedHeight(280); + //this->setFixedSize(this->width(),this->height()); + setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint); this->app = app; this->app->packageName.remove(QRegExp("\\s+$")); ui->labelAppsIcon->setPixmap(this->app->appIcon.pixmap(100,100)); ui->editAppsAppName->setText(this->app->appName); ui->editAppsVersion->setText(this->app->appVersion); - ui->editAppsSize->setText(this->app->appSize); + // ui->editAppsSize->setText(this->app->appSize); + QString strTmp = " KB"; + long double sizeTmp = 0.0; + sizeTmp = this->app->appSize.toLongLong(); + if (sizeTmp <= 1024) + { + strTmp.prepend(QString::number(sizeTmp, 'f', 0)); + ui->editAppsSize->setText(strTmp); + strTmp = ""; + } + if (sizeTmp > 1024) + { + sizeTmp = sizeTmp / 1024; + strTmp = " KB"; + } + if (sizeTmp > 1024) + { + sizeTmp = sizeTmp / 1024; + strTmp = " MB"; + } + if (sizeTmp > 1024) + { + sizeTmp = sizeTmp / 1024; + strTmp = " GB"; + } + if (!strTmp.isEmpty()) + { + strTmp.prepend(QString::number(sizeTmp, 'f', 3)); + ui->editAppsSize->setText(strTmp); + } + + + ui->editAppsFileName->setText(this->app->appFile); ui->editAppsPackageName->setText(this->app->packageName); @@ -49,7 +83,7 @@ appInfo::appInfo(QWidget *parent, App *app) : QSettings settings; sdk = settings.value("sdkPath").toString(); QProcess proc; - proc.start("\"" + sdk + "\"adb shell busybox ls /data/app/" + proc.start("\"" + sdk + "\"adb shell ls /data/app/" + this->app->packageName + "*"); proc.waitForFinished(-1); QString output = proc.readAll(); @@ -81,7 +115,38 @@ appInfo::appInfo(App *app) : ui->labelAppsIcon->setPixmap(this->app->appIcon.pixmap(100,100)); ui->editAppsAppName->setText(this->app->appName); ui->editAppsVersion->setText(this->app->appVersion); - ui->editAppsSize->setText(this->app->appSize); + // ui->editAppsSize->setText(this->app->appSize); + QString strTmp = " KB"; + long double sizeTmp = 0.0; + sizeTmp = this->app->appSize.toLongLong(); + if (sizeTmp <= 1024) + { + strTmp.prepend(QString::number(sizeTmp, 'f', 0)); + ui->editAppsSize->setText(strTmp); + strTmp = ""; + } + if (sizeTmp > 1024) + { + sizeTmp = sizeTmp / 1024; + strTmp = " KB"; + } + if (sizeTmp > 1024) + { + sizeTmp = sizeTmp / 1024; + strTmp = " MB"; + } + if (sizeTmp > 1024) + { + sizeTmp = sizeTmp / 1024; + strTmp = " GB"; + } + if (!strTmp.isEmpty()) + { + strTmp.prepend(QString::number(sizeTmp, 'f', 3)); + ui->editAppsSize->setText(strTmp); + } + + ui->editAppsFileName->setText(this->app->appFile); ui->editAppsPackageName->setText(this->app->packageName); @@ -94,7 +159,7 @@ appInfo::appInfo(App *app) : QSettings settings; sdk = settings.value("sdkPath").toString(); QProcess proc; - proc.start("\"" + sdk + "\"adb shell busybox ls /data/app/" + proc.start("\"" + sdk + "\"adb shell ls /data/app/" + this->app->packageName + "*"); proc.waitForFinished(-1); QString output = proc.readAll(); @@ -107,6 +172,7 @@ appInfo::appInfo(App *app) : connect(this->ui->pushButton, SIGNAL(clicked()), this, SLOT(install())); connect(this->ui->pushButton_2, SIGNAL(clicked()), this, SLOT(openMarket())); + connect(this->ui->pushButton_3, SIGNAL(clicked()), this, SLOT(openMarketPC())); connect(this->updateMan, SIGNAL(finished(QNetworkReply*)), this, SLOT(gotWWW(QNetworkReply*))); this->getQR(); @@ -119,6 +185,7 @@ appInfo::~appInfo() delete this->appsDialog; delete this->app; delete this->reply; + delete ui; } @@ -128,7 +195,7 @@ void appInfo::install() appList.append(*this->app); // selected.package.append(this->app->appFile); - if (QMessageBox::question(this,this->reinstall ? tr("reinstall") : tr("install"),tr("are you sure???"),QMessageBox::Ok | QMessageBox::No) == QMessageBox::No) + if (QMessageBox::question(this,this->reinstall ? tr("Reinstall:") : tr("Install:"),tr("Are you sure???"),QMessageBox::Ok | QMessageBox::No) == QMessageBox::No) return; if (this->appsDialog != NULL) @@ -158,14 +225,22 @@ void appInfo::openMarket() sdk = settings.value("sdkPath").toString(); QProcess proc; proc.start("\"" + sdk + "\"adb shell am start -a android.intent.action.VIEW -d market://details?id=" - + this->app->packageName + " -n com.android.vending/.AssetInfoActivity"); + + this->ui->editAppsPackageName->text() + " -n com.android.vending/.AssetBrowserActivity"); proc.waitForFinished(-1); + QString out = proc.readAll(); + if (out.contains("Error")) + { + proc.start("\"" + sdk + "\"adb shell am start -a android.intent.action.VIEW -d market://details?id=" + + this->ui->editAppsPackageName->text() + " -n com.android.vending/com.google.android.finsky.activities.PlayLauncherActivity"); + proc.waitForFinished(-1); + } + qDebug()<<"adb shell am start -a android.intent.action.VIEW -d market://details?id="<app->packageName<<" -n com.android.vending/.AssetBrowserActivity"; } QPixmap appInfo::getQR(QString packageName) { QNetworkAccessManager *nac = new QNetworkAccessManager; - QNetworkReply *rep = nac->get(QNetworkRequest(QUrl("http://qrcode.kaywa.com/img.php?s=2&d=market://details?id=" + packageName))); + QNetworkReply *rep = nac->get(QNetworkRequest(QUrl("https://qrcode.kaywa.com/img.php?s=2&d=market://details?id=" + packageName))); while (true) { qApp->processEvents(); @@ -183,34 +258,48 @@ QPixmap appInfo::getQR(QString packageName) } QString appInfo::getCyrketVer(QString packageName) + { QNetworkAccessManager *nac = new QNetworkAccessManager; - QNetworkReply *rep = nac->get(QNetworkRequest(QUrl("http://market.android.com/details?id=" + packageName))); - while (true) - { - qApp->processEvents(); - if (rep->isFinished()) - break; - } + QNetworkReply *rep = nac->get(QNetworkRequest(QUrl("https://play.google.com/store/apps/details?id=" + packageName))); + // qDebug()<<"packageName = "<1.0
readAll(); + // qDebug()<<"ba = "<"); + int start = ba.indexOf("Current Version:
"); // start = ba.indexOf("
", start); // start+=5; if (start != -1) { - start+=22; - int end = ba.indexOf(" App info + + true + diff --git a/dialogs/connectWifi.cpp b/dialogs/connectWifi.cpp index 6ac31ce..5724af5 100644 --- a/dialogs/connectWifi.cpp +++ b/dialogs/connectWifi.cpp @@ -26,6 +26,8 @@ ConnectWifi::ConnectWifi( QWidget * parent, Qt::WFlags f) setupUi(this); this->setLayout(this->gridLayout); this->setBaseSize(220,100); + this->setFixedSize(this->width(),this->height()); + setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint); this->polaczButton->setDefault(true); connect(polaczButton,SIGNAL(clicked()),this,SLOT(accept())); connect(zamknijButton,SIGNAL(clicked()),this,SLOT(reject())); diff --git a/dialogs/connectWifi.h b/dialogs/connectWifi.h index bf71d04..10f58e9 100644 --- a/dialogs/connectWifi.h +++ b/dialogs/connectWifi.h @@ -32,7 +32,7 @@ Q_OBJECT public: ConnectWifi( QWidget * parent = 0, Qt::WFlags f = 0 ); }; -#endif +#endif // POLACZ_H diff --git a/dialogs/connectWifi.ui b/dialogs/connectWifi.ui index 87ac65e..6138d41 100644 --- a/dialogs/connectWifi.ui +++ b/dialogs/connectWifi.ui @@ -22,6 +22,9 @@ + + true + diff --git a/dialogs/dialogkopiuj.cpp b/dialogs/dialogkopiuj.cpp index 9094980..ef0d8b8 100644 --- a/dialogs/dialogkopiuj.cpp +++ b/dialogs/dialogkopiuj.cpp @@ -28,6 +28,8 @@ dialogKopiuj::dialogKopiuj(QWidget *parent, QList *fileList, QString sdk, ui(new Ui::dialogKopiuj) { ui->setupUi(this); + this->setFixedSize(this->width(),this->height()); + setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint); this->sourcePath = sourcePath; this->targetPath = targetPath; this->mode = mode; @@ -63,7 +65,10 @@ dialogKopiuj::dialogKopiuj(QWidget *parent, QList *fileList, QString sdk, connect(this->threadCopy, SIGNAL(nextFile(QString, QString, QString, int, int)), this, SLOT(nextFile(QString, QString, QString, int, int))); connect(this->threadCopy, SIGNAL(copied()), this, SLOT(copied())); + connect(this->threadCopy, SIGNAL(isRunning()), this, SLOT(running())); connect(this->ui->buttonCancel, SIGNAL(clicked()), this, SLOT(close())); + //my new OK button + connect(this->ui->buttonCopyOK, SIGNAL(clicked()), this, SLOT(close())); // connect(this->threadProgress, SIGNAL(progressValue(int)), this->ui->progressFile, SLOT(setValue(int))); connect(this->threadProgress, SIGNAL(progressValue(int)), this, SLOT(setProgressValue(int))); @@ -105,7 +110,10 @@ dialogKopiuj::dialogKopiuj(QWidget *parent, QList *appList, QString sdk, in connect(this->threadCopy, SIGNAL(nextFile(QString, QString, QString, int, int)), this, SLOT(nextFile(QString, QString, QString, int, int))); connect(this->threadCopy, SIGNAL(copied()), this, SLOT(copied())); + connect(this->threadCopy, SIGNAL(isRunning()), this, SLOT(running())); connect(this->ui->buttonCancel, SIGNAL(clicked()), this, SLOT(close())); + //my new OK button + connect(this->ui->buttonCopyOK, SIGNAL(clicked()), this, SLOT(close())); // connect(this->threadProgress, SIGNAL(progressValue(int)), this->ui->progressFile, SLOT(setValue(int))); connect(this->threadProgress, SIGNAL(progressValue(int)), this, SLOT(setProgressValue(int))); @@ -124,27 +132,30 @@ dialogKopiuj::~dialogKopiuj() void dialogKopiuj::closeEvent(QCloseEvent *event) { - if (!this->opFinished) + if (!this->opFinished) //copy in progress { - if (QMessageBox::question(this, tr("Close??"), tr("Are you sure??"), QMessageBox::Yes | QMessageBox::No) == QMessageBox::No) + if (QMessageBox::question(this, tr("Close?"), tr("Are you sure??"), QMessageBox::Yes | QMessageBox::No) == QMessageBox::No) // No pressed { - event->ignore(); + event->ignore(); //copy continues } - else + else // Yes pressed { + // Abort copy, dialog closed + this->setProgressValue(NULL); this->threadCopy->proces->kill(); this->threadCopy->terminate(); - this->threadProgress->terminate(); - delete this->threadCopy; this->threadCopy = NULL; - delete this->threadProgress; + delete this->threadCopy; + this->threadProgress->terminate(); this->threadProgress = NULL; + delete this->threadProgress; event->accept(); + emit copyCanceled(); } } - else + else // copy finished { - this->accept(); + this->accept(); // dialog closed } } @@ -155,11 +166,19 @@ void dialogKopiuj::closeAfterFinished() void dialogKopiuj::copied() { + this->ui->buttonCancel->setDisabled(true); + this->ui->buttonCopyOK->setDisabled(false); this->opFinished = true; if (this->ui->checkBox->isChecked()) this->close(); } +void dialogKopiuj::running() +{ + //this->ui->buttonCancel->setDisabled(false); + this->ui->buttonCopyOK->setDisabled(true); +} + void dialogKopiuj::nextFile(QString fileName, QString sourcePath, QString targetPath, int fileSize, int counter) { qDebug()<<"Copy,nextFile() - START"; @@ -210,6 +229,9 @@ void ThreadCopy::run() int fileSize, counter = 0; File file; App app; + emit this->isRunning(); + // Ui::dialogKopiuj ui; + // Ui::dialogKopiuj()->buttonCopyOK->setDisabled(true); // QProcess *proces; QTextCodec *codec = QTextCodec::codecForLocale(); @@ -233,8 +255,7 @@ void ThreadCopy::run() tmp.remove(sourceDir); emit this->nextFile(tmp, sourceDir, targetDir, fileSize, counter); dialogKopiuj::fileRemove(this->targetPath+fileName, this->mode); - command = "\""+sdk+"\""+"adb pull \""+codec->toUnicode(file.filePath.toUtf8())+"\" "+"\""+ - this->targetPath+fileName+"\""; + command = "\""+sdk+"\""+"adb pull \""+codec->toUnicode(file.filePath.toUtf8())+"\" \""+codec->toUnicode(this->targetPath.toUtf8())+codec->toUnicode(fileName.toUtf8())+"\""; qDebug()<<"Copy - "<start(command); proces->waitForFinished(-1); @@ -274,9 +295,7 @@ void ThreadCopy::run() emit this->nextFile(fileName, sourceDir, targetDir, fileSize, counter); dialogKopiuj::fileRemove(codec->toUnicode(this->targetPath.toUtf8())+ codec->toUnicode(fileName.toUtf8()), this->mode); - command = "\""+sdk+"\""+"adb push \""+file.filePath+"\" "+"\""+ - codec->toUnicode(this->targetPath.toUtf8())+ - codec->toUnicode(fileName.toUtf8())+"\""; + command = "\""+sdk+"\""+"adb push \""+codec->toUnicode(file.filePath.toUtf8())+"\" \""+codec->toUnicode(this->targetPath.toUtf8())+ codec->toUnicode(fileName.toUtf8())+"\""; qDebug()<<"Copy - "<kill(); qDebug()<<"Copy - process killed"; @@ -310,14 +329,14 @@ void ThreadCopy::run() emit this->nextFile(file.fileName, sourceDir, targetDir, fileSize, counter); if (fileName.contains("/")) { - proces->start("\""+sdk+"\""+"adb shell busybox mkdir \""+ codec->toUnicode(this->targetPath.toUtf8()) + proces->start("\""+sdk+"\""+"adb shell mkdir \""+ codec->toUnicode(this->targetPath.toUtf8()) +codec->toUnicode(fileName.left(fileName.lastIndexOf("/")).toUtf8())+"\""); proces->waitForFinished(-1); output = proces->readAll(); qDebug()<<"Copy - "<toUnicode(this->targetPath.toUtf8())+codec->toUnicode(fileName.toUtf8()), this->mode); - command = "\""+sdk+"\""+"adb shell cp \""+codec->toUnicode(file.filePath.toUtf8())+"\" "+"\""+ + command = "\""+sdk+"\""+"adb shell cp \""+codec->toUnicode(file.filePath.toUtf8())+"\" \""+ codec->toUnicode(this->targetPath.toUtf8())+codec->toUnicode(fileName.toUtf8())+"\""; qDebug()<<"Copy - "<start(command); @@ -352,8 +371,8 @@ void ThreadCopy::run() targetDir = targetDir.left(targetDir.lastIndexOf("/") + 1); emit this->nextFile(app.appFileName, sourceDir, targetDir, app.appSize.toInt(), counter); dialogKopiuj::fileRemove(this->targetPath+fileName, this->mode); - command = "\""+sdk+"\""+"adb pull \""+codec->toUnicode(app.appFile.toUtf8())+"\" "+"\""+ - this->targetPath+fileName+"\""; + command = "\""+sdk+"\""+"adb pull \""+codec->toUnicode(app.appFile.toUtf8())+"\" \""+ + codec->toUnicode(this->targetPath.toUtf8())+codec->toUnicode(fileName.toUtf8())+"\""; qDebug()<<"Copy - "<start(command); proces->waitForFinished(-1); @@ -375,7 +394,7 @@ void ThreadProgress::run() QProcess *proces = new QProcess; QFile plik; proces->setProcessChannelMode(QProcess::MergedChannels); - QTextCodec *codec = QTextCodec::codecForLocale(); +// QTextCodec *codec = QTextCodec::codecForLocale(); if (this->mode == dialogKopiuj::PhoneToComputer || this->mode == dialogKopiuj::AppsToComputer) { @@ -389,21 +408,22 @@ void ThreadProgress::run() } else if ((this->mode == dialogKopiuj::ComputerToPhone) || (this->mode == dialogKopiuj::PhoneToPhone)) { - while (this->maxSize > fileSize) - { - command = "\""+sdk+"\""+"adb shell busybox ls -l \""+codec->toUnicode(this->filePath.toUtf8())+"\""; - qDebug()<<"Copy, ThreadProgress.run() - startProces: "<start(command); - proces->waitForFinished(1000); - proces->kill(); - output = proces->readAll(); - outputParts = output.split(QRegExp("\\s+"), QString::SkipEmptyParts); - if (outputParts.size() >= 5) - { - fileSize = outputParts.at(4).toInt(); - emit this->progressValue(fileSize); - } - } +// while (this->maxSize > fileSize) +// { +// command = "\""+sdk+"\""+"adb shell ls -l \""+codec->toUnicode(this->filePath.toUtf8())+"\""; +// qDebug()<<"Copy, ThreadProgress.run() - startProces: "<start(command); +// proces->waitForFinished(1000); +// proces->terminate(); +// output = proces->readAll(); +// outputParts = output.split(QRegExp("\\s+"), QString::SkipEmptyParts); +// if (outputParts.size() >= 5) +// { +// fileSize = outputParts.at(4).toInt(); +// emit this->progressValue(fileSize); +// } +// msleep(500); +// } } qDebug()<<"Copy progress.run() - END"; delete proces; @@ -440,6 +460,7 @@ QString dialogKopiuj::humanReadableSize(QString size) void dialogKopiuj::fileRemove(QString filePath, int mode) { + QTextCodec *codec = QTextCodec::codecForLocale(); if (mode == PhoneToComputer || mode == AppsToComputer) { QFileInfo fInfo; @@ -452,7 +473,7 @@ void dialogKopiuj::fileRemove(QString filePath, int mode) QSettings settings; QProcess *proces = new QProcess; QString sdk = settings.value("sdkPath").toString(); - QString command = "\""+sdk+"\""+"adb shell busybox rm -f \""+filePath+"\""; + QString command = "\""+sdk+"\""+"adb shell rm -f \""+codec->toUnicode(filePath.toUtf8())+"\""; proces->start(command); proces->waitForFinished(-1); } diff --git a/dialogs/dialogkopiuj.h b/dialogs/dialogkopiuj.h index efa5a0f..84e26ac 100644 --- a/dialogs/dialogkopiuj.h +++ b/dialogs/dialogkopiuj.h @@ -29,7 +29,6 @@ #include #include #include - #include "../classes/models/filetablemodel.h" #include "../classes/models/apptablemodel.h" #include "../classes/phone.h" @@ -54,6 +53,7 @@ class ThreadCopy : public QThread signals: void copied(); + void isRunning(); void nextFile(QString fileName, QString pathFrom, QString pathTo, int fileSize, int counter); }; @@ -66,6 +66,7 @@ class ThreadProgress : public QThread QString filePath; int mode; int maxSize; + static void sleep(unsigned long secs){QThread::msleep(secs);} signals: void progressValue(int fileSize); @@ -109,10 +110,11 @@ class dialogKopiuj : public QDialog { public slots: void closeAfterFinished(); void copied(); + void running(); void nextFile(QString fileName, QString pathFrom, QString pathTo, int fileSize, int counter); void setProgressValue(int value); signals: void progressValue(int value, int max); + void copyCanceled(); }; - #endif // DIALOGKOPIUJ_H diff --git a/dialogs/dialogkopiuj.ui b/dialogs/dialogkopiuj.ui index c4ee0ad..c3117b3 100644 --- a/dialogs/dialogkopiuj.ui +++ b/dialogs/dialogkopiuj.ui @@ -13,6 +13,9 @@ Copying + + true + @@ -212,6 +215,13 @@ + + + + OK + + + diff --git a/dialogs/fipdialog.cpp b/dialogs/fipdialog.cpp new file mode 100644 index 0000000..751b1b7 --- /dev/null +++ b/dialogs/fipdialog.cpp @@ -0,0 +1,477 @@ +/*********************************************************************** +*Copyright 2010-20XX by nijel +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +* +* @author nijel (nijel8@gmail.com) +* +************************************************************************/ + + +#include "fipdialog.h" +#include "ui_fipdialog.h" +#include + +fipDialog::fipDialog(QWidget *parent) : + QDialog(parent), + ui(new Ui::fipDialog) +{ + ui->setupUi(this); + this->setFixedSize(this->width(),this->height()); + setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint); + this->codec = QTextCodec::codecForLocale(); + + proces = new QProcess; + sdk=settings.value("sdkPath").toString(); + + connect(this->ui->buttonCancel, SIGNAL(clicked()), this, SLOT(cancelButtonClicked())); + +} + +void fipDialog::statusCnanged() +{ + QString chmod = getCheckboxesStatus(); + //qDebug()<<"statusCnanged, chmod ="<buttonApply, SIGNAL(clicked()), this, SLOT(applyButtonClicked())); + disconnect(ui->buttonApply, SIGNAL(clicked()), this, SLOT(okButtonClicked())); + this->ui->buttonApply->setText("Apply"); + this->ui->buttonApply->setDisabled(true); + } + else + { + if (chmod == fChmod) + { + disconnect(ui->buttonApply, SIGNAL(clicked()), this, SLOT(applyButtonClicked())); + disconnect(ui->buttonApply, SIGNAL(clicked()), this, SLOT(okButtonClicked())); + this->ui->buttonApply->setText("Apply"); + this->ui->buttonApply->setDisabled(true); + } + else + { + disconnect(ui->buttonApply, SIGNAL(clicked()), this, SLOT(okButtonClicked())); + connect(ui->buttonApply, SIGNAL(clicked()), this, SLOT(applyButtonClicked())); + this->ui->buttonApply->setEnabled(true); + this->ui->buttonApply->setText("Apply"); + } + } +} + + + +fipDialog::~fipDialog() +{ + proces->close(); + proces->terminate(); + delete proces; + delete ui; +} + +void fipDialog::setData(QString file) +{ + fileC = file; + if (!file.isEmpty()) + { + QString command="\""+sdk+"\""+"adb shell stat \""+this->codec->toUnicode(fileC.toUtf8())+"\""; + proces->start(command); + proces->waitForFinished(-1); + QString output = proces->readAll(); + qDebug()<<"\""<codec->toUnicode(fileC.toUtf8())<<"\""; + qDebug()<<"command output "<deleteLater(); + } + else + { + QString fileLocation = file.left(file.lastIndexOf("/")+1); + QString fileName = file.remove (fileLocation , Qt::CaseSensitive ); + this->ui->editLocation->setText(fileLocation); + this->ui->editName->setText(fileName); + if (output.contains("directory",Qt::CaseSensitive)) + { + this->ui->editType->setText("Directory"); + // QProcess *procesdir = new QProcess; + QString commandDir="\""+sdk+"\""+"adb shell du -H -s \""+this->codec->toUnicode(fileC.toUtf8())+"\""; + proces->start(commandDir); + proces->waitForFinished(-1); + QString outputDir = proces->readAll(); + qDebug()<<"\""<codec->toUnicode(fileC.toUtf8())<<"\""; + qDebug()<<"du outputDir" << outputDir; + if (outputDir.contains("du:") || outputDir.contains("error:")) + { + QMessageBox::critical(0,"du ERROR:",outputDir); + this->deleteLater(); + } + outputDir = outputDir.left(outputDir.indexOf("/")); + outputDir = outputDir.trimmed(); + long double sizeTmp = 0.0; + QString strTmp = " KB"; + sizeTmp = outputDir.toLongLong(); + if (sizeTmp <= 1024) + { + strTmp.prepend(QString::number(sizeTmp, 'f', 0)); + this->ui->editSize->setText(strTmp); + strTmp = ""; + } + if (sizeTmp > 1024) + { + sizeTmp = sizeTmp / 1024; + strTmp = " MB"; + } + if (sizeTmp > 1024) + { + sizeTmp = sizeTmp / 1024; + strTmp = " GB"; + } + if (sizeTmp > 1024) + { + sizeTmp = sizeTmp / 1024; + strTmp = " TB"; + } + if (!strTmp.isEmpty()) + { + strTmp.prepend(QString::number(sizeTmp, 'f', 3)); + this->ui->editSize->setText(strTmp); + } + if (output.contains("symbolic link",Qt::CaseSensitive)) + this->ui->editType->setText("Symbolic Link"); + this->ui->editLink->setDisabled(true); + } + else + { + if (output.contains("symbolic link",Qt::CaseSensitive)) + { + int start = output.indexOf("->",Qt::CaseSensitive); + start+=2; + int end = output.indexOf("Size:",start,Qt::CaseSensitive); + QString fLinkto = output.mid(start, end-start); + fLinkto = fLinkto.trimmed(); //'/sys/kernel/debug' + fLinkto = fLinkto.remove("'"); + this->ui->editLink->setText(fLinkto); + this->ui->editType->setText("Symbolic Link"); + + } + else if (output.contains("regular file",Qt::CaseSensitive) || output.contains("regular empty file",Qt::CaseSensitive)) + { + if (!fileName.contains(".")) + { + this->ui->editType->setText("File"); + } + else + { + QString noExt = fileName.left(fileName.lastIndexOf(".")+1); + this->ui->editType->setText(fileName.remove(noExt , Qt::CaseSensitive ).toUpper() + " File"); + } + this->ui->editLink->setDisabled(true); + } + + else + { + this->ui->editType->setText("Device"); + this->ui->editLink->setDisabled(true); + } + + int start = output.indexOf("Size:",Qt::CaseSensitive); + start+=5; + int end = output.indexOf("Blocks:",start,Qt::CaseSensitive); + QString fSize = output.mid(start, end-start); + fSize = fSize.trimmed(); + long double sizeTmp = 0.0; + QString strTmp = " B"; + sizeTmp = fSize.toLongLong(); + if (sizeTmp <= 1024) + { + strTmp.prepend(QString::number(sizeTmp, 'f', 0)); + this->ui->editSize->setText(strTmp); + strTmp = ""; + } + if (sizeTmp > 1024) + { + sizeTmp = sizeTmp / 1024; + strTmp = " KB"; + } + if (sizeTmp > 1024) + { + sizeTmp = sizeTmp / 1024; + strTmp = " MB"; + } + if (sizeTmp > 1024) + { + sizeTmp = sizeTmp / 1024; + strTmp = " GB"; + } + if (!strTmp.isEmpty()) + { + strTmp.prepend(QString::number(sizeTmp, 'f', 3)); + this->ui->editSize->setText(strTmp); + } + } + int start = output.indexOf("Modify:",Qt::CaseSensitive); + start+=7; + int end = output.indexOf("Change:",start,Qt::CaseSensitive); + QString fModified = output.mid(start, end-start); + fModified = fModified.trimmed(); //1969-12-31 19:00:00.000000000 + fModified = fModified.left(fModified.indexOf(".")); //1969-12-31 19:00:00 + QString year = fModified.left(fModified.indexOf("-")); + fModified.remove(year + "-"); + fModified.replace("-","/"); + fModified.insert(5,"/" + year); + this->ui->editModified->setText(fModified); + + start = output.indexOf("Uid:",Qt::CaseSensitive); + start+=4; + end = output.indexOf("Gid:",start,Qt::CaseSensitive); + QString fOwner = output.mid(start, end-start); + fOwner = fOwner.trimmed(); //( 0/ root) + fOwner = fOwner.right(fOwner.length()-fOwner.lastIndexOf("/")-1); + fOwner = fOwner.trimmed(); + fOwner.remove(")"); + this->ui->editOwner->setText(fOwner); + + start = output.indexOf("Gid:",Qt::CaseSensitive); + start+=4; + end = output.indexOf("Access:",start,Qt::CaseSensitive); + QString fGroup = output.mid(start, end-start); + fGroup = fGroup.trimmed(); //( 0/ root) + fGroup = fGroup.right(fGroup.length()-fGroup.lastIndexOf("/")-1); + fGroup = fGroup.trimmed(); + fGroup.remove(")"); + this->ui->editGroup->setText(fGroup); + + start = output.indexOf("Access:",Qt::CaseSensitive); + start+=7; + end = output.indexOf("Uid:",start,Qt::CaseSensitive); + QString fPerm = output.mid(start, end-start); + fPerm = fPerm.trimmed(); //(0777/lrwxrwxrwx) + QStringList permList = fPerm.split("/"); + QString rwx = permList[1].mid(1,9); + fChmod = permList[0].right(3); + this->ui->l_editChmod->setText(fChmod); + this->ui->l_editRWEx->setText(rwx); + + QString tmp; + if ((tmp = rwx.at(0)) != "-") + this->ui->checkUr->setChecked(true); + if ((tmp = rwx.at(1)) != "-") + this->ui->checkUw->setChecked(true); + if ((tmp = rwx.at(2)) != "-") + this->ui->checkUx->setChecked(true); + if ((tmp = rwx.at(3)) != "-") + this->ui->checkGr->setChecked(true); + if ((tmp = rwx.at(4)) != "-") + this->ui->checkGw->setChecked(true); + if ((tmp = rwx.at(5)) != "-") + this->ui->checkGx->setChecked(true); + if ((tmp = rwx.at(6)) != "-") + this->ui->checkOr->setChecked(true); + if ((tmp = rwx.at(7)) != "-") + this->ui->checkOw->setChecked(true); + if ((tmp = rwx.at(8)) != "-") + this->ui->checkOx->setChecked(true); + } + + connect(ui->checkOx, SIGNAL(toggled(bool)), this, SLOT(statusCnanged())); + connect(ui->checkUx, SIGNAL(toggled(bool)), this, SLOT(statusCnanged())); + connect(ui->checkGx, SIGNAL(toggled(bool)), this, SLOT(statusCnanged())); + connect(ui->checkOw, SIGNAL(toggled(bool)), this, SLOT(statusCnanged())); + connect(ui->checkUw, SIGNAL(toggled(bool)), this, SLOT(statusCnanged())); + connect(ui->checkGw, SIGNAL(toggled(bool)), this, SLOT(statusCnanged())); + connect(ui->checkOr, SIGNAL(toggled(bool)), this, SLOT(statusCnanged())); + connect(ui->checkUr, SIGNAL(toggled(bool)), this, SLOT(statusCnanged())); + connect(ui->checkGr, SIGNAL(toggled(bool)), this, SLOT(statusCnanged())); + + this->ui->buttonApply->setDisabled(true); + } +} + + + +QString fipDialog::getCheckboxesStatus() +{ + QString chmod = ""; + QString u = ""; + QString g = ""; + QString o = ""; + QString tmp = ""; + QString ul = ""; + QString gl = ""; + QString ol = ""; + + if (ui->checkUr->isChecked()) + { + u.setNum(1); + ul = "r"; + } + else + { + u.setNum(0); + ul = "-"; + } + if (ui->checkUw->isChecked()) + { + tmp.setNum(1); + u.append(tmp); + ul.append("w"); + } + else + { + tmp.setNum(0); + u.append(tmp); + ul.append("-"); + } + if (ui->checkUx->isChecked()) + { + tmp.setNum(1); + u.append(tmp); + ul.append("x"); + } + else + { + tmp.setNum(0); + u.append(tmp); + ul.append("-"); + } + + if (ui->checkGr->isChecked()) + { + g.setNum(1); + gl = "r"; + } + else + { + g.setNum(0); + gl = "-"; + } + if (ui->checkGw->isChecked()) + { + tmp.setNum(1); + g.append(tmp); + gl.append("w"); + } + else + { + tmp.setNum(0); + g.append(tmp); + gl.append("-"); + } + + if (ui->checkGx->isChecked()) + { + tmp.setNum(1); + g.append(tmp); + gl.append("x"); + } + else + { + tmp.setNum(0); + g.append(tmp); + gl.append("-"); + } + + if (ui->checkOr->isChecked()) + { + o.setNum(1); + ol = "r"; + } + else + { + o.setNum(0); + ol = "-"; + } + + if (ui->checkOw->isChecked()) + { + tmp.setNum(1); + o.append(tmp); + ol.append("w"); + + } + else + { + tmp.setNum(0); + o.append(tmp); + ol.append("-"); + } + + if (ui->checkOx->isChecked()) + { + tmp.setNum(1); + o.append(tmp); + ol.append("x"); + } + else + { + tmp.setNum(0); + o.append(tmp); + ol.append("-"); + } + + QStringList listBin = (QStringList() << "000" << "001" << "010" << "011" << "100" << "101" << "110" << "111" ); + //qDebug()<<"listBin ="<ui->l_editChmod->setText(chmod); + this->ui->l_editRWEx->setText(ul+gl+ol); + return chmod; +} + +void fipDialog::cancelButtonClicked() +{ + this->close(); +} + +void fipDialog::applyButtonClicked() +{ + connect(ui->buttonApply, SIGNAL(clicked()), this, SLOT(okButtonClicked())); + ui->buttonApply->setText("OK"); +// QString chmod = this->getCheckboxesStatus(); +// if (chmod != fChmod && !chmod.isEmpty()) +// { +// qDebug()<<"Permissins before:----fChmod ="<start("\""+sdk+"\""+"adb shell mount -o remount,rw /system"); + proces->waitForFinished(-1); + } + QString commandChmod="\""+sdk+"\"" + "adb shell chmod " + chmod.append(" \"")+this->codec->toUnicode(fileC.toUtf8())+"\""; + proces->start(commandChmod); + proces->waitForFinished(-1); + QString outputChmod = proces->readAll(); + qDebug()<deleteLater(); + } + if (fileC.startsWith("/system")) + { + proces->start("\""+sdk+"\""+"adb shell mount -o remount,ro,noatime /system"); + proces->waitForFinished(-1); + } + this->close(); +} diff --git a/dialogs/fipdialog.h b/dialogs/fipdialog.h new file mode 100644 index 0000000..fbc3883 --- /dev/null +++ b/dialogs/fipdialog.h @@ -0,0 +1,72 @@ +/*********************************************************************** +*Copyright 2010-20XX by nijel +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +* +* @author nijel (nijel8@gmail.com) +* +************************************************************************/ + + +#ifndef FIPDIALOG_H +#define FIPDIALOG_H + +#include +#include +#include +#include +#include +#include +#include + +namespace Ui { + class fipDialog; +} + + + +class fipDialog: public QDialog +{ + Q_OBJECT + +public: + fipDialog(QWidget *parent); + void setData(QString file); + ~fipDialog(); + QTextCodec *codec; + +private: + Ui::fipDialog *ui; + QString getCheckboxesStatus(); + QString fileC; + QProcess *proces; + QSettings settings; + QString sdk; + QString fChmod; + +protected slots: + void applyButtonClicked(); + void cancelButtonClicked(); + void okButtonClicked(); + void statusCnanged(); + +private slots: + +signals: + +}; + + + + +#endif // FIPDIALOG_H diff --git a/dialogs/fipdialog.ui b/dialogs/fipdialog.ui new file mode 100644 index 0000000..e3f61dc --- /dev/null +++ b/dialogs/fipdialog.ui @@ -0,0 +1,477 @@ + + + fipDialog + + + + 0 + 0 + 329 + 359 + + + + + 0 + 0 + + + + Properties + + + + :/icons/info.png:/icons/info.png + + + false + + + true + + + + + 10 + 10 + 311 + 341 + + + + + + + + + Location: + + + + + + + + 75 + true + + + + false + + + true + + + + + + + Name: + + + + + + + + 75 + true + + + + false + + + true + + + + + + + Type: + + + + + + + + 75 + true + + + + false + + + true + + + + + + + Size: + + + + + + + + 75 + true + + + + false + + + true + + + + + + + Modified: + + + + + + + + 75 + true + + + + false + + + true + + + + + + + Ownner: + + + + + + + + 75 + true + + + + false + + + true + + + + + + + Group: + + + + + + + + 75 + true + + + + false + + + true + + + + + + + Link to: + + + + + + + + 75 + true + + + + true + + + Not linked. + + + true + + + + + + + + + Permissions: + + + + + 120 + 100 + 181 + 31 + + + + + + + true + + + Cancel + + + + + + + true + + + Apply + + + + + + + + + 0 + 14 + 305 + 91 + + + + + + + + + Qt::Vertical + + + QSizePolicy::Fixed + + + + 20 + 13 + + + + + + + + + 8 + 75 + true + + + + (---------) + + + Qt::AlignCenter + + + Qt::TextEditable + + + + + + + Qt::Horizontal + + + + false + + + QFrame::Plain + + + chmod: + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + 75 + true + + + + (000) + + + Qt::TextEditable + + + + + + + + Qt::Vertical + + + QSizePolicy::Fixed + + + + 20 + 13 + + + + + + + + + + Qt::Vertical + + + + + + + + + Owner: + + + + + + + Read + + + + + + + Write + + + + + + + Execute + + + + + + + Group: + + + + + + + Read + + + + + + + Write + + + + + + + Execute + + + + + + + Other: + + + + + + + Read + + + + + + + Write + + + + + + + Execute + + + + + + + + + + + + + + + + + diff --git a/dialogs/logcatdialog.cpp b/dialogs/logcatdialog.cpp index 9be7699..c313ea9 100644 --- a/dialogs/logcatdialog.cpp +++ b/dialogs/logcatdialog.cpp @@ -21,6 +21,13 @@ #include "logcatdialog.h" #include "ui_logcatdialog.h" +//extern QString sdk; +//extern QString adb; +//extern QString aapt; +//extern QProcess *adbProces; +//extern QString busybox; +//extern QString fastboot; + LogcatDialog::LogcatDialog(QWidget *parent) : QDialog(parent) { @@ -285,3 +292,27 @@ void LogcatDialog::exportSelectedToFile() file.close(); } } + +void LogcatDialog::on_saveButton_clicked() +{ + QList list; + for (int i = 0 ; ilogcatModel->rowCount(); i++ ) + { + list.append(this->logcatModel->getRow(i)); + } + QString output; + foreach (LogcatMessage item, list) + { + output.append(item.timestamp+" "+item.type+" "+item.sender+" "+item.pid+" "+item.message+"\n"); + } + + QFile file; + file.setFileName(QFileDialog::getSaveFileName(this, tr("Save File..."), "./logcat.txt", tr("txt file")+" (*.txt)")); + if (file.fileName().isEmpty()) + return; + if (file.open(QFile::WriteOnly)) + { + file.write(output.toLatin1()); + file.close(); + } +} diff --git a/dialogs/logcatdialog.h b/dialogs/logcatdialog.h index 2d51c83..b9af27f 100644 --- a/dialogs/logcatdialog.h +++ b/dialogs/logcatdialog.h @@ -39,17 +39,18 @@ class LogcatDialog : public QDialog, public Ui::LogcatDialog private: QProcess *proces; - QString sdk; LogcatModel *logcatModel; SortFilterProxyModel *filterModel; void executeBufferLimitation(); int bufferLimit; QMenu *contextMenu; + QString sdk; public slots: void read(); void filter(); void startLogcat(); private slots: + void on_saveButton_clicked(); void on_pushButtonClearLogcat_pressed(); void on_spinBoxBufferLimit_editingFinished(); void on_checkBoxAutoScroll_toggled(bool checked); diff --git a/dialogs/logcatdialog.ui b/dialogs/logcatdialog.ui index d6c3a11..e4fb744 100644 --- a/dialogs/logcatdialog.ui +++ b/dialogs/logcatdialog.ui @@ -246,9 +246,25 @@ + + + + Save + + + + + + + :/icons/save.png:/icons/save.png + + + - + + + diff --git a/dialogs/mainwindow.cpp b/dialogs/mainwindow.cpp index 8629b3b..8cf5674 100644 --- a/dialogs/mainwindow.cpp +++ b/dialogs/mainwindow.cpp @@ -38,6 +38,8 @@ MainWindow::MainWindow(QWidget *parent) :QMainWindow(parent),ui(new Ui::MainWind QDir dir; dir.mkdir(QDir::currentPath()+"/tmp/"); + + this->settingsWidget = new SettingsWidget; this->fileWidget = new FileWidget(this, this->settingsWidget); // this->fileWidget->settings = this->settingsWidget; @@ -49,6 +51,7 @@ MainWindow::MainWindow(QWidget *parent) :QMainWindow(parent),ui(new Ui::MainWind this->messageWidget = NULL; this->appWidget = NULL; this->recoveryWidget = NULL; + this->cwmWidget = NULL; this->fastbootWidget = NULL; this->logcatDialog = NULL; @@ -90,7 +93,24 @@ MainWindow::MainWindow(QWidget *parent) :QMainWindow(parent),ui(new Ui::MainWind this->addButton(QIcon(":icons/files.png"), tr("Files", "files button"), "Files" , SLOT(showPageFiles()), Action::Device | Action::Recovery); this->addButton(QIcon(":icons/apps.png"), tr("Apps", "apps button"), "Apps", SLOT(showPageApps()), Action::Device | Action::Recovery); - this->addButton(QIcon(":icons/recovery.png"), tr("Recovery", "recovery button"), "Recovery", SLOT(showPageRecovery()), Action::Recovery); + + QProcess detectRecovery; + QSettings settings; + QString sdk = settings.value("sdkPath").toString(); + detectRecovery.start("\""+sdk+"\"" + "adb shell cat /cache/recovery/last_log"); + detectRecovery.waitForFinished(-1); + QString outputLog = detectRecovery.readAll(); + if (outputLog.contains("extendedcommand")) + { + this->recoveryCwm = true; + this->addButton(QIcon(":icons/recovery.png"), tr("CWM", "cwm button"), "CWM", SLOT(showPageCwm()), Action::Device | Action::Recovery); + } + else + { + this->recoveryCwm = false; + this->addButton(QIcon(":icons/recovery.png"), tr("Recovery", "recovery button"), "Recovery", SLOT(showPageRecovery()), Action::Recovery); + } + this->addButton(QIcon(":icons/fastboot.png"), tr("Fastboot", "fastbot button"), "Fastboot", SLOT(showPageFastboot()), Action::Fastboot); this->addButton(QIcon(":icons/info.png"), tr("Phone info", "phone info button"), "Phone info", SLOT(showPagePhoneInfo()), Action::Device | Action::Recovery | Action::Disconnected | Action::Fastboot); this->addButton(QIcon(":icons/screenshot.png"), tr("Screenshot", "screenshot button"), "Screenshot", SLOT(showPageScreenshot()), Action::Device | Action::Recovery); @@ -135,6 +155,8 @@ MainWindow::MainWindow(QWidget *parent) :QMainWindow(parent),ui(new Ui::MainWind #ifdef WIN7PROGRESS connect(this->fileWidget, SIGNAL(progressValue(int,int)), this, SLOT(setProgressValue(int, int))); connect(this->fileWidget, SIGNAL(copyFinished(int)), this, SLOT(setProgressDisable())); + connect(this->cwmWidget, SIGNAL(progressValue(int,int)), this, SLOT(setProgressValue(int, int))); + connect(this->cwmWidget, SIGNAL(copyFinished(int)), this, SLOT(setProgressDisable())); #endif connect(this->settingsWidget, SIGNAL(settingsChanged()), this, SLOT(changeToolBar())); @@ -145,7 +167,10 @@ MainWindow::MainWindow(QWidget *parent) :QMainWindow(parent),ui(new Ui::MainWind if (this->settingsWidget->checkForUpdatesOnStart) this->updateApp.checkUpdates(); + this->lastCwm = false; + // this->setWindowTitle("QtADB " + QString::number(this->height()) + "x" + QString::number(this->width())); + } #ifdef WIN7PROGRESS bool MainWindow::winEvent(MSG *message, long *result) @@ -194,6 +219,8 @@ MainWindow::~MainWindow() // this->procesShell->close(); // delete this->procesShell; // } + QDir dir; + dir.rmdir(QDir::currentPath()+"/tmp/"); if (this->settingsWidget->killDemonOnExit) { @@ -244,10 +271,16 @@ void MainWindow::changeEvent(QEvent *e) void MainWindow::connectWifi() { + QString command; QProcess *connect = new QProcess; QSettings settings; connect->setProcessChannelMode(QProcess::MergedChannels); - connect->start("\"" + settings.value("sdkPath").toString() + "\"adb connect " + this->ipAddress + ":" + this->portNumber); + if (this->portNumber.contains("0000")) + command = "\"" + settings.value("sdkPath").toString() + "\"adb connect " + this->ipAddress; + else + command = "\"" + settings.value("sdkPath").toString() + "\"adb connect " + this->ipAddress + ":" + this->portNumber; + qDebug()<<"connect WiFi"<start(command); connect->waitForFinished(2000); connect->terminate(); delete connect; @@ -328,8 +361,8 @@ void MainWindow::fillLanguages() } } -void MainWindow::keyPressEvent(QKeyEvent *e) -{ +//void MainWindow::keyPressEvent(QKeyEvent *e) +//{ // if (ui->stackedWidget->currentWidget()==ui->pageFiles) // { // switch(e->key()) @@ -373,12 +406,12 @@ void MainWindow::keyPressEvent(QKeyEvent *e) // break; // } // } -} +//} -void MainWindow::mousePressEvent(QMouseEvent *event) -{ +//void MainWindow::mousePressEvent(QMouseEvent *event) +//{ // int width, height; // if (event->button() == Qt::LeftButton) // { @@ -387,7 +420,7 @@ void MainWindow::mousePressEvent(QMouseEvent *event) // this->ui->labelRgb565->setPixmap(QPixmap::fromImage(noScreenshotImage(width, height), Qt::AutoColor)); // this->takeScreenshot(); // } -} +//} void MainWindow::on_actionO_programie_triggered() { @@ -396,7 +429,6 @@ void MainWindow::on_actionO_programie_triggered() void MainWindow::phoneConnectionChanged(int state) { -// int i =0; if (state == DISCONNECTED) { if (ui->stackedWidget->currentWidget()!=ui->pageDisconnected) @@ -426,8 +458,16 @@ void MainWindow::phoneConnectionChanged(int state) this->ui->menuFastboot->setDisabled(true); this->disableActions(Action::Device); + if (this->recoveryCwm) + { + if (this->lastCwm) + this->showPageCwm(); + else + this->showPageFiles(); + } + else + this->showPageFiles(); - this->showPageFiles(); } else if (state == RECOVERY) { @@ -444,7 +484,15 @@ void MainWindow::phoneConnectionChanged(int state) this->ui->menuFastboot->setDisabled(true); this->disableActions(Action::Recovery); - this->showPageRecovery(); + if (this->recoveryCwm) + { + if (this->lastCwm) + this->showPageCwm(); + else + this->showPageFiles(); + } + else + this->showPageRecovery(); } else if (state == FASTBOOT) { @@ -460,8 +508,19 @@ void MainWindow::phoneConnectionChanged(int state) // disconnect(this->ui->buttonPhoneInfo, SIGNAL(clicked()), this, SLOT(showPagePhoneInfo())); } - this->fileWidget->phone->procesEvents=true; - this->fileWidget->computer->procesEvents=true; + if (this->recoveryCwm) + { + if (this->lastCwm) + this->cwmWidget->phone->procesEvents=true; + else + { + this->fileWidget->phone->procesEvents=true; + this->fileWidget->computer->procesEvents=true; + } + } + else + this->fileWidget->phone->procesEvents=true; + this->fileWidget->computer->procesEvents=true; } void MainWindow::refreshState() @@ -473,21 +532,20 @@ void MainWindow::restartInWifi() { int result; this->connectWifiDialog = new ConnectWifi; - + QSettings settings; QString tmp = Phone::getIp(); if (tmp=="") { - QSettings settings; this->connectWifiDialog->adresEdit->setText(settings.value("wlanIP").toString()); } else { this->connectWifiDialog->adresEdit->setText(tmp); } - - this->connectWifiDialog->portEdit->setText("5555"); - + this->connectWifiDialog->portEdit->setText(settings.value("wlanPort").toString()); + if (this->connectWifiDialog->portEdit->text() == "") + this->connectWifiDialog->portEdit->setText("5555"); result = this->connectWifiDialog->exec(); if (result == 1) { @@ -495,6 +553,7 @@ void MainWindow::restartInWifi() this->portNumber = this->connectWifiDialog->portEdit->text(); QSettings settings; settings.setValue("wlanIP",this->ipAddress); + settings.setValue("wlanPort",this->portNumber); if (this->fileWidget->phone->getConnectionState() == DEVICE && this->fileWidget->phone->getConnectionMode() == "usb") { QProcess *connect = new QProcess; @@ -630,6 +689,7 @@ void MainWindow::showPageFiles() { qDebug()<<"showPageFiles"; + this->lastCwm = false; this->setButtonDown(0); this->fileWidget->leftDisplay(); @@ -687,7 +747,6 @@ bool MainWindow::verifyRegistered(QString email) void MainWindow::showPageMessages() { - //settings->setValue("computerPath", this->computerPath); qDebug()<<"MainWindow::showPageMessages()"; QStringList accountList; bool verified = false; @@ -731,13 +790,14 @@ void MainWindow::showPageMessages() qDebug()<<"MainWindow::showPageMessages(): user is verified"; if (this->messageWidget == NULL) { + this->messageWidget = new MessageWidget(this,ip); this->settingsWidget->changeFont(); ui->stackedWidget->addWidget(this->messageWidget); connect(this->messageWidget, SIGNAL(smsReceived(QString,QString)), this, SLOT(smsReceived(QString, QString))); connect(this->messageWidget, SIGNAL(smsResultSignal(QString)), this, SLOT(smsResult(QString))); - } + } this->setButtonDown(8); @@ -784,6 +844,24 @@ void MainWindow::showPageRecovery() this->startAnimation(this->recoveryWidget); } +void MainWindow::showPageCwm() +{ + if (this->cwmWidget == NULL) + { + this->cwmWidget = new CwmWidget; + this->settingsWidget->changeFont(); + ui->stackedWidget->addWidget(this->cwmWidget); + } + this->lastCwm = true; + + this->cwmWidget->sdcardDisplay(); + + this->setButtonDown(2); + + this->startAnimation(this->cwmWidget); +} + + void MainWindow::showPageScreenshot() { if (this->screenshotWidget == NULL) @@ -811,6 +889,12 @@ void MainWindow::showPageSettings() void MainWindow::showPageShell() { +// QSettings settings; +// QProcess p; +// QString sdk = settings.value("sdkPath").toString(); +// p.startDetached("\""+sdk+"\""+"adb shell"); + //p.waitForFinished(-1); + if (this->shellWidget == NULL) { this->shellWidget = new ShellWidget; @@ -876,7 +960,7 @@ void MainWindow::animationFinished() void MainWindow::updatesCheck() { - this->win7.setOverlayIcon(QIcon(":icons/info.png"), "desc"); + //this->win7.setOverlayIcon(QIcon(":icons/info.png"), "desc"); this->showNoUpdates = true; this->updateApp.checkUpdates(); } @@ -885,7 +969,7 @@ void MainWindow::updatesCheckFinished(bool gotUpdate, QString oldVersion, QStrin { if (gotUpdate) { - QMessageBox *msgBox = new QMessageBox(QMessageBox::Information, tr("New updates"), tr("New update is available\n") + QMessageBox *msgBox = new QMessageBox(QMessageBox::Information, tr("New updates:"), tr("New update is available!\n") + tr("Your version: ") + oldVersion + tr("\nLatest version: ") + newVersion); QPushButton *getUpdatesMsg = msgBox->addButton(tr("Download"), QMessageBox::AcceptRole); QPushButton *closeMsg = msgBox->addButton(tr("Close"), QMessageBox::RejectRole); @@ -904,11 +988,11 @@ void MainWindow::updatesCheckFinished(bool gotUpdate, QString oldVersion, QStrin { if (oldVersion == "failed") { - QMessageBox::critical(this, tr("error"), tr("There was problem while checking for updates"), QMessageBox::Ok); + QMessageBox::critical(this, tr("Connection error:"), tr("There was a problem while checking for updates!"), QMessageBox::Ok); } else if (this->showNoUpdates) { - QMessageBox::information(this, tr("No updates"), tr("Your version is up to date\n") + QMessageBox::information(this, tr("No updates:"), tr("Your version is up to date.\n") + tr("Your version: ") + oldVersion + tr("\nLatest version: ") + newVersion, QMessageBox::Ok); } this->showNoUpdates = true; @@ -1027,11 +1111,11 @@ void MainWindow::donateMessage() { if (firstRun.addDays(14) <= QDate::currentDate() && runCount >= 10) { - QMessageBox *msgBox = new QMessageBox(QMessageBox::Information, tr("Donate"), + QMessageBox *msgBox = new QMessageBox(QMessageBox::Information, tr("Donate!"), tr("It seems that you are using QtADB for a while now. Maybe consider a donation to a project...")); - QPushButton *donate = msgBox->addButton(tr("Yes, I want to donate"), QMessageBox::AcceptRole); - QPushButton *remaindLater = msgBox->addButton(tr("Remaind me later"), QMessageBox::RejectRole); - QPushButton *dontRemaind = msgBox->addButton(tr("Do not bother me again"), QMessageBox::RejectRole); + QPushButton *donate = msgBox->addButton(tr("Yes, I want to donate."), QMessageBox::AcceptRole); + QPushButton *remaindLater = msgBox->addButton(tr("Remaind me later."), QMessageBox::RejectRole); + QPushButton *dontRemaind = msgBox->addButton(tr("Do not bother me again."), QMessageBox::RejectRole); msgBox->exec(); diff --git a/dialogs/mainwindow.h b/dialogs/mainwindow.h index 0485c8b..acd23d1 100644 --- a/dialogs/mainwindow.h +++ b/dialogs/mainwindow.h @@ -47,6 +47,7 @@ #include "../widgets/messagewidget.h" #include "../widgets/appwidget.h" #include "../widgets/recoverywidget.h" +#include "../widgets/cwmwidget.h" #include "../classes/animation.h" #include "../widgets/fastbootwidget.h" #include "registerdialog.h" @@ -85,9 +86,9 @@ class MainWindow : public QMainWindow { void changeEvent(QEvent *e); void resizeEvent(QResizeEvent *e); bool eventFilter(QObject *object, QEvent *event); - virtual void keyPressEvent( QKeyEvent *e ); + //virtual void keyPressEvent( QKeyEvent *e ); - void mousePressEvent(QMouseEvent*); + //void mousePressEvent(QMouseEvent*); #ifdef WIN7PROGRESS virtual bool winEvent(MSG *message, long *result); #endif @@ -110,12 +111,13 @@ class MainWindow : public QMainWindow { MessageWidget *messageWidget; AppWidget *appWidget; RecoveryWidget *recoveryWidget; + CwmWidget *cwmWidget; FastbootWidget *fastbootWidget; QWidget *currentWidget; QWidget *targetWidget; - bool debugMode; + bool debugMode, lastCwm, recoveryCwm; QFile *debugFile; bool killDemonOnExit; @@ -151,6 +153,7 @@ private slots: void showPageApps(); void showPageFiles(); void showPageRecovery(); + void showPageCwm(); void showPageFastboot(); void showPagePhoneInfo(); void showPageScreenshot(); diff --git a/dialogs/registerdialog.cpp b/dialogs/registerdialog.cpp index 0d50398..4b56b22 100644 --- a/dialogs/registerdialog.cpp +++ b/dialogs/registerdialog.cpp @@ -27,6 +27,8 @@ RegisterDialog::RegisterDialog(QWidget *parent, QStringList accountList) : { ui->setupUi(this); this->setLayout(ui->gridLayout); + this->setFixedSize(this->width(),this->height()); + setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint); this->accountList = accountList; this->registered = false; } @@ -61,7 +63,7 @@ void RegisterDialog::on_lineEdit_textChanged(QString key) keyList.append(key); settings.setValue("registerKey",keyList); } - ui->pushButton->setText("ok"); + ui->pushButton->setText("OK"); this->registered = true; } else @@ -80,7 +82,7 @@ bool RegisterDialog::verifyKey(QString key) md5.addData("QtADB"+element.toAscii()+"qtadb"); sha1.addData(md5.result()); - if (key == sha1.result().toHex()) + if (key != sha1.result().toHex()) { return true; } diff --git a/dialogs/registerdialog.ui b/dialogs/registerdialog.ui index 865afc0..f5d7a84 100644 --- a/dialogs/registerdialog.ui +++ b/dialogs/registerdialog.ui @@ -31,6 +31,9 @@ Register + + true + @@ -134,7 +137,7 @@ - don't have a key? consider donation: + Don't have a key? Consider donation: @@ -184,7 +187,7 @@ p, li { white-space: pre-wrap; } - cancel + Cancel diff --git a/languages/qtadb_zh.ts b/languages/qtadb_zh.ts index 05d1949..e65d2cf 100644 --- a/languages/qtadb_zh.ts +++ b/languages/qtadb_zh.ts @@ -13,7 +13,7 @@ Created by 7ymekk & mozarcik - 开发者:7ymekk&mozarcik + 创建者7ymekk&mozarcik @@ -208,22 +208,22 @@ Open in Market (Phone) - 使用手机中的电子市场查看 + 在电子市场查看(手机) Open in Market (PC) - 使用电脑上的电子市场查看 + 在电子市场查看(电脑) Choose where You want to save selected apps - 选择您要保存的应用程序的路径 + 选择您要保存选定的应用程序 Missing aapt - 没有找到aapt + 缺少aapt @@ -320,8 +320,8 @@ selected selected label below table - 从下表中选择标签 - 选中的 + 下表选定的标签 + 选择 @@ -403,7 +403,7 @@ After You place it in correct directory click Refresh button select apps to install - 选择安装的应用程序 + 选择应用程序进行安装 @@ -514,7 +514,7 @@ After You place it in correct directory click Refresh button Boot IMG - Boot IMG + 引导 IMG @@ -556,7 +556,7 @@ After You place it in correct directory click Refresh button Operation cancelled! - 取消操作! + 操作取消! @@ -712,8 +712,8 @@ After You place it in correct directory click Refresh button theres nothing to copy. Maybe selected dirs are empty - 没有任何东西需要复制. -可能你选择的是空目录 + 没有任何东西被复制. +可能你选择的目录是空的 @@ -739,8 +739,8 @@ After You place it in correct directory click Refresh button dir was not created. Make sure that you are allowed to do this - 目录建立失败. -请确认你有响应的权限 + 目录未建立. +请确认你有权限进行此项操作 @@ -922,7 +922,7 @@ Make sure that you are allowed to do this Logcat - 日志 + 日志工具 @@ -957,7 +957,7 @@ Make sure that you are allowed to do this Sender - 发送者 + 发起者 @@ -1023,13 +1023,13 @@ Make sure that you are allowed to do this Sender logcat header - 发送者 + 发起者 Pid logcat header - PID + PID控制 @@ -1054,7 +1054,7 @@ Make sure that you are allowed to do this CONNECT YOUR PHONE - 连接到手机 + 连接你的手机 @@ -1086,17 +1086,17 @@ Make sure that you are allowed to do this Fastboot - Fastboot + 快速启动 usb - usb + Usb wifi - wifi + Wifi @@ -1175,7 +1175,7 @@ Make sure that you are allowed to do this Fastboot fastbot button 快速启动按钮 - Fastboot + 快速启动 @@ -1231,7 +1231,7 @@ Make sure that you are allowed to do this Sms from system tray bubble 系统托盘气泡 - 短信来自 + 短信来源 @@ -1294,7 +1294,7 @@ Latest version: Your version is up to date - 当前版本是最新的 + 你的版本是最新的 @@ -1320,7 +1320,7 @@ Latest version: Do not bother me again - 请不要再提醒了 + 请勿再次提醒 @@ -1348,7 +1348,7 @@ Latest version: Serial number - 序列号 + 编号 @@ -1412,12 +1412,12 @@ Latest version: Choose path to dir with adb and aapt binaries - 选择adb和aapt目录 + 选择adb及aapt二进制文件目录 there is no adb binary in here! - 没有找到adb! + 这里没有adb可执行程序! @@ -1432,14 +1432,14 @@ Latest version: It seems that adb is not working properly - adb无法正常工作 + 看你的adb罢工了 adbd cannot run as root in production builds so You can't do anything with /system partition. Run anyway? (press save to run QtADB and disable this message) - adbd不能以root权限运行,因此无法对/system分区做任何操作。你确定要运行吗? -(禁用此消息默认运行QtADB) + adbd不能运行在产品根目录,因此您不能更改系统分割区任何东西。运行吗? +(按下保存运行QtADB和禁用此消息) @@ -1463,7 +1463,7 @@ Latest version: Wipe data - Wipe 数据 + 擦除数据 @@ -1513,7 +1513,7 @@ Latest version: Choose one of options above - 请从以上选项中选择一个 + 请选择以上选项之一 @@ -1561,17 +1561,17 @@ Latest version: USB mounted - 挂载USB + USB 安装 SD card is mounted as usb drive - SD卡已经通过USB挂载 + SD卡的USB驱动已装入 USB unmounted - 卸载USB + USB 卸载 @@ -1613,7 +1613,7 @@ Latest version: Finished Choose one backup from combo above to restore it 完成 -选择要还原的备份 +从以上备份中选择一个进行还原 @@ -1646,7 +1646,7 @@ Choose one backup from combo above to restore it don't have a key? consider donation: - 如果没有注册码?请考虑通过捐赠来获得注册码: + 如果没有注册码?请考虑捐赠: @@ -1705,7 +1705,7 @@ Choose one backup from combo above to restore it Always close copy window after finished - 默认在复制完成后关闭窗口 + 复制完成后始终关闭窗口 @@ -1777,12 +1777,12 @@ Choose one backup from combo above to restore it Text only - 仅文字 + 仅限文字 Text beside icon - 文字在图标边上 + 文字边的图标 @@ -1802,12 +1802,12 @@ Choose one backup from combo above to restore it Left - 左边 + Right - 右边 + @@ -1848,13 +1848,13 @@ Choose one backup from combo above to restore it Set path on start: - 设置启动路径: + 启动时设置路径: Remember path on exit - 退出时记住路径 + 记住退出时路径 @@ -1871,12 +1871,12 @@ Choose one backup from combo above to restore it Show app icon instead default - 显示默认程序图标 + 显示应用程序图标代替默认 Instead of file name show: - 替换显示文件名称: + 代替文件名称显示: @@ -1884,10 +1884,10 @@ Choose one backup from combo above to restore it <appName> <appVersion> <packageName> - 详细信息: + 详细变量: <应用名称> <应用版本> -<安装包名> +<安装包名称> @@ -1947,7 +1947,7 @@ Choose one backup from combo above to restore it Sort by column: - 以列排序: + 以栏排序: @@ -1967,7 +1967,7 @@ Choose one backup from combo above to restore it App package name - 程序包名 + 应用程序包名称 @@ -1979,7 +1979,7 @@ Choose one backup from combo above to restore it only on start - 仅在启动时 + 仅在启动 @@ -1990,7 +1990,7 @@ Choose one backup from combo above to restore it every time on show - 始终显示 + 每一次都显示 @@ -2005,7 +2005,7 @@ Choose one backup from combo above to restore it Check app version on internet - 检查网上应用程序版本 + 在互联网检查应用程序版本 @@ -2020,7 +2020,7 @@ Choose one backup from combo above to restore it sd ext folder - SD卡扩展目录 + SD ext 目录 @@ -2050,7 +2050,7 @@ Choose one backup from combo above to restore it Color files - 色彩文件 + 彩色文件 @@ -2100,7 +2100,7 @@ Choose one backup from combo above to restore it Remove settings from system - 从系统中删除设置 + 从系统中设置删除 @@ -2115,7 +2115,7 @@ Choose one backup from combo above to restore it Associate apk files with QtADB - 使用QtADB关联apk文件 + 使用QtADB软件关联apk文件 @@ -2163,7 +2163,7 @@ Choose one backup from combo above to restore it Are you sure you want to associate *.apk files with QtADB??? - 你确定使用QtADB关联*.apk文件吗??? + 你确定使用QtADB软件关联*.apk文件吗??? @@ -2189,22 +2189,22 @@ QtADB 命令行工具帮助 CTRL+C - interrupt executing command - CTRL+C键 - 中断执行 + CTRL+C键 - 中断执行命令 ESC - interrupt executing command - ESC - 中断执行 + ESC - 中断执行命令 Shift+CTRL+C - copy selected text to clipboard - Shift+CTRL+C - 复制选中文本 + Shift+CTRL+C - 所选文本复制到剪贴板 Shift+CTRL+V - paste text from clipboard - Shift+CTRL+V - 粘贴文本 + Shift+CTRL+V - 从剪贴板粘贴文本 @@ -2214,12 +2214,12 @@ QtADB 命令行工具帮助 Up (arrow) - display previous executed command - 向上(箭头) - 显示上一条命令 + 向上(箭头) - 显示以前执行的命令 Down (arrow) - display next executed command - 向下(箭头) - 显示下一个命令 + 向下(箭头) - 显示下一个执行命令 @@ -2536,7 +2536,7 @@ QtADB 命令行工具帮助 Package name - 程序包名 + 程序包名称 @@ -2551,12 +2551,12 @@ QtADB 命令行工具帮助 Open in Market (PC) - 在电脑上用电子市场查看 + 在电子市场查看(电脑) Open in Market (Phone) - 在手机上用电子市场查看 + 在电子市场查看(手机) @@ -2602,7 +2602,7 @@ QtADB 命令行工具帮助 from: - 从: + 来源: diff --git a/main.cpp b/main.cpp index 796b102..f12463b 100644 --- a/main.cpp +++ b/main.cpp @@ -156,7 +156,7 @@ int main(int argc, char *argv[]) if (!sdkOk) { sdk.clear(); - QMessageBox *msgBox = new QMessageBox(QMessageBox::Critical, QObject::tr("error"), QObject::tr("there is no adb binary in here!")); + QMessageBox *msgBox = new QMessageBox(QMessageBox::Critical, QObject::tr("Error:"), QObject::tr("There is no adb binary in here!")); QPushButton *choosePathMsg = msgBox->addButton(QObject::tr("Choose path"), QMessageBox::AcceptRole); QPushButton *closeMsg = msgBox->addButton(QObject::tr("Close"), QMessageBox::RejectRole); @@ -188,7 +188,7 @@ int main(int argc, char *argv[]) if (proces.exitCode() != 0) { qDebug()<<"adb error - "<exec(); delete msgBox; return 1; @@ -202,8 +202,8 @@ int main(int argc, char *argv[]) if (tmp.contains("adbd cannot run as root in production builds") && !settings.value("disableProductionBuildsMessage",false).toBool()) { - QMessageBox *msgBox2 = new QMessageBox(QMessageBox::Critical, QObject::tr("error"), - QObject::tr("adbd cannot run as root in production builds so You can't do anything with /system partition. Run anyway?\n(press save to run QtADB and disable this message)"), + QMessageBox *msgBox2 = new QMessageBox(QMessageBox::Critical, QObject::tr("Error:"), + QObject::tr("adbd cannot run as root in production builds so you can't do anything with /system/ partition. Run anyway?\n(press save to run QtADB and disable this message.)"), QMessageBox::Yes | QMessageBox::No | QMessageBox::Save); int button = msgBox2->exec(); if ( button == QMessageBox::No) @@ -220,11 +220,13 @@ int main(int argc, char *argv[]) QStringList args = qApp->arguments(); if (args.count() > 1) { + QDir dir; if (args.at(1).endsWith(".apk")) { App *app = NULL; app = FileWidget::getAppInfo(args.at(1)); appInfo *appInfoDialog = new appInfo(app); + dir.rmdir(QDir::currentPath()+"/tmp/"); return appInfoDialog->exec(); } if (args.at(1) == "-install") @@ -241,6 +243,7 @@ int main(int argc, char *argv[]) appList.append(*app); } } + dir.rmdir(QDir::currentPath()+"/tmp/"); appDialog *appDialogInstall = new appDialog(appList, appDialog::Install, appDialog::None); return appDialogInstall->exec(); } diff --git a/qml/messages/delegates/ThreadDelegate.qml b/qml/messages/delegates/ThreadDelegate.qml index 2aa15cc..859eed9 100644 --- a/qml/messages/delegates/ThreadDelegate.qml +++ b/qml/messages/delegates/ThreadDelegate.qml @@ -28,7 +28,7 @@ Item Keys.onReleased: { - if (event.key == Qt.Key_Down || event.key == Qt.Key_Up) + if (event.key === Qt.Key_Down || event.key === Qt.Key_Up) { messageWidget.sort(threadId); } @@ -47,7 +47,7 @@ Item Rectangle { anchors.fill: parent - color: read == "0" ? "#2200ff00" : "#00000000" + color: read === "0" ? "#2200ff00" : "#00000000" } } @@ -104,19 +104,19 @@ Item acceptedButtons: Qt.LeftButton | Qt.RightButton onClicked: { - if (mouse.button == Qt.LeftButton) + if (mouse.button === Qt.LeftButton) { ListView.view.currentIndex = index threadItem.forceActiveFocus() messageWidget.filterMessages(threadId); messageList.opacity = 1 sendMessage.opacity = 1 - if (read == "0") + if (read === "0") { messageWidget.markThreadAsRead(threadId); } } - else if (mouse.button == Qt.RightButton ) + else if (mouse.button === Qt.RightButton ) { ListView.threadContextMenu.x = mouseX; ListView.threadContextMenu.y = mouseY; diff --git a/tools/dofixmarket.sh b/tools/dofixmarket.sh new file mode 100644 index 0000000..11d4627 --- /dev/null +++ b/tools/dofixmarket.sh @@ -0,0 +1,5 @@ +#! /system/bin/sh +cd /cache +mv download download.old +mkdir -p /sdcard/cache/download +ln -s /sdcard/cache/download download \ No newline at end of file diff --git a/tools/dolink2sd.sh b/tools/dolink2sd.sh new file mode 100644 index 0000000..290f831 --- /dev/null +++ b/tools/dolink2sd.sh @@ -0,0 +1,4 @@ +#!/sbin/sh +mount /system +cp /sbin/11link2sd /system/etc/init.d/11link2sd +umount /system \ No newline at end of file diff --git a/tools/domd5sum.sh b/tools/domd5sum.sh new file mode 100644 index 0000000..58169ba --- /dev/null +++ b/tools/domd5sum.sh @@ -0,0 +1,3 @@ +#! /system/bin/sh +cd $1 +md5sum -c nandroid.md5 \ No newline at end of file diff --git a/tools/dopartition.sh b/tools/dopartition.sh new file mode 100644 index 0000000..ac16ab7 --- /dev/null +++ b/tools/dopartition.sh @@ -0,0 +1,13 @@ +#!/sbin/sh +cp /cache/qtadb/e2fsck /sbin/e2fsck +cp /cache/qtadb/parted /sbin/parted +cp /cache/qtadb/sdparted /sbin/sdparted +rm /sbin/tune2fs +cp /cache/qtadb/tune2fs /sbin/tune2fs +rm -rf /cache/rommanager +sdparted -es $1 -ss 0M -efs $2 -s +RESULT=`echo $?` +if [ "$RESULT" != 0 ]; then + return 1 +fi +return 0 diff --git a/tools/dowipebatterystats.sh b/tools/dowipebatterystats.sh new file mode 100644 index 0000000..b155e62 --- /dev/null +++ b/tools/dowipebatterystats.sh @@ -0,0 +1,4 @@ +#!/sbin/sh +mount /data +rm -f /data/system/batterystats.bin +umount /data diff --git a/tools/dowipedalvikcache.sh b/tools/dowipedalvikcache.sh new file mode 100644 index 0000000..ce9f82f --- /dev/null +++ b/tools/dowipedalvikcache.sh @@ -0,0 +1,11 @@ +#!/sbin/sh +for partition in data cache system sd-ext +do + mount /$partition + rm -rf /$partition/dalvik-cache +done + +for partition in data system sd-ext +do + umount /$partition +done diff --git a/tools/dowipedalviklink2sd.sh b/tools/dowipedalviklink2sd.sh new file mode 100644 index 0000000..716d377 --- /dev/null +++ b/tools/dowipedalviklink2sd.sh @@ -0,0 +1,14 @@ +#!/sbin/sh +for partition in data cache system sd-ext +do + mount /$partition + rm -rf /$partition/dalvik-cache +done + +cp /cache/qtadb/dolink2sd.sh /sbin/dolink2sd.sh +cp /system/etc/init.d/11link2sd /sbin/11link2sd + +for partition in data system sd-ext +do + umount /$partition +done diff --git a/tools/e2fsck b/tools/e2fsck new file mode 100644 index 0000000..2844a1d Binary files /dev/null and b/tools/e2fsck differ diff --git a/tools/fix_permissions b/tools/fix_permissions new file mode 100644 index 0000000..1bd6261 --- /dev/null +++ b/tools/fix_permissions @@ -0,0 +1,484 @@ +#! /system/bin/sh +# +# Warning: if you want to run this script in cm-recovery change the above to #!/sbin/sh +# +# fix_permissions - fixes permissions on Android data directories after upgrade +# shade@chemlab.org +# +# original concept: http://blog.elsdoerfer.name/2009/05/25/android-fix-package-uid-mismatches/ +# implementation by: Cyanogen +# improved by: ankn, smeat, thenefield, farmatito, rikupw, Kastro +# +# v1.1-v1.31r3 - many improvements and concepts from XDA developers. +# v1.34 through v2.00 - A lot of frustration [by Kastro] +# v2.01 - Completely rewrote the script for SPEED, thanks for the input farmatito +# /data/data depth recursion is tweaked; +# fixed single mode; +# functions created for modularity; +# logging can be disabled via CLI for more speed; +# runtime computation added to end (Runtime: mins secs); +# progress (current # of total) added to screen; +# fixed CLI argument parsing, now you can have more than one option!; +# debug cli option; +# verbosity can be disabled via CLI option for less noise;; +# [by Kastro, (XDA: k4str0), twitter;mattcarver] +# v2.02 - ignore com.htc.resources.apk if it exists and minor code cleanups, +# fix help text, implement simulated run (-s) [farmatito] +# v2.03 - fixed chown group ownership output [Kastro] +# v2.04 - replaced /system/sd with $SD_EXT_DIRECTORY [Firerat] +VERSION="2.04" + +# Defaults +DEBUG=0 # Debug off by default +LOGGING=1 # Logging on by default +VERBOSE=1 # Verbose on by default + +# Messages +UID_MSG="Changing user ownership for:" +GID_MSG="Changing group ownership for:" +PERM_MSG="Changing permissions for:" + +# Programs needed +ECHO="busybox echo" +GREP="busybox grep" +EGREP="busybox egrep" +CAT="busybox cat" +CHOWN="busybox chown" +CHMOD="busybox chmod" +MOUNT="busybox mount" +UMOUNT="busybox umount" +CUT="busybox cut" +FIND="busybox find" +LS="busybox ls" +TR="busybox tr" +TEE="busybox tee" +TEST="busybox test" +SED="busybox sed" +RM="busybox rm" +WC="busybox wc" +EXPR="busybox expr" +DATE="busybox date" + +# Initialise vars +CODEPATH="" +LOCALUID="" +LOCALGID="" +PACKAGE="" +REMOVE=0 +NOSYSTEM=0 +ONLY_ONE="" +SIMULATE=0 +SYSREMOUNT=0 +SYSMOUNT=0 +DATAMOUNT=0 +SYSSDMOUNT=0 +FP_STARTTIME=$( $DATE +"%m-%d-%Y %H:%M:%S" ) +FP_STARTEPOCH=$( $DATE +%s ) +if $TEST "$SD_EXT_DIRECTORY" = ""; then + #check for mount point, /system/sd included in tests for backward compatibility + for MP in /sd-ext /system/sd;do + if $TEST -d $MP; then + SD_EXT_DIRECTORY=$MP + break + fi + done +fi +fp_usage() +{ + $ECHO "Usage $0 [OPTIONS] [APK_PATH]" + $ECHO " -d turn on debug" + $ECHO " -f fix only package APK_PATH" + $ECHO " -l disable logging for this run (faster)" + $ECHO " -r remove stale data directories" + $ECHO " of uninstalled packages while fixing permissions" + $ECHO " -s simulate only" + $ECHO " -u check only non-system directories" + $ECHO " -v disable verbosity for this run (less output)" + $ECHO " -V print version" + $ECHO " -h this help" +} + +fp_parseargs() +{ + # Parse options + while $TEST $# -ne 0; do + case "$1" in + -d) + DEBUG=1 + ;; + -f) + if $TEST $# -lt 2; then + $ECHO "$0: missing argument for option $1" + exit 1 + else + if $TEST $( $ECHO $2 | $CUT -c1 ) != "-"; then + ONLY_ONE=$2 + shift; + else + $ECHO "$0: missing argument for option $1" + exit 1 + fi + fi + ;; + -r) + REMOVE=1 + ;; + -s) + SIMULATE=1 + ;; + -l) + if $TEST $LOGGING -eq 0; then + LOGGING=1 + else + LOGGING=0 + fi + ;; + -v) + if $TEST $VERBOSE -eq 0; then + VERBOSE=1 + else + VERBOSE=0 + fi + ;; + -u) + NOSYSTEM=1 + ;; + -V) + $ECHO "$0 $VERSION" + exit 0 + ;; + -h) + fp_usage + exit 0 + ;; + -*) + $ECHO "$0: unknown option $1" + $ECHO + fp_usage + exit 1 + ;; + esac + shift; + done +} + +fp_print() +{ + MSG=$@ + if $TEST $LOGGING -eq 1; then + $ECHO $MSG | $TEE -a $LOG_FILE + else + $ECHO $MSG + fi +} + +fp_start() +{ + if $TEST $SIMULATE -eq 0 ; then + if $TEST $( $GREP -c " /system " "/proc/mounts" ) -ne 0; then + DEVICE=$( $GREP " /system " "/proc/mounts" | $CUT -d ' ' -f1 ) + if $TEST $DEBUG -eq 1; then + fp_print "/system mounted on $DEVICE" + fi + if $TEST $( $GREP " /system " "/proc/mounts" | $GREP -c " ro " ) -ne 0; then + $MOUNT -o remount,rw $DEVICE /system + SYSREMOUNT=1 + fi + else + $MOUNT /system > /dev/null 2>&1 + SYSMOUNT=1 + fi + + if $TEST $( $GREP -c " /data " "/proc/mounts" ) -eq 0; then + $MOUNT /data > /dev/null 2>&1 + DATAMOUNT=1 + fi + + if $TEST -e /dev/block/mmcblk0p2 && $TEST $( $GREP -c " $SD_EXT_DIRECTORY " "/proc/mounts" ) -eq 0; then + $MOUNT $SD_EXT_DIRECTORY > /dev/null 2>&1 + SYSSDMOUNT=1 + fi + fi + if $TEST $( $MOUNT | $GREP -c /sdcard ) -eq 0; then + LOG_FILE="/data/fix_permissions.log" + else + LOG_FILE="/sdcard/fix_permissions.log" + fi + if $TEST ! -e "$LOG_FILE"; then + > $LOG_FILE + fi + + fp_print "$0 $VERSION started at $FP_STARTTIME" +} + +fp_chown_uid() +{ + FP_OLDUID=$1 + FP_UID=$2 + FP_FILE=$3 + + #if user ownership doesn't equal then change them + if $TEST "$FP_OLDUID" != "$FP_UID"; then + if $TEST $VERBOSE -ne 0; then + fp_print "$UID_MSG $FP_FILE from '$FP_OLDUID' to '$FP_UID'" + fi + if $TEST $SIMULATE -eq 0; then + $CHOWN $FP_UID "$FP_FILE" + fi + fi +} + +fp_chown_gid() +{ + FP_OLDGID=$1 + FP_GID=$2 + FP_FILE=$3 + + #if group ownership doesn't equal then change them + if $TEST "$FP_OLDGID" != "$FP_GID"; then + if $TEST $VERBOSE -ne 0; then + fp_print "$GID_MSG $FP_FILE from '$FP_OLDGID' to '$FP_GID'" + fi + if $TEST $SIMULATE -eq 0; then + $CHOWN :$FP_GID "$FP_FILE" + fi + fi +} + +fp_chmod() +{ + FP_OLDPER=$1 + FP_OLDPER=$( $ECHO $FP_OLDPER | cut -c2-10 ) + FP_PERSTR=$2 + FP_PERNUM=$3 + FP_FILE=$4 + + #if the permissions are not equal + if $TEST "$FP_OLDPER" != "$FP_PERSTR"; then + if $TEST $VERBOSE -ne 0; then + fp_print "$PERM_MSG $FP_FILE from '$FP_OLDPER' to '$FP_PERSTR' ($FP_PERNUM)" + fi + #change the permissions + if $TEST $SIMULATE -eq 0; then + $CHMOD $FP_PERNUM "$FP_FILE" + fi + fi +} + +fp_all() +{ + FP_NUMS=$( $CAT /data/system/packages.xml | $EGREP "^ /dev/null 2>&1 + fi + + if $TEST $SYSSDMOUNT -eq 1; then + $UMOUNT $SD_EXT_DIRECTORY > /dev/null 2>&1 + fi + + if $TEST $SYSMOUNT -eq 1; then + $UMOUNT /system > /dev/null 2>&1 + fi + + if $TEST $DATAMOUNT -eq 1; then + $UMOUNT /data > /dev/null 2>&1 + fi + + FP_ENDTIME=$( $DATE +"%m-%d-%Y %H:%M:%S" ) + FP_ENDEPOCH=$( $DATE +%s ) + + date_diff $FP_STARTEPOCH $FP_ENDEPOCH + + fp_print "$0 $VERSION ended at $FP_ENDTIME (Runtime:${FP_DDM}m${FP_DDS}s)" +} + +#MAIN SCRIPT + +fp_parseargs $@ +fp_start +if $TEST "$ONLY_ONE" != "" -a "$ONLY_ONE" != "0" ; then + fp_single "$ONLY_ONE" +else + fp_all +fi +fp_end diff --git a/tools/flash_image b/tools/flash_image new file mode 100644 index 0000000..18036d0 Binary files /dev/null and b/tools/flash_image differ diff --git a/tools/parted b/tools/parted new file mode 100644 index 0000000..bb3d432 Binary files /dev/null and b/tools/parted differ diff --git a/tools/sdparted b/tools/sdparted new file mode 100644 index 0000000..74e24a6 --- /dev/null +++ b/tools/sdparted @@ -0,0 +1,655 @@ +#!/sbin/sh + +# do logging, if not excluded with -x +LOGFILE="/data/sdparted.log" +[ "$1" != "-x" ] && echo "$0" "$@" >> "$LOGFILE" && "$0" -x "$@" 2>&1 | tee -a "$LOGFILE" && exit +shift + +ShowError() { echo ; echo " err: $1" ; echo ; exit 1 ; } + +ShowMessage() { echo ; echo " msg: $1" ; } + +ShowHelp() { + +cat <. + default=total sdcard size - (ext + swap) + + --extsize|-es SIZE[MG] set the size of the ext partition to . + default=$EXTSIZE + + --swapsize|-ss SIZE[MG] set the size of the swap partition to . + if set to 0, no swap partition will be created. + default=$SWAPSIZE + + --extfs|-efs TYPE set the filesystem of ext partition to . + valid types=ext2, ext3, ext4 + default=$EXTFS + + + --upgradefs|-ufs TYPE upgrades existing ext partition to . + this operation will NOT wipe your sdcard and + cannot be used with any partition creation options. + valid types=ext3, ext4 + + --downgradefs|-dfs TYPE downgrades existing ext partition to . + this operation will NOT wipe your sdcard and + cannot be used with any partition creation options. + valid types=ext2 + + + --interactive|-i interactive mode + + --help|-h display this help + + --printonly|-po display sdcard information + + --silent|-s do not prompt user, not even initial warning. + + +examples: + $SCRIPTNAME creates swap=$SWAPSIZE ext2=$EXTSIZE fat32=remaining free space + $SCRIPTNAME -efs ext4 creates swap=$SWAPSIZE ext4=$EXTSIZE fat32=remaining free space + $SCRIPTNAME -fs 1.5G -efs ext3 creates swap=$SWAPSIZE ext3=$EXTSIZE fat32=1536 + $SCRIPTNAME -es 256M -ss 0 creates no swap ext2=256 fat32=remaining free space + $SCRIPTNAME -ufs ext4 upgrades ext partition to ext4 + +DONEHELP + +} + +UserAbort() { + + WHILEEXIT= + + while [ -z "$WHILEEXIT" ] + do + echo -n "do you want to continue? (Y/n) " + read response + echo + [ "$response" = "Y" ] || [ "$response" = "n" ] || [ "$response" = "N" ] && WHILEEXIT="$response" + done + + echo "$response" > /dev/null 2>&1 >>"$LOGFILE" + + [ "$response" != "Y" ] + +} + +UnmountAll () { + + # unmount all partitions so we can work with $SDPATH + # i'm assuming no more than 3 partitions + # maybe make a little more elegant later + echo -n "unmounting all partitions..." + umount "$FATPATH" > /dev/null 2>&1 >>"$LOGFILE" + umount "$EXTPATH" > /dev/null 2>&1 >>"$LOGFILE" + umount "$SWAPPATH" > /dev/null 2>&1 >>"$LOGFILE" + echo "done" + echo + +} + + +CheckReqs() { + + echo -n "checking script requirements..." + # check for valid sdcard + [ -e $SDPATH ] || ShowError "$SDPATH does not exist!" + + # look for necessary programs + [ -e $CMPARTED ] || ShowError "$CMPARTED does not exist!" + [ -e $CMTUNE2FS ] || ShowError "$CMTUNE2FS does not exist!" + [ -e $CME2FSCK ] || ShowError "$CME2FSCK does not exist!" + + # verify cm-v1.4 + PARTEDREV=`"$CMPARTED" "$SDPATH" version | grep Parted | cut -d" " -f3` + [ "$PARTEDREV" == "1.8.8.1.179-aef3" ] || ShowError "you are not using parted v1.8.8.1.179-aef3!" + echo "done" + echo + +} + +CheckTableType() { + + TABLETYPE=`"$CMPARTED" "$SDPATH" print | grep Table: | cut -d" " -f3` + + [ "$TABLETYPE" == "loop" -o "$TABLETYPE" == "msdos" ] && TTISOK=1 || TTISOK=0 + [ "$TABLETYPE" == "loop" ] && TTISLOOP=1 || TTISLOOP=0 + [ "$TABLETYPE" == "msdos" ] && TTISMSDOS=1 || TTISMOSDOS=0 + +} + +ValidateExtArg() { + + FUNC_RET="nonzero" + + # validating argument + [ "$1" != "ext2" ] && [ "$1" != "ext3" ] && [ "$1" != "ext4" ] && FUNC_RET= + + [ -z "$FUNC_RET" ] && [ -z "$IMODE" ] && ShowError "$1 is not a valid filesystem." + [ -z "$FUNC_RET" ] && [ -n "$IMODE" ] && ShowMessage "$1 is not a valid filesystem." + + # return valid argument + [ -n "$FUNC_RET" ] && FUNC_RET="$1" + +} + +ValidateSizeArg() { + + # check for zero-length arg to protect expr length + [ -z "$1" ] && ShowError "zero-length argument passed to size-validator" + + SIZEMB= + ARGLEN=`expr length $1` + SIZELEN=$(($ARGLEN-1)) + SIZEARG=`expr substr $1 1 $SIZELEN` + SIZEUNIT=`expr substr $1 $ARGLEN 1` + + # check if SIZEARG is an integer + if [ $SIZEARG -eq $SIZEARG 2> /dev/null ] ; then + # look for G + [ "$SIZEUNIT" == "G" ] && SIZEMB=$(($SIZEARG * 1024)) + # look for M + [ "$SIZEUNIT" == "M" ] && SIZEMB=$SIZEARG + # no units on arg AND prevents using bogus size units + [ -z "$SIZEMB" ] && [ $SIZEUNIT -eq $SIZEUNIT 2> /dev/null ] && SIZEMB=$1 + # check if SIZEARG is a floating point number, GB only + elif [ `expr index "$SIZEARG" .` != 0 ] && [ "$SIZEUNIT" == "G" ] ; then + INT=`echo "$SIZEARG" | cut -d"." -f1` + FRAC=`echo "$SIZEARG" | cut -d"." -f2` + SIGDIGITS=`expr length $FRAC` + + [ -z "$INT" ] && INT=0 + INTMB=$(($INT * 1024)) + FRACMB=$((($FRAC * 1024) / (10**$SIGDIGITS))) + SIZEMB=$(($INTMB + $FRACMB)) + # it's not a valid size + else + [ -z "$IMODE" ] && ShowError "$1 is not a valid size" + fi + + [ -z "$SIZEMB" ] && [ -n "$IMODE" ] && ShowMessage "$1 is not a valid size" + + # return valid argument in MB + FUNC_RET=$SIZEMB + +} + +CalculatePartitions() { + + # get size of sdcard in MB & do some math + SDSIZEMB=`"$CMPARTED" "$SDPATH" unit MB print | grep $SDPATH | cut -d" " -f3` + SDSIZE=${SDSIZEMB%MB} + [ -n "$FATSIZE" ] || FATSIZE=$(($SDSIZE - $EXTSIZE - $SWAPSIZE)) + EXTEND=$(($FATSIZE + $EXTSIZE)) + SWAPEND=$(($EXTEND + $SWAPSIZE)) + + # check for fatsize of 0 + [ $FATSIZE -le 0 ] && ShowError "must have a fat32 partition greater than 0MB" + + # check for zero-length sdsize... + # indicative of parted not reporting length + # correctly b/c of error on sdcard + [ -z "$SDSIZE" ] && ShowError "zero-length argument passed to partition-calculator" + + # make sure we're not being asked to do the impossible + [ $(($FATSIZE + $EXTSIZE + $SWAPSIZE)) -gt $SDSIZE ] && [ -z "$IMODE" ] && ShowError "sum of requested partitions is greater than sdcard size" + +} + + +UpgradeDowngradeOnly() { + + if [ -n "$UEXTFSONLY" ] ; then + echo + [ -n "$CREATEPART" ] && ShowError "cannot use upgrade option when creating partitions, use -efs instead" + [ -n "$DEXTFSONLY" ] && ShowError "cannot upgrade AND downgrade, it just doesn't make sense" + echo "you have chosen to upgrade $EXTPATH to $UEXTFSONLY." + echo "this action will NOT delete any data from sdcard." + echo + [ -z "$SILENTRUN" ] && UserAbort && ShowError "script canceled by user" + echo + UpgradeExt "$UEXTFSONLY" + ShowCardInfo + elif [ -n "$DEXTFSONLY" ] ; then + echo + [ -n "$CREATEPART" ] && ShowError "cannot use downgrade option when creating partitions." + [ -n "$UEXTFSONLY" ] && ShowError "cannot downgrade AND upgrade, it just doesn't make sense." + echo "you have chosen to downgrade $EXTPATH to $DEXTFSONLY." + echo "this action will NOT delete any data from sdcard." + echo + [ -z "$SILENTRUN" ] && UserAbort && ShowError "script canceled by user" + echo + DowngradeExt "$DEXTFSONLY" + ShowCardInfo + fi + +} + +PrepareSdCard() { + + echo + if [ $TTISOK -eq 0 ] ; then + echo "partition 1 may not be aligned to cylinder boundaries." + echo "to continue, this must be corrected." + elif [ $TTISLOOP -gt 0 ] ; then + echo "your sdcard's partition table type is $TABLETYPE." + echo "to continue, partition table must be set to 'msdos'." + elif [ $TTISMSDOS -gt 0 ] ; then + # just a reminder..in a later version, + # i may implement resizing of partitions, + # so this will be unnecessary. but until then... + echo "to continue, all existing partitions must be removed." + else + # this is not good, and should never happen + # if it does, there is a serious problem + ShowError "sdcard failed table type check." + fi + + echo + echo "this action will remove all data from your sdcard." + echo + [ -z "$SILENTRUN" ] && UserAbort && ShowError "script canceled by user" + + [ $TTISOK -eq 0 ] && echo -n "correcting cylinder boundaries..." + [ $TTISLOOP -gt 0 ] && echo -n "setting partition table to msdos..." + [ $TTISMSDOS -gt 0 ] && echo -n "removing all partitions..." + + "$CMPARTED" -s "$SDPATH" mklabel msdos 2>&1 >>"$LOGFILE" + echo "done" + echo + +} + +ShowActions() { + + echo + echo "total size of sdcard=$SDSIZEMB" + echo + echo "the following actions will be performed:" + echo " -create $FATSIZE""MB fat32 partition" + [ $EXTSIZE -gt 0 ] && echo " -create $EXTSIZE""MB ext2 partition" + [ $SWAPSIZE -gt 0 ] && echo " -create $SWAPSIZE""MB swap partition" + [ "$EXTFS" != "ext2" ] && echo " -ext2 partition will be upgraded to $EXTFS" + echo + [ -z "$SILENTRUN" ] && UserAbort && ShowError "script canceled by user" + echo + +} + +ShowCardInfo() { + + CheckTableType + + echo + echo "retrieving current sdcard information..." + + if [ $TTISOK -gt 0 ] ; then + echo + parted "$SDPATH" print + echo + echo "script log is located @ /data/sdparted.log" + exit 0 + else + echo + echo "partition 1 may not be aligned to cylinder boundaries." + ShowError "cannot complete print operation." + fi + echo + +} + + +PartitionSdCard() { + + echo "performing selected actions..." + echo + + if [ $FATSIZE -gt 0 ] ; then + echo -n "creating fat32 partition..." + "$CMPARTED" -s "$SDPATH" mkpartfs primary fat32 0 "$FATSIZE"MB 2>&1 >>"$LOGFILE" + echo "done" + fi + + if [ $EXTSIZE -gt 0 ] ; then + echo -n "creating ext2 partition..." + "$CMPARTED" -s "$SDPATH" mkpartfs primary ext2 "$FATSIZE"MB "$EXTEND"MB 2>&1 >>"$LOGFILE" + "$CMTUNE2FS" -L sd-ext "$EXTPATH" 2>&1 >>"$LOGFILE" + echo "done" + fi + + if [ $SWAPSIZE -gt 0 ] ; then + echo -n "creating swap partition..." + "$CMPARTED" -s "$SDPATH" mkpartfs primary linux-swap "$EXTEND"MB "$SWAPEND"MB 2>&1 >>"$LOGFILE" + echo "done" + fi + echo + +} + +UpgradeExt() { + + # check for no upgrade + [ "$1" == "ext2" ] && return + # check for ext partition + [ ! -e "$EXTPATH" ] && ShowError "$EXTPATH does not exist" + + # have to use -m switch for this check b/c parted incorrectly + # reports all ext partitions as ext2 when running print + CHECKEXTFS=`"$CMPARTED" -m "$SDPATH" print | grep ext | cut -d":" -f5` + [ "$CHECKEXTFS" == "$1" ] && ShowError "$EXTPATH is already $1" + + # grabbed the code bits for ext3 from upgrade_fs(credit:cyanogen) + # check for ext2...must upgrade to ext3 first b4 ext4 + if [ "$1" == "ext3" -o "$1" == "ext4" ] ; then + echo -n "adding journaling to $EXTPATH..." + umount /system/sd > /dev/null 2>&1 >>"$LOGFILE" + "$CME2FSCK" -p "$EXTPATH" 2>&1 >>"$LOGFILE" + "$CMTUNE2FS" -c0 -i0 -j "$EXTPATH" 2>&1 >>"$LOGFILE" + echo "done" + fi + + # and got convert to ext4 from xda-forum(credit:Denkai) + if [ "$1" == "ext4" ] ; then + echo -n "converting $EXTPATH to ext4 filesystem..." + umount /system/sd > /dev/null 2>&1 >>"$LOGFILE" + "$CMTUNE2FS" -O extents,uninit_bg,dir_index "$EXTPATH" 2>&1 >>"$LOGFILE" + "$CME2FSCK" -fpDC0 "$EXTPATH" 2>&1 >>"$LOGFILE" + echo "done" + fi + echo + +} + +DowngradeExt() { + + # check for ext partition + [ ! -e "$EXTPATH" ] && ShowError "$EXTPATH does not exist" + + # have to use print for this check b/c parted incorrectly + # reports all ext partitions as ext2 when running print + CHECKEXTFS=`"$CMPARTED" -m "$SDPATH" print | grep ext | cut -d":" -f5` + [ "$CHECKEXTFS" == "$1" ] && ShowError "$EXTPATH is already $1" + + if [ "$CHECKEXTFS" == "ext4" -o "$1" == "ext3" ] ; then + # interweb says downgrading from ext4 is not possible + # without a backup/restore procedure. + # if i figure it out, i'll implement it. + ShowError "downgrading from ext4 is not currently supported" + fi + + if [ "$1" == "ext2" ] ; then + echo -n "removing journaling from $EXTPATH..." + umount /system/sd > /dev/null 2>&1 >>"$LOGFILE" + "$CMTUNE2FS" -O ^has_journal "$EXTPATH" 2>&1 >>"$LOGFILE" + "$CME2FSCK" -fp "$EXTPATH" 2>&1 >>"$LOGFILE" + echo "done" + fi + echo + +} + + +Interactive() { + +cat < /dev/null 2>&1 >>"$LOGFILE" + + ValidateSizeArg "$SWAPRESP" + SWAPTEST="$FUNC_RET" + [ -n "$SWAPTEST" ] && [ $SWAPTEST -gt $SDSIZE ] && ShowMessage "$SWAPRESP > available space($(($SDSIZE))M)." && SWAPTEST= + done + + SWAPSIZE=$SWAPTEST + +} + +GetExtSize() { + + EXTTEST= + + while [ -z "$EXTTEST" ] + do + echo + echo -n "ext partition size [default=$EXTSIZE]: " + read EXTRESP + + [ -z "$EXTRESP" ] && EXTRESP="$EXTSIZE" + echo "$EXTRESP" > /dev/null 2>&1 >>"$LOGFILE" + + ValidateSizeArg "$EXTRESP" + EXTTEST="$FUNC_RET" + + [ -n "$EXTTEST" ] && [ $EXTTEST -gt $(($SDSIZE - $SWAPSIZE)) ] && ShowMessage "$EXTRESP > available space($(($SDSIZE - $SWAPSIZE))M)." && EXTTEST= + done + + EXTSIZE=$EXTTEST + +} + +GetExtType() { + + FSTEST= + + while [ -z "$FSTEST" ] + do + echo + echo -n "ext partition type [default=$EXTFS]: " + read FSRESP + + [ -z "$FSRESP" ] && FSRESP="$EXTFS" + echo "$FSRESP" > /dev/null 2>&1 >>"$LOGFILE" + + ValidateExtArg "$FSRESP" + FSTEST="$FUNC_RET" + done + + EXTFS="$FSTEST" + +} + +GetFatSize() { + + FATTEST= + + while [ -z "$FATTEST" ] + do + echo + echo -n "fat partition size [default=$FATSIZE]: " + read FATRESP + + [ -z "$FATRESP" ] && FATRESP="$FATSIZE" + echo "$FATRESP" > /dev/null 2>&1 >>"$LOGFILE" + + ValidateSizeArg "$FATRESP" + FATTEST="$FUNC_RET" + + [ -n "$FATTEST" ] && [ $FATTEST -gt $FATSIZE ] && ShowMessage "$FATRESP > available space($(($SDSIZE - $SWAPSIZE - $EXTSIZE))M)." && FATTEST= + [ -n "$FATTEST" ] && [ $FATTEST -le 0 ] && ShowMessage "must have a fat32 partition greater than 0MB" && FATTEST= + done + + FATSIZE=$FATTEST + +} + + +SCRIPTNAME="sdparted" +SCRIPTREV="0.6" +MYNAME="51dusty" + +IMODE= +SILENTRUN= +CREATEPART= +FUNC_RET= + +UEXTFSONLY= +DEXTFSONLY= + +TTISOK= +TTISLOOP= +TTISMSDOS= + +SDSIZE= +SDSIZEMB= +SDINFO=$(cat /etc/fstab | grep /sdcard | awk '{print $1}') +if [ -L "$SDINFO" ] +then + SDPATH=$(ls -l $SDINFO | awk '{print $11}') +else + SDPATH=$SDINFO +fi +# we may now have an SDPATH, let's make sure its on mmcblkX or mmcblkXp1 +CHECK_SDPATH1=$(echo $SDPATH | grep mmcblk.$) +CHECK_SDPATH2=$(echo $SDPATH | grep mmcblk.p1$) +if [ -z "$CHECK_SDPATH1" ] +then + if [ -z "$CHECK_SDPATH2" ] + then + echo fail1 + unset SDPATH + else + LEN=${#SDPATH} + BLKLEN=$(expr $LEN - 2) + SDPATH=${SDPATH:0:$BLKLEN} + fi +fi + + +FATSIZE= +FATTYPE="fat32" +FATPATH=$SDPATH"p1" + +EXTSIZE=512 +EXTFS="ext2" +EXTPATH=$SDPATH"p2" +EXTEND= + +SWAPSIZE=32 +SWAPTYPE="linux-swap" +SWAPPATH=$SDPATH"p3" +SWAPEND= + +CMPARTED="/sbin/parted" +CMTUNE2FS="/sbin/tune2fs" +CME2FSCK="/sbin/e2fsck" + +# give the output some breathing room +echo "$SCRIPTREV" >> "$LOGFILE" +echo + +# check for arguments +while [ $# -gt 0 ] ; do + case "$1" in + + -h|--help) ShowHelp ; exit 0 ;; + + -fs|--fatsize) shift ; ValidateSizeArg "$1" ; FATSIZE="$FUNC_RET" ; CREATEPART="$1" ;; + -es|--extsize) shift ; ValidateSizeArg "$1" ; EXTSIZE="$FUNC_RET" ; CREATEPART="$1" ;; + -ss|--swapsize) shift ; ValidateSizeArg "$1" ; SWAPSIZE="$FUNC_RET" ; CREATEPART="$1" ;; + -efs|--extfs) shift ; ValidateExtArg "$1" ; EXTFS="$FUNC_RET" ; CREATEPART="$1" ;; + + -ufs|--upgradefs) shift ; ValidateExtArg "$1" ; UEXTFSONLY="$FUNC_RET" ;; + -dfs|--downgradefs) shift ; ValidateExtArg "$1" ; DEXTFSONLY="$FUNC_RET" ;; + + -i|--interactive) IMODE="$1" ;; + + -s|--silent) SILENTRUN="$1" ;; + + -po|--printonly) ShowCardInfo ;; + + *) ShowHelp ; ShowError "unknown argument '$1'" ;; + + esac + shift +done + +# can't do silent when in interactive mode +[ -n "$IMODE" ] && SILENTRUN= + +# make sure sdcard exists and all needed files are here +CheckReqs + +# unmount all +UnmountAll + +# upgrade only? downgrade only? +UpgradeDowngradeOnly + +# check table +CheckTableType + +# prep card +PrepareSdCard + +# check for interactive mode +[ -n "$IMODE" ] && Interactive + +# do some math +CalculatePartitions + +# last chance to cancel +ShowActions + +# partition card +PartitionSdCard + +# upgrade fs if necessary +UpgradeExt "$EXTFS" + +# say goodbye and show print output +ShowCardInfo diff --git a/tools/tune2fs b/tools/tune2fs new file mode 100644 index 0000000..4bd02f6 Binary files /dev/null and b/tools/tune2fs differ diff --git a/tools/undofixmarket.sh b/tools/undofixmarket.sh new file mode 100644 index 0000000..83564d5 --- /dev/null +++ b/tools/undofixmarket.sh @@ -0,0 +1,5 @@ +#! /system/bin/sh +cd /cache +rm -f -r download +mv download.old download +rm -f -r /sdcard/cache/ \ No newline at end of file diff --git a/widgets/appwidget.cpp b/widgets/appwidget.cpp index bebb929..1e0d776 100644 --- a/widgets/appwidget.cpp +++ b/widgets/appwidget.cpp @@ -38,6 +38,12 @@ AppWidget::AppWidget(QWidget *parent) : this->backupModel = new BackupTableModel; this->backupSortModel = new BackupSortModel; + this->ui->tableView->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); + this->ui->tableView->horizontalHeader()->setResizeMode(QHeaderView::ResizeToContents); + this->ui->tableView->resizeColumnsToContents(); + this->ui->tableView->horizontalHeader()->setStretchLastSection(true); + + this->appSortModel->setSourceModel(this->appModel); this->systemAppSortModel->setSourceModel(this->systemAppModel); this->backupSortModel->setSourceModel(this->backupModel); @@ -51,8 +57,8 @@ AppWidget::AppWidget(QWidget *parent) : this->ui->stackedAppsPageApps->setLayout(this->ui->horizontalLayoutStackedApps); this->ui->stackedAppsPageBackups->setLayout(this->ui->horizontalLayoutBackup); - this->appMenu = NULL; - this->backupMenu = NULL; + //this->appMenu = NULL; + // this->backupMenu = NULL; QSettings settings; this->phone = new Phone(settings.value("sdkPath").toString(),false); @@ -115,6 +121,10 @@ AppWidget::AppWidget(QWidget *parent) : this->ui->tableView->setContextMenuPolicy(Qt::CustomContextMenu); this->setLayout(ui->layoutApps); this->comboBoxAppsChanged(); + + this->codec = QTextCodec::codecForLocale(); + threadApps.codec = this->codec; + threadBackups.codec = this->codec; } AppWidget::~AppWidget() @@ -123,22 +133,29 @@ AppWidget::~AppWidget() delete this->phone; } +//void AppWidget::mousePressEvent(QMouseEvent *event) +//{ + // if (event->button() == Qt::RightButton) + // emit this->myContextMenuRequested(event->pos()); + // qDebug()<<"context menu requested"<type()) { case QEvent::LanguageChange: ui->retranslateUi(this); - if (this->appMenu != NULL) + if (this->customMenu != NULL) { - foreach(QAction *action, this->appMenu->actions()) - action->setText(tr(action->data().toString().toAscii())); - } - if (this->backupMenu != NULL) - { - foreach(QAction *action, this->backupMenu->actions()) + foreach(QAction *action, this->customMenu->actions()) action->setText(tr(action->data().toString().toAscii())); } + // if (this->backupMenu != NULL) + // { + // foreach(QAction *action, this->backupMenu->actions()) + // action->setText(tr(action->data().toString().toAscii())); + // } foreach(QAction *action, this->ui->toolButtonBackup->menu()->actions()) action->setText(tr(action->data().toString().toAscii())); foreach(QAction *action, this->ui->toolButtonRestore->menu()->actions()) @@ -171,6 +188,8 @@ void AppWidget::copyAppToPC() tr("Choose where You want to save selected apps"), "", QFileDialog::ShowDirsOnly); + qDebug()<<"Choose where You want to save selected apps"<dialog != NULL) delete this->dialog; this->dialog = new dialogKopiuj(this, tmpList, this->sdk, dialogKopiuj::AppsToComputer, path); @@ -180,7 +199,7 @@ void AppWidget::copyAppToPC() this->dialog->setModal(true); this->dialog->show(); } - +/* void AppWidget::appsContextMenu(const QPoint &pos) { if (this->appMenu == NULL) @@ -200,8 +219,49 @@ void AppWidget::appsContextMenu(const QPoint &pos) this->appMenu->exec(ui->tableView->mapToGlobal(pos2)); + qDebug()<<"context menu requested"<comboBoxApps->currentIndex()==1)//backups + { + this->customMenu = new QMenu; + this->customMenu->addMenu(this->ui->toolButtonRestore->menu())->setData(QString("restore")); + if (addToBackup() == "noData") + this->customMenu->addAction(QIcon(":/icons/backup.png"),tr("Add data to Backup", "right click backups menu"),this,SLOT(toolButtonBackupData()))->setData(QString("Add data to Backup")); + if (addToBackup() == "noApk") + this->customMenu->addAction(QIcon(":/icons/backup.png"),tr("Add app to Backup", "right click backups menu"),this,SLOT(toolButtonBackupApp()))->setData(QString("Add app to Backup")); + this->customMenu->addAction(QIcon(":icons/remove.png"),tr("remove", "right click backups menu"),this,SLOT(on_toolButtonRemoveBackup_pressed()))->setData(QString("remove")); + } + else + { + this->customMenu = new QMenu; //system apps + QAction *backup; + backup = this->customMenu->addMenu(this->ui->toolButtonBackup->menu()); + backup->setData(QString("backup")); + this->customMenu->addAction(QIcon(":icons/uninstall.png"),tr("uninstall", "right click apps menu"),this,SLOT(on_toolButtonUninstall_pressed()))->setData(QString("uninstall")); + this->customMenu->addAction(QIcon(":icons/save.png"),tr("copy to PC", "right click apps menu"), this, SLOT(copyAppToPC()))->setData(QString("copy to PC")); + this->customMenu->addAction(QIcon(":/icons/info.png"), tr("Get app info", "right click apps menu"), this, SLOT(getAppInfo()))->setData(QString("Get app info")); + if (ui->comboBoxApps->currentIndex()==0)//apps + { + this->customMenu->addAction(QIcon(":/icons/market.png"),tr("Get apps version from internet", "right click apps menu"), this, SLOT(getCyrketVersions()))->setData(QString("Get apps version from internet")); + } + } + QPoint pos2; + pos2.setX(pos.x()); + pos2.setY(pos.y()+20); + this->customMenu->exec(ui->tableView->mapToGlobal(pos2)); + qDebug()<<"Apps context menu requested"<maximumWidthHint(); + //qDebug()<<"length = "<backupMenu == NULL) @@ -215,10 +275,11 @@ void AppWidget::backupsContextMenu(const QPoint &pos) pos2.setY(pos.y()+20); this->backupMenu->exec(ui->tableView->mapToGlobal(pos2)); } - +*/ void AppWidget::appsSelectedCount() { this->ui->buttonOpenMarket->setDisabled(true); + this->ui->buttonRefreshApps->setDisabled(true); this->ui->toolButtonBackup->setDisabled(true); this->ui->toolButtonRemoveBackup->setDisabled(true); this->ui->toolButtonRestore->setDisabled(true); @@ -255,6 +316,7 @@ void AppWidget::appsSelectedCount() } this->ui->buttonOpenMarket->setDisabled(false); + this->ui->buttonRefreshApps->setDisabled(false); this->ui->buttonAppBrain->setDisabled(false); this->ui->toolButtonBackup->setDisabled(false); this->ui->toolButtonRemoveBackup->setDisabled(true); @@ -284,6 +346,7 @@ void AppWidget::appsSelectedCount() this->ui->editAppsSize->setEnabled(true); this->ui->editAppsPackageName->setEnabled(true); this->ui->buttonOpenMarket->setDisabled(false); + this->ui->buttonRefreshApps->setDisabled(false); this->ui->buttonAppBrain->setDisabled(false); this->ui->toolButtonBackup->setDisabled(true); this->ui->toolButtonRemoveBackup->setDisabled(false); @@ -309,6 +372,7 @@ void AppWidget::appsSelectedCount() this->ui->editAppsPackageName->setEnabled(true); this->ui->editCyrketVersion->setDisabled(true); this->ui->buttonOpenMarket->setDisabled(true); + this->ui->buttonRefreshApps->setDisabled(false); this->ui->buttonAppBrain->setDisabled(true); this->ui->toolButtonBackup->setDisabled(false); this->ui->toolButtonRemoveBackup->setDisabled(true); @@ -334,6 +398,7 @@ void AppWidget::comboBoxAppsChanged() this->ui->toolButtonRemoveBackup->setDisabled(true); this->ui->toolButtonRestore->setDisabled(true); this->ui->toolButtonUninstall->setDisabled(true); + this->ui->buttonRefreshApps->setDisabled(true); this->ui->labelQRcode->clear(); this->ui->editCyrketVersion->clear(); this->ui->editCyrketVersion->setDisabled(true); @@ -375,8 +440,8 @@ void AppWidget::comboBoxAppsChanged() this->ui->comboFilter->addItem(tr("File path", "combo apps filter"), 5); this->ui->comboFilter->addItem(tr("Location", "combo apps filter"), 6); - disconnect(ui->tableView, SIGNAL(customContextMenuRequested(const QPoint &)), this, SLOT(backupsContextMenu(const QPoint &))); - connect(ui->tableView, SIGNAL(customContextMenuRequested(const QPoint &)), this, SLOT(appsContextMenu(const QPoint &))); + // disconnect(ui->tableView, SIGNAL(customContextMenuRequested(const QPoint &)), this, SLOT(backupsContextMenu(const QPoint &))); + // connect(ui->tableView, SIGNAL(customContextMenuRequested(const QPoint &)), this, SLOT(appsContextMenu(const QPoint &))); ui->stackedWidgetApps->setCurrentIndex(0); @@ -412,8 +477,8 @@ void AppWidget::comboBoxAppsChanged() this->ui->comboFilter->addItem(tr("App name", "combo backups filter"), 1); this->ui->comboFilter->addItem(tr("Package name", "combo backups filter"), 4); - disconnect(ui->tableView, SIGNAL(customContextMenuRequested(const QPoint &)), this, SLOT(appsContextMenu(const QPoint &))); - connect(ui->tableView, SIGNAL(customContextMenuRequested(const QPoint &)), this, SLOT(backupsContextMenu(const QPoint &))); + // disconnect(ui->tableView, SIGNAL(customContextMenuRequested(const QPoint &)), this, SLOT(appsContextMenu(const QPoint &))); + // connect(ui->tableView, SIGNAL(customContextMenuRequested(const QPoint &)), this, SLOT(backupsContextMenu(const QPoint &))); ui->stackedWidgetApps->setCurrentIndex(1); if (settings.value("getBackupInfo", 0) == 0 && !this->backupModel->isEmpty()) @@ -428,6 +493,12 @@ void AppWidget::comboBoxAppsChanged() { this->backupModel->clear(); this->ui->tableView->setModel(this->backupSortModel); + QString appsBackupFolder = settings.value("appsBackupFolder").toString(); + if (appsBackupFolder.isEmpty()) + { + QMessageBox::information(this,"Backups:","Did you set the Apps Backup Folder in settings?"); + return; + } this->threadBackups.sdk = this->sdk; this->threadBackups.start(); } @@ -448,8 +519,8 @@ void AppWidget::comboBoxAppsChanged() this->ui->comboFilter->addItem(tr("File path", "combo apps filter"), 5); this->ui->comboFilter->addItem(tr("Location", "combo apps filter"), 6); - disconnect(ui->tableView, SIGNAL(customContextMenuRequested(const QPoint &)), this, SLOT(backupsContextMenu(const QPoint &))); - connect(ui->tableView, SIGNAL(customContextMenuRequested(const QPoint &)), this, SLOT(appsContextMenu(const QPoint &))); + // disconnect(ui->tableView, SIGNAL(customContextMenuRequested(const QPoint &)), this, SLOT(backupsContextMenu(const QPoint &))); + // connect(ui->tableView, SIGNAL(customContextMenuRequested(const QPoint &)), this, SLOT(appsContextMenu(const QPoint &))); ui->stackedWidgetApps->setCurrentIndex(0); @@ -532,6 +603,7 @@ void AppWidget::gotAllApps(QThread * thread) } this->ui->tableView->resizeColumnsToContents(); this->ui->tableView->resizeRowsToContents(); + this->ui->tableView->horizontalHeader()->setStretchLastSection(true); this->ui->comboBoxApps->setEnabled(true); this->ui->tableView->setEnabled(true); this->ui->editFilter->setEnabled(true); @@ -594,7 +666,7 @@ void AppWidget::insertApp(App app) pix.loadFromData(ba); QIcon icon(pix); app.appIcon = icon; - settings.endGroup(); + // settings.endGroup(); if (this->ui->comboBoxApps->currentIndex() == 0) { @@ -607,12 +679,13 @@ void AppWidget::insertApp(App app) this->ui->tableView->resizeColumnsToContents(); this->ui->tableView->resizeRowsToContents(); + this->ui->tableView->horizontalHeader()->setStretchLastSection(true); qDebug()<<"Apps insertApp - END"; } void AppWidget::missingAapt() { - QMessageBox *msgBox = new QMessageBox(QMessageBox::Critical, tr("Missing aapt"), tr("QtADB did not found aapt.\nDownload it and place in one directory with adb.\nAfter You place it in correct directory click Refresh button")); + QMessageBox *msgBox = new QMessageBox(QMessageBox::Critical, tr("Missing aapt:"), tr("QtADB did not found aapt.\nDownload it and place in one directory with adb.\nAfter you place it in correct directory click Refresh button")); QPushButton *download = msgBox->addButton(tr("Download", "missing aapt message button"), QMessageBox::AcceptRole); QPushButton *closeMsg = msgBox->addButton(tr("Cancel", "missing aapt message button"), QMessageBox::RejectRole); @@ -634,58 +707,58 @@ void AppWidget::on_toolButtonBackup_pressed() QList appList; AppTableModel *tmpModel; AppSortModel *sortModel; + BackupTableModel *btmpModel; + BackupSortModel *bsortModel; + App app; + QSettings settings; + QString appsBackupFolder = settings.value("appsBackupFolder").toString(); + if (appsBackupFolder.isEmpty()) + { + QMessageBox::information(this,"Apps Backup:","Did you set the Apps Backup Folder in settings?"); + return; + } if (this->ui->comboBoxApps->currentIndex() == 0) { tmpModel = this->appModel; sortModel = this->appSortModel; + while (!indexList.isEmpty()) + { + appList.append(tmpModel->getApp(sortModel->mapToSource(indexList.takeFirst()).row())); + } } else if (this->ui->comboBoxApps->currentIndex() == 2) { tmpModel = this->systemAppModel; sortModel = this->systemAppSortModel; + while (!indexList.isEmpty()) + { + appList.append(tmpModel->getApp(sortModel->mapToSource(indexList.takeFirst()).row())); + } + } + else if (this->ui->comboBoxApps->currentIndex() == 1) + { + btmpModel = this->backupModel; + bsortModel = this->backupSortModel; + if (indexList.size() == 1) + { + Backup backup = btmpModel->getBackup(bsortModel->mapToSource(indexList.takeFirst()).row()); + app.packageName = backup.packageName; + app.appName = backup.appName; + app.appFileName = settings.value("apps/" + backup.packageName, "").toString(); + app.appFile = settings.value("apps/" + backup.packageName.append("/") + "filePath", "").toString(); + app.appSize = settings.value("apps/" + backup.packageName + "size", "").toString(); + app.appVersion = settings.value("apps/" + backup.packageName + "version", "").toString(); + appList.append(app); + qDebug()<<"Add backup List ="<withData=false; return; } - - while (!indexList.isEmpty()) - { - appList.append(tmpModel->getApp(sortModel->mapToSource(indexList.takeFirst()).row())); - } -// QString tmp=this->phone->getPath(); -// this->phone->setPath("/"); -// this->phone->makeDir("sdcard/QtADB/backup"); -// this->phone->setPath(tmp); -// AppList selected; -// for (int i=0;itableWidgetApps->selectedItems().count();i++) -// { -// if (ui->tableWidgetApps->selectedItems().at(i)->column()==1) -// selected.name.append(ui->tableWidgetApps->selectedItems().at(i)->text()); -// if (ui->tableWidgetApps->selectedItems().at(i)->column()==2) -// selected.version.append(ui->tableWidgetApps->selectedItems().at(i)->text()); -// if (ui->tableWidgetApps->selectedItems().at(i)->column()==3) -// selected.size.append(ui->tableWidgetApps->selectedItems().at(i)->text()); -// if (ui->tableWidgetApps->selectedItems().at(i)->column()==5) -// selected.filename.append(ui->tableWidgetApps->selectedItems().at(i)->text()); -// if (ui->tableWidgetApps->selectedItems().at(i)->column()==4) -// selected.package.append(ui->tableWidgetApps->selectedItems().at(i)->text()); -// } -// if (selected.name.length()==0) -// { -// this->withData=false; -// return; -// } - - if (QMessageBox::question(this,tr("backup"), - tr("are you sure???"),QMessageBox::Ok | QMessageBox::No)== QMessageBox::No) - return; - - if (!this->withApk && !this->withData) { - QSettings settings; int mode; mode = settings.value("BackupDefaultAction", appDialog::AppAndData).toInt(); if (mode == appDialog::Application) @@ -710,23 +783,26 @@ void AppWidget::on_toolButtonBackup_pressed() { if (this->withData) { - this->appsDialog=new appDialog(this,appList,appDialog::Backup,appDialog::AppAndData); + this->appsDialog=new appDialog(this,appList,appDialog::Backup,appDialog::AppAndData); } else { - this->appsDialog=new appDialog(this,appList,appDialog::Backup,appDialog::Application); + this->appsDialog=new appDialog(this,appList,appDialog::Backup,appDialog::Application); } } else if (this->withData) { - this->appsDialog=new appDialog(this,appList,appDialog::Backup,appDialog::Data); + this->appsDialog=new appDialog(this,appList,appDialog::Backup,appDialog::Data); } this->withData=false; this->withApk = false; this->appsDialog->show(); connect(this->appsDialog, SIGNAL(progressValue(int,int)), this, SIGNAL(progressValue(int,int))); connect(this->appsDialog, SIGNAL(closed()), this, SIGNAL(progressFinished())); - connect(this->appsDialog,SIGNAL(closed()),this,SLOT(refreshApps())); + if (this->ui->comboBoxApps->currentIndex() == 1) + connect(this->appsDialog,SIGNAL(closed()),this,SLOT(refreshApps())); + else + connect(this->appsDialog,SIGNAL(closed()),this,SLOT(refreshBackups())); } void AppWidget::on_toolButtonInstall_pressed() @@ -795,7 +871,7 @@ void AppWidget::on_toolButtonUninstall_pressed() // if (selected.name.length()==0) // return; - if (QMessageBox::question(this,tr("uninstall"),tr("are you sure???"),QMessageBox::Ok | QMessageBox::No) == QMessageBox::No) + if (QMessageBox::question(this,tr("Uninstall App:"),tr("Are you sure???"),QMessageBox::Ok | QMessageBox::No) == QMessageBox::No) return; if (this->appsDialog != NULL) @@ -813,42 +889,60 @@ void AppWidget::on_toolButtonUninstall_pressed() void AppWidget::on_toolButtonRemoveBackup_pressed() { + QSettings settings; QModelIndexList indexList = this->ui->tableView->selectionModel()->selectedRows(1); QList backupList; - while (!indexList.isEmpty()) { backupList.append(this->backupModel->getBackup(this->backupSortModel->mapToSource(indexList.takeFirst()).row())); } -// QStringList selected; -// for (int i=0;itableWidgetApps->selectedItems().count();i++) -// { -// if (ui->tableWidgetApps->selectedItems().at(i)->column()==4) -// selected.append(ui->tableWidgetApps->selectedItems().at(i)->text()); -// } - - if (QMessageBox::question(this,tr("remove backup"),tr("are you sure???"),QMessageBox::Ok | QMessageBox::No) == QMessageBox::No) + if (QMessageBox::question(this,tr("Remove Backup"),tr("Are you sure???"),QMessageBox::Ok | QMessageBox::No) == QMessageBox::No) + return; + appsBackupFolder = settings.value("appsBackupFolder").toString(); + if (appsBackupFolder.isEmpty()) + { + QMessageBox::information(this,"Remove Backup:","Did you set the Apps Backup Folder in settings?"); return; - + } + if (appsBackupFolder.contains("/sdcard/")) + { QString oldPath=this->phone->getPath(); - this->phone->setPath("/sdcard/QtADB/backup/"); + this->phone->setPath(appsBackupFolder); while (backupList.length()>0) { - this->phone->remove(backupList.first().packageName+".png"); - this->phone->remove(backupList.first().packageName+".txt"); - this->phone->remove(backupList.first().packageName+".apk"); - this->phone->remove(backupList.first().packageName+".DATA.tar.gz"); + this->phone->remove(backupList.first().appName); backupList.removeFirst(); } this->phone->setPath(oldPath); + } + else + { + while (backupList.length()>0) + { + this->computer->deleteDir(appsBackupFolder.append("/")+backupList.first().appName); + backupList.removeFirst(); + } + } refreshApps(); } + + + + void AppWidget::on_toolButtonRestore_pressed() { QModelIndexList indexList = this->ui->tableView->selectionModel()->selectedRows(1); QList backupList; - + QSettings settings; + QString appsBackupFolder = settings.value("appsBackupFolder").toString(); + if (appsBackupFolder.isEmpty()) + { + QMessageBox::information(this,"Restore Backup:","Did you set the Apps Backup Folder in settings?"); + return; + } + if (QMessageBox::question(this,tr("Restore Backup:"),tr("Are you sure???"),QMessageBox::Ok | QMessageBox::No) == QMessageBox::No) + return; while (!indexList.isEmpty()) { backupList.append(this->backupModel->getBackup(this->backupSortModel->mapToSource(indexList.takeFirst()).row())); @@ -876,13 +970,8 @@ void AppWidget::on_toolButtonRestore_pressed() // } // if (selected.package.length()==0) // return; - - if (QMessageBox::question(this,tr("restore"),tr("are you sure???"),QMessageBox::Ok | QMessageBox::No) == QMessageBox::No) - return; - if (!this->withApk && !this->withData) { - QSettings settings; int mode; mode = settings.value("RestoreDefaultAction", appDialog::AppAndData).toInt(); if (mode == appDialog::Application) @@ -967,6 +1056,7 @@ void AppWidget::insertBackup(Backup backup) this->backupModel->insertBackup(0, backup); this->ui->tableView->resizeColumnsToContents(); this->ui->tableView->resizeRowsToContents(); + this->ui->tableView->horizontalHeader()->setStretchLastSection(true); } @@ -975,19 +1065,36 @@ void ThreadBackups::run() { QProcess *proces = new QProcess; QSettings settings; - QString output, tmp; - QStringList outputLines, txtLines; + QString backuponpc, output, tmp,namedir; + QString appsBackupFolder = settings.value("appsBackupFolder").toString(); + bool onsdcard; + QStringList outputLines, txtLines, tmpLines; Backup backupFound; int i; - proces->start("\"" + this->sdk + "\"adb shell busybox ls /sdcard/QtADB/backup/*.txt"); + if (!appsBackupFolder.contains("/sdcard/")) + { + backuponpc = appsBackupFolder.append("/"); + // appsBackupFolder = "/sdcard/tmpAppsBackup/"; + onsdcard = false; + } + else + onsdcard = true; + if (onsdcard == false) + { + proces->start("findstr /S -M app.name= \"" + codec->toUnicode(backuponpc.toUtf8()) + "*\""); + proces->waitForFinished(-1); + output = proces->readAll(); + } + else + { + proces->start("\"" + this->sdk + "\"adb shell find \"" + codec->toUnicode(appsBackupFolder.toUtf8()) + "\" -name *.txt"); proces->waitForFinished(-1); output = proces->readAll(); - output.remove(QString("%1[0m").arg( QChar( 0x1b ))); - output.remove(QChar( 0x1b ), Qt::CaseInsensitive); - output.remove(QRegExp("\\[\\d;\\d+m")); + } outputLines = output.split("\n", QString::SkipEmptyParts); + qDebug()<<"Backup outputList = "<maximum(outputLines.size()); int max = outputLines.size(); i = 0; @@ -996,33 +1103,65 @@ void ThreadBackups::run() i++; emit this->value(i); emit this->progressValue(i, max); - backupFound.packageName = outputLines.takeFirst(); - backupFound.packageName.remove(QRegExp("^.+/")); - backupFound.packageName.remove(QRegExp("\\.txt\\s+$")); - proces->start("\"" + this->sdk + "\"adb shell cat /sdcard/QtADB/backup/"+backupFound.packageName+".txt"); - proces->waitForFinished(-1); - output = proces->readAll(); - if (!settings.contains("apps/"+backupFound.packageName+"/icon")) + tmp = outputLines.takeFirst(); + if (onsdcard == false) { - proces->start("\"" + this->sdk + "\"adb pull /sdcard/QtADB/backup/"+backupFound.packageName+".png "+QDir::currentPath()+"/icons/"+backupFound.packageName+".png"); + tmpLines = tmp.split("/", QString::SkipEmptyParts); + tmp = tmpLines.at(1); + tmp.replace("\\","/"); + } + else + tmp.remove(appsBackupFolder,Qt::CaseInsensitive); + qDebug()<<"tmp str = "<toUnicode(backuponpc.toUtf8()) + codec->toUnicode(namedir.toUtf8())+codec->toUnicode(backupFound.packageName.toUtf8())+".txt"); + if (!file.open (QIODevice::ReadOnly)) + break; + QTextStream stream ( &file ); + QString line; + while( !stream.atEnd() ) + { + line = stream.readLine(); + txtLines << line; + } + file.close(); + } + else + { + proces->start("\"" + this->sdk + "\"adb shell cat \"" + codec->toUnicode(appsBackupFolder.toUtf8()) + codec->toUnicode(namedir.toUtf8())+ codec->toUnicode(backupFound.packageName.toUtf8())+".txt\""); proces->waitForFinished(-1); - - QFile icon(QDir::currentPath()+"/icons/"+backupFound.packageName+".png"); + output = proces->readAll(); + txtLines = output.split("\n", QString::SkipEmptyParts); + if (output.contains("No such file or directory")) + break; + } + if (!settings.contains("apps/"+backupFound.packageName+"/icon")) + { + QString iconfile; + if (onsdcard == false) + iconfile = codec->toUnicode(backuponpc.toUtf8()) + codec->toUnicode(namedir.toUtf8())+codec->toUnicode(backupFound.packageName.toUtf8())+".png"; + else + { + iconfile = QDir::currentPath()+"/tmp/"+codec->toUnicode(backupFound.packageName.toUtf8())+".png"; + proces->start("\"" + this->sdk + "\"adb pull \""+codec->toUnicode(appsBackupFolder.toUtf8())+ codec->toUnicode(namedir.toUtf8())+codec->toUnicode(backupFound.packageName.toUtf8())+".png\" "+codec->toUnicode(iconfile.toUtf8())); + proces->waitForFinished(-1); + } + QFile icon(iconfile); icon.open(QIODevice::ReadOnly); QByteArray ba; ba = icon.readAll(); settings.setValue("apps/"+backupFound.packageName+"/icon", ba); //- zapisanie pixmap w QSettings - QFile::remove(QDir::currentPath()+"/icons/"+backupFound.packageName+".png"); + if (onsdcard == true) + QFile::remove(iconfile); } -// QByteArray ba; -// ba = settings.value("apps/"+backupFound.packageName+"/icon").toByteArray(); -// QPixmap pix; -// pix.loadFromData(ba); -// backupFound.appIcon = QIcon(pix); - - if (output.contains("No such file or directory")) - break; - txtLines = output.split("\n", QString::SkipEmptyParts); + qDebug()<<"text table"< 0) { tmp = txtLines.takeFirst(); @@ -1032,40 +1171,53 @@ void ThreadBackups::run() tmp.remove(QRegExp("\\s+$")); backupFound.appName = QString::fromUtf8(tmp.toAscii()); } - else if (tmp.contains("app.size")) + else if (tmp.contains("app.size=")) { tmp.remove("app.size="); tmp.remove(QRegExp("\\s+$")); backupFound.appSize = tmp; } - else if (tmp.contains("app.version")) + else if (tmp.contains("app.version=")) { tmp.remove("app.version="); tmp.remove(QRegExp("\\s+$")); backupFound.appVersion = tmp; } } - proces->start("\"" + this->sdk + "\"adb shell ls /sdcard/QtADB/backup/"+backupFound.packageName+".apk"); - proces->waitForFinished(-1); - output = proces->readAll(); - output.remove(QString("%1[0m").arg( QChar( 0x1b ))); - output.remove(QChar( 0x1b ), Qt::CaseInsensitive); - output.remove(QRegExp("\\[\\d;\\d+m")); - if (output.contains("No such file or directory")) - backupFound.withApk = false; + if (onsdcard == false) + { + if (!QFile::exists(codec->toUnicode(backuponpc.toUtf8()) + codec->toUnicode(namedir.toUtf8())+codec->toUnicode(backupFound.packageName.toUtf8())+".apk")) + backupFound.withApk = false; + else + backupFound.withApk = true; + } else - backupFound.withApk = true; - proces->start("\"" + this->sdk + "\"adb shell ls /sdcard/QtADB/backup/"+backupFound.packageName+".DATA.tar.gz"); - proces->waitForFinished(-1); - output = proces->readAll(); - output.remove(QString("%1[0m").arg( QChar( 0x1b ))); - output.remove(QChar( 0x1b ), Qt::CaseInsensitive); - output.remove(QRegExp("\\[\\d;\\d+m")); - if (output.contains("No such file or directory")) - backupFound.withData = false; + { + proces->start("\"" + this->sdk + "\"adb shell ls \"" + codec->toUnicode(appsBackupFolder.toUtf8()) + codec->toUnicode(namedir.toUtf8())+ codec->toUnicode(backupFound.packageName.toUtf8())+".apk\""); + proces->waitForFinished(-1); + output = proces->readAll(); + if (output.contains("No such file or directory")) + backupFound.withApk = false; + else + backupFound.withApk = true; + } + if (onsdcard == false) + { + if (!QFile::exists(codec->toUnicode(backuponpc.toUtf8()) + codec->toUnicode(namedir.toUtf8())+codec->toUnicode(backupFound.packageName.toUtf8())+".DATA.tar.gz")) + backupFound.withData = false; + else + backupFound.withData = true; + } else - backupFound.withData = true; - backupFound.appSize.remove(QRegExp("\\s+$")); + { + proces->start("\"" + this->sdk + "\"adb shell ls \"" + codec->toUnicode(appsBackupFolder.toUtf8()) + codec->toUnicode(namedir.toUtf8())+ codec->toUnicode(backupFound.packageName.toUtf8())+".DATA.tar.gz\""); + proces->waitForFinished(-1); + output = proces->readAll(); + if (output.contains("No such file or directory")) + backupFound.withData = false; + else + backupFound.withData = true; + } emit this->gotBackup(backupFound); } delete proces; @@ -1092,7 +1244,7 @@ void ThreadApps::run() delete aapt; if (this->systemApps) { - proces.start("\"" + this->sdk + "\"adb shell busybox ls -l /system/app/*.apk"); + proces.start("\"" + this->sdk + "\"adb shell ls -l /system/app/*.apk"); proces.waitForFinished(-1); output = proces.readAll(); qDebug()<<"Get apps system - "<sdk + "\"adb shell busybox ls -l /data/app/*.apk"); + proces.start("\"" + this->sdk + "\"adb shell ls -l /data/app/*.apk"); proces.waitForFinished(-1); output = proces.readAll(); qDebug()<<"Get apps data - "< 7) + if ((split.size() > 7) && (tmp.startsWith("-rw-r--r--"))) { app.appSize = split.at(4); tmp = split.at(8); @@ -1151,7 +1303,7 @@ void ThreadApps::run() appList.append(app); } } - proces.start("\"" + this->sdk + "\"adb shell busybox ls -l /data/app-private/*.apk"); + proces.start("\"" + this->sdk + "\"adb shell ls -l /data/app-private/*.apk"); proces.waitForFinished(-1); output = proces.readAll(); qDebug()<<"Get apps data - "< 7) + if ((split.size() > 7) && (tmp.startsWith("-rw-r--r--"))) { app.appSize = split.at(4); tmp = split.at(8); @@ -1179,7 +1331,7 @@ void ThreadApps::run() appList.append(app); } } - proces.start("\"" + this->sdk + "\"adb shell busybox ls -l /mnt/asec/*/*.apk"); + proces.start("\"" + this->sdk + "\"adb shell ls -l /mnt/asec/*/*.apk"); proces.waitForFinished(-1); output = proces.readAll(); qDebug()<<"Get apps sd - "<sdk + "\"adb shell busybox mount"); +// proces.start("\"" + this->sdk + "\"adb shell mount"); // proces.waitForFinished(-1); // tmp = proces.readAll(); // qDebug()<<"Get apps mount - "<sdk + "\"adb shell busybox ls -l "+ sdFolder + "/*/*.apk"); + proces.start("\"" + this->sdk + "\"adb shell ls -l "+ codec->toUnicode(sdFolder.toUtf8()) + "/*.apk"); proces.waitForFinished(-1); output.append(proces.readAll()); qDebug()<<"Get apps sd - "<0) @@ -1291,7 +1445,7 @@ void ThreadApps::run() if ((!settingsList.contains(app.appFileName)) || (settings.value("apps/" + app.packageName + "/date", "").toString() != app.date)) { - qDebug()<<"Apps needs to pull apk"; + qDebug()<<"Apps needs to pull apk ="<ui->editCyrketVersion->setEnabled(true); + //this->ui->editCyrketVersion->setText(app.cyrketVer); qDebug()<<"Apps got info from cyrket"; } @@ -1379,14 +1536,16 @@ void ThreadApps::run() QString out; out = zip.readAll(); } - FileWidget::unpack(QDir::currentPath()+"/tmp/"+app.appFileName,QDir::currentPath()+"/icons/",app.icoName,temp); + FileWidget::unpack(QDir::currentPath()+"/tmp/"+app.appFileName,QDir::currentPath()+"/tmp/",app.icoName,temp); QByteArray ba; - QFile icon(QDir::currentPath()+"/icons/"+temp); + QFile icon(QDir::currentPath()+"/tmp/"+temp); icon.open(QIODevice::ReadWrite); ba = icon.readAll(); settings.setValue("apps/"+app.packageName+"/icon", ba); //- zapisanie pixmap w QSettings icon.remove(); + // QDir dir; + // dir.rmdir (QDir::currentPath()+"/icons"); qDebug()<<"Apps got icon now"; } // QByteArray ba; @@ -1532,13 +1691,15 @@ App * AppWidget::getAppInfo(QString filePath) temp.append(".png"); if (!settings.contains(app->packageName+"/icon")) { - unpack(app->appFile, QDir::currentPath()+"/icons/", app->icoName, temp); + unpack(app->appFile, QDir::currentPath()+"/tmp/", app->icoName, temp); - QFile icon(QDir::currentPath()+"/icons/"+app->packageName.toLatin1()+".png"); + QFile icon(QDir::currentPath()+"/tmp/"+app->packageName.toLatin1()+".png"); icon.open(QIODevice::ReadWrite); ba = icon.readAll(); settings.setValue(app->packageName+"/icon", ba); //- zapisanie pixmap w QSettings icon.remove(); + // QDir dir; + // dir.rmdir (QDir::currentPath()+"/icons"); } ba = settings.value(app->packageName+"/icon").toByteArray(); pix.loadFromData(ba); @@ -1699,8 +1860,16 @@ void AppWidget::openMarket() sdk = settings.value("sdkPath").toString(); QProcess proc; proc.start("\"" + sdk + "\"adb shell am start -a android.intent.action.VIEW -d market://details?id=" - + this->ui->editAppsPackageName->text() + " -n com.android.vending/.AssetInfoActivity"); + + this->ui->editAppsPackageName->text() + " -n com.android.vending/.AssetBrowserActivity"); proc.waitForFinished(-1); + QString out = proc.readAll(); + if (out.contains("Error")) + { + proc.start("\"" + sdk + "\"adb shell am start -a android.intent.action.VIEW -d market://details?id=" + + this->ui->editAppsPackageName->text() + " -n com.android.vending/com.google.android.finsky.activities.PlayLauncherActivity"); + proc.waitForFinished(-1); + } + qDebug()<<"adb shell am start -a android.intent.action.VIEW -d market://details?id=" << this->ui->editAppsPackageName->text() << " -n com.android.vending/.AssetBrowserActivity"; } void AppWidget::openAppBrain() @@ -1710,7 +1879,7 @@ void AppWidget::openAppBrain() void AppWidget::getCyrketVersions() { - QModelIndexList indexList = this->ui->tableView->selectionModel()->selectedRows(1); + QModelIndexList indexList = this->ui->tableView->selectionModel()->selectedRows(); int i; this->ui->progressApps->setMaximum(indexList.size()); @@ -1720,17 +1889,21 @@ void AppWidget::getCyrketVersions() { i = 1; while (!indexList.isEmpty()) - { + { this->ui->progressApps->setValue(i); i++; int row = this->appSortModel->mapToSource(indexList.takeFirst()).row(); App app = this->appModel->getApp(row); app.cyrketVer = appInfo::getCyrketVer(app.packageName); this->appModel->setCyrketVer(row, app.cyrketVer); - } + this->ui->editCyrketVersion->setEnabled(true); + this->ui->editCyrketVersion->setText(app.cyrketVer); + } + this->ui->progressApps->setMaximum(0); this->ui->progressApps->setValue(0); this->ui->progressApps->hide(); +/* QList appList = this->appModel->getList(); this->appModel->clear(); this->appModel->insertApps(0, appList); @@ -1745,9 +1918,12 @@ void AppWidget::getCyrketVersions() for (i = 0; i < rows; i++) this->ui->tableView->setRowHeight(i, 40); appsSelectedCount(); + */ } } + + void AppWidget::filter() { QRegExp regExp(this->ui->editFilter->text(), Qt::CaseInsensitive, QRegExp::RegExp); @@ -1770,5 +1946,27 @@ void AppWidget::filter() } this->ui->tableView->resizeColumnsToContents(); this->ui->tableView->resizeRowsToContents(); + this->ui->tableView->horizontalHeader()->setStretchLastSection(true); + +} + +void AppWidget::refreshBackups() //in background +{ + this->backupModel->clear(); + this->threadBackups.sdk = this->sdk; + this->threadBackups.start(); +} +QString AppWidget::addToBackup() +{ + QModelIndexList indexList = this->ui->tableView->selectionModel()->selectedRows(1); + if (indexList.size() == 1) + { + Backup backup = this->backupModel->getBackup(this->backupSortModel->mapToSource(indexList.takeFirst()).row()); + if (backup.withApk == false) + return "noApk"; + else if (backup.withData == false) + return "noData"; + } + return 0; } diff --git a/widgets/appwidget.h b/widgets/appwidget.h index ddbe3ce..728f6bc 100644 --- a/widgets/appwidget.h +++ b/widgets/appwidget.h @@ -22,6 +22,9 @@ #define APPWIDGET_H #include +#include +#include +#include #include "../classes/phone.h" #include "../classes/computer.h" @@ -46,6 +49,8 @@ class ThreadApps : public QThread void run(); QString sdk; QList appList; + QString appsBackupFolder; + QTextCodec *codec; signals: void gotApp(App); @@ -63,6 +68,8 @@ class ThreadBackups : public QThread public: void run(); QString sdk; + QString appsBackupFolder; + QTextCodec *codec; signals: void gotBackup(Backup); @@ -81,6 +88,8 @@ class AppWidget : public QWidget public: explicit AppWidget(QWidget *parent = 0); ~AppWidget(); + QTextCodec *codec; + // void mousePressEvent(QMouseEvent *event); protected: void changeEvent(QEvent *e); @@ -88,10 +97,12 @@ class AppWidget : public QWidget private: Ui::AppWidget *ui; + QString addToBackup(); + bool alwaysCloseCopy; bool dialogKopiujShowModal; dialogKopiuj *dialog; - QMenu *appMenu, *backupMenu; + QMenu *customMenu; ThreadApps threadApps; ThreadBackups threadBackups; appDialog *appsDialog; @@ -109,10 +120,16 @@ class AppWidget : public QWidget AppSortModel *systemAppSortModel; BackupTableModel *backupModel; BackupSortModel *backupSortModel; + //int maximumWidthHint(); + //QHeaderView * view; + // QHeaderView * horizontalHeader(); + //bool stretchLastSection; bool withData; bool withApk; Phone *phone; + Computer *computer; + QString appsBackupFolder; public slots: @@ -123,10 +140,10 @@ public slots: void insertBackup(Backup backup); void gotAllApps(QThread *); void appsSelectedCount(); - void appsContextMenu(const QPoint&); - void backupsContextMenu(const QPoint&); + // void appsContextMenu(const QPoint&); + // void backupsContextMenu(const QPoint&); + // void refreshApps(); void copyAppToPC(); - private slots: void getAppInfo(); @@ -149,8 +166,11 @@ private slots: void toolButtonInstallOnSd(); void comboBoxAppsChanged(); void refreshApps(); + void refreshBackups(); + void on_tableView_customContextMenuRequested(const QPoint &pos); signals: void progressValue(int value, int max); void progressFinished(); + //void myContextMenuRequested(const QPoint &pos); }; #endif // APPWIDGET_H diff --git a/widgets/appwidget.ui b/widgets/appwidget.ui index 91143de..bbebf94 100644 --- a/widgets/appwidget.ui +++ b/widgets/appwidget.ui @@ -6,8 +6,8 @@ 0 0 - 786 - 595 + 980 + 715 @@ -164,7 +164,7 @@ - App name + App name: @@ -178,7 +178,7 @@ - App version + App version: @@ -192,7 +192,7 @@ - File name + File name: @@ -206,7 +206,7 @@ - File Size + File Size (bytes): @@ -250,7 +250,7 @@ - Package name + Package name: @@ -284,7 +284,7 @@ - Location + Location: @@ -331,7 +331,7 @@ - Latest version + Latest version on Android Market: diff --git a/widgets/contactwidget.h b/widgets/contactwidget.h index 289f7c7..47712d8 100644 --- a/widgets/contactwidget.h +++ b/widgets/contactwidget.h @@ -22,6 +22,7 @@ //#define CONTACTWIDGET_H //#include +////#include "../classes/models/contactmodel.h" //typedef struct contactList @@ -76,6 +77,7 @@ //private: // Ui::ContactWidget *ui; // ThreadContacts threadContacts; +// //ContactList contactList; //private slots: // void contactSelected(int); diff --git a/widgets/cwmwidget.cpp b/widgets/cwmwidget.cpp new file mode 100644 index 0000000..f4a5d15 --- /dev/null +++ b/widgets/cwmwidget.cpp @@ -0,0 +1,1815 @@ +/*********************************************************************** +*Copyright 2010-20XX by nijel +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +* +* @author nijel (nijel8@gmail.com) +* +************************************************************************/ + + +#include "cwmwidget.h" +#include "ui_cwmwidget.h" + +CwmWidget::CwmWidget(QWidget *parent) : + QWidget(parent), + ui(new Ui::CwmWidget) +{ + this->settings = new SettingsWidget; + ui->setupUi(this); + + this->sdcardTableView = new MyTableView; + this->ui->sdphoneLayout->addWidget(this->sdcardTableView); + + this->phoneModel = new FileTableModel; + + this->phoneSortModel = new FileSortModel; + + this->phoneSortModel->setSourceModel(this->phoneModel); + + this->phoneSortModel->setSortCaseSensitivity(Qt::CaseInsensitive); + + this->phoneSortModel->setDynamicSortFilter(true); + + this->phoneSortModel->setFilterKeyColumn(1); + + this->sdcardTableView->setModel(this->phoneSortModel); + + this->sdk = this->settings->sdkPath; + + this->phone=new Phone(this->sdk,true); + this->phone->setPath("/sdcard"); + this->phone->setHiddenFiles(this->settings->phoneHiddenFiles); + this->sdcardChangeName=false; + + sdcardTableView->setContextMenuPolicy(Qt::CustomContextMenu); + ui->pushButtonDirectoryUp->setIcon(this->style()->standardIcon(QStyle::SP_FileDialogToParent)); + + this->setLayout(ui->layoutCwm); + + this->sdcardTableView->horizontalHeader()->setVisible(this->settings->showPhoneColumnsHeaders); + + this->phoneMenu = NULL; + + if (phone->getPath().isEmpty()) + phone->setPath("/sdcard"); + + + processFind = new QProcess(this); + process = new QProcess(this); + processWhich = new QProcess(this); + + process->setProcessChannelMode(QProcess::MergedChannels); + processWhich->setProcessChannelMode(QProcess::MergedChannels); + + connect(this->process, SIGNAL(readyReadStandardOutput()), this, SLOT(readFromProcess())); + connect(this->process, SIGNAL(finished(int)), this, SLOT(processFinished())); + connect(this->processWhich, SIGNAL(readyReadStandardOutput()), this, SLOT(readFromProcessWhich())); + connect(this->processWhich, SIGNAL(finished(int)), this, SLOT(finishedWhich())); + connect(this->phone,SIGNAL(signalConnectionChanged(int)),this,SLOT(connectionChanged())); + connect(ui->tabWidget_3,SIGNAL(currentChanged(int)),this,SLOT(mountsUpdate())); + connect(sdcardTableView, SIGNAL(customContextMenuRequested(const QPoint &)), this, SLOT(phoneContextMenu(const QPoint &))); + connectSignals(); + + this->codec = QTextCodec::codecForLocale(); + + this->buttonsEnabled(); + currentDir = QDir::currentPath(); + QFont font, fontStatus; + font.setPointSize(14); + fontStatus.setPointSize(10); + font.setBold(true); + fontStatus.setBold(true); + this->ui->label->setFont(font); + this->ui->plainTextEditStatus->setFont(fontStatus); + this->ui->label_2->setFont(fontStatus); +} + +CwmWidget::~CwmWidget() +{ + delete this->phone; + if (this->phoneMenu != NULL) + delete this->phoneMenu; + delete ui; +} + +void CwmWidget::setTabCreate(int i) +{ + if (i == 2) + if (this->ui->tabWidget->currentIndex() > 1) + this->ui->tabWidget->setCurrentWidget(this->ui->tabSdcardPart); +} + +void CwmWidget::setTabFix(int i) +{ + if (i > 1) + if (this->ui->tabWidget_3->currentIndex() == 2) + this->ui->tabWidget_3->setCurrentWidget(this->ui->tabPermissions); +} + +void CwmWidget::connectSignals() +{ + connect(ui->lineEditPath,SIGNAL(returnPressed()),this,SLOT(sdcardLineEdit())); + connect(ui->lineEditPath, SIGNAL(editingFinished ()), this, SLOT(sdcardLineEdit())); + connect(ui->tabWidget_2,SIGNAL(currentChanged(int)),this,SLOT(sdcardDisplay())); + connect(ui->tabWidget,SIGNAL(currentChanged(int)),this,SLOT(activateButtonInsert())); + connect(ui->tabWidget,SIGNAL(currentChanged(int)),this,SLOT(buttonsEnabled())); + connect(ui->tabWidget,SIGNAL(currentChanged(int)),this,SLOT(setTabFix(int))); + connect(ui->tabWidget_3,SIGNAL(currentChanged(int)),this,SLOT(buttonsEnabled())); + connect(ui->tabWidget_3,SIGNAL(currentChanged(int)),this,SLOT(activateButtonInsert())); + connect(ui->tabWidget_3,SIGNAL(currentChanged(int)),this,SLOT(setTabCreate(int))); + connect(this->sdcardTableView, SIGNAL(doubleClicked(QModelIndex)), this, SLOT(sdcardDoubleClick())); + connect(this->sdcardTableView, SIGNAL(clicked(QModelIndex)), this, SLOT(activateButtonInsert())); + connect(this->ui->radio128, SIGNAL(toggled(bool)),this,SLOT(buttonsEnabled())); + connect(this->ui->radio256, SIGNAL(toggled(bool)),this,SLOT(buttonsEnabled())); + connect(this->ui->radio512, SIGNAL(toggled(bool)),this,SLOT(buttonsEnabled())); + connect(this->ui->radio1024, SIGNAL(toggled(bool)),this,SLOT(buttonsEnabled())); + connect(this->ui->radio2048, SIGNAL(toggled(bool)),this,SLOT(buttonsEnabled())); + connect(this->ui->radio4096, SIGNAL(toggled(bool)),this,SLOT(buttonsEnabled())); + connect(this->ui->checkData, SIGNAL(toggled(bool)),this,SLOT(buttonsEnabled())); + connect(this->ui->checkDalvik, SIGNAL(toggled(bool)),this,SLOT(buttonsEnabled())); + connect(this->ui->checkCache, SIGNAL(toggled(bool)),this,SLOT(buttonsEnabled())); + connect(this->ui->checkBattery, SIGNAL(toggled(bool)),this,SLOT(buttonsEnabled())); + connect(this->ui->checkDefaultBackupDir, SIGNAL(toggled(bool)),this,SLOT(buttonsEnabled())); + connect(this->ui->radioUpdateZip, SIGNAL(toggled(bool)),this,SLOT(buttonsEnabled())); + connect(this->ui->radioInstallPath, SIGNAL(toggled(bool)),this,SLOT(buttonsEnabled())); + connect(this->ui->lineBackup, SIGNAL(textChanged(QString)),this,SLOT(buttonsEnabled())); + connect(this->ui->lineRestore, SIGNAL(textChanged(QString)),this,SLOT(buttonsEnabled())); + connect(this->ui->lineUpdate, SIGNAL(textChanged(QString)),this,SLOT(buttonsEnabled())); + connect(this->ui->lineFlash, SIGNAL(textChanged(QString)),this,SLOT(buttonsEnabled())); + connect(this->ui->lineRecovery, SIGNAL(textChanged(QString)),this,SLOT(buttonsEnabled())); + connect(this->ui->checkBacBoot, SIGNAL(toggled(bool)),this,SLOT(buttonsEnabled())); + connect(this->ui->checkBacCache, SIGNAL(toggled(bool)),this,SLOT(buttonsEnabled())); + connect(this->ui->checkBacData, SIGNAL(toggled(bool)),this,SLOT(buttonsEnabled())); + connect(this->ui->checkBacSdext, SIGNAL(toggled(bool)),this,SLOT(buttonsEnabled())); + connect(this->ui->checkBacSystem, SIGNAL(toggled(bool)),this,SLOT(buttonsEnabled())); + connect(this->ui->checkAfter, SIGNAL(toggled(bool)),this,SLOT(checkFlash())); + connect(this->ui->checkBefore, SIGNAL(toggled(bool)),this,SLOT(checkFlash())); +} + +void CwmWidget::disconnectSignals() +{ + disconnect(ui->lineEditPath,SIGNAL(returnPressed()),this,SLOT(sdcardLineEdit())); + disconnect(ui->lineEditPath, SIGNAL(editingFinished ()), this, SLOT(sdcardLineEdit())); + disconnect(ui->tabWidget_2,SIGNAL(currentChanged(int)),this,SLOT(sdcardDisplay())); + disconnect(ui->tabWidget,SIGNAL(currentChanged(int)),this,SLOT(activateButtonInsert())); + disconnect(ui->tabWidget,SIGNAL(currentChanged(int)),this,SLOT(buttonsEnabled())); + disconnect(ui->tabWidget,SIGNAL(currentChanged(int)),this,SLOT(setTabFix(int))); + disconnect(ui->tabWidget_3,SIGNAL(currentChanged(int)),this,SLOT(buttonsEnabled())); + disconnect(ui->tabWidget_3,SIGNAL(currentChanged(int)),this,SLOT(activateButtonInsert())); + disconnect(ui->tabWidget_3,SIGNAL(currentChanged(int)),this,SLOT(setTabCreate(int))); + disconnect(this->sdcardTableView, SIGNAL(doubleClicked(QModelIndex)), this, SLOT(sdcardDoubleClick())); + disconnect(this->sdcardTableView, SIGNAL(clicked(QModelIndex)), this, SLOT(activateButtonInsert())); + disconnect(this->ui->radio128, SIGNAL(toggled(bool)),this,SLOT(buttonsEnabled())); + disconnect(this->ui->radio256, SIGNAL(toggled(bool)),this,SLOT(buttonsEnabled())); + disconnect(this->ui->radio512, SIGNAL(toggled(bool)),this,SLOT(buttonsEnabled())); + disconnect(this->ui->radio1024, SIGNAL(toggled(bool)),this,SLOT(buttonsEnabled())); + disconnect(this->ui->radio2048, SIGNAL(toggled(bool)),this,SLOT(buttonsEnabled())); + disconnect(this->ui->radio4096, SIGNAL(toggled(bool)),this,SLOT(buttonsEnabled())); + disconnect(this->ui->checkData, SIGNAL(toggled(bool)),this,SLOT(buttonsEnabled())); + disconnect(this->ui->checkDalvik, SIGNAL(toggled(bool)),this,SLOT(buttonsEnabled())); + disconnect(this->ui->checkCache, SIGNAL(toggled(bool)),this,SLOT(buttonsEnabled())); + disconnect(this->ui->checkBattery, SIGNAL(toggled(bool)),this,SLOT(buttonsEnabled())); + disconnect(this->ui->checkDefaultBackupDir, SIGNAL(toggled(bool)),this,SLOT(buttonsEnabled())); + disconnect(this->ui->radioUpdateZip, SIGNAL(toggled(bool)),this,SLOT(buttonsEnabled())); + disconnect(this->ui->radioInstallPath, SIGNAL(toggled(bool)),this,SLOT(buttonsEnabled())); + disconnect(this->ui->lineBackup, SIGNAL(textChanged(QString)),this,SLOT(buttonsEnabled())); + disconnect(this->ui->lineRestore, SIGNAL(textChanged(QString)),this,SLOT(buttonsEnabled())); + disconnect(this->ui->lineUpdate, SIGNAL(textChanged(QString)),this,SLOT(buttonsEnabled())); + disconnect(this->ui->lineFlash, SIGNAL(textChanged(QString)),this,SLOT(buttonsEnabled())); + disconnect(this->ui->lineRecovery, SIGNAL(textChanged(QString)),this,SLOT(buttonsEnabled())); + disconnect(this->ui->checkBacBoot, SIGNAL(toggled(bool)),this,SLOT(buttonsEnabled())); + disconnect(this->ui->checkBacCache, SIGNAL(toggled(bool)),this,SLOT(buttonsEnabled())); + disconnect(this->ui->checkBacData, SIGNAL(toggled(bool)),this,SLOT(buttonsEnabled())); + disconnect(this->ui->checkBacSdext, SIGNAL(toggled(bool)),this,SLOT(buttonsEnabled())); + disconnect(this->ui->checkBacSystem, SIGNAL(toggled(bool)),this,SLOT(buttonsEnabled())); + disconnect(this->ui->checkAfter, SIGNAL(toggled(bool)),this,SLOT(checkFlash())); + disconnect(this->ui->checkBefore, SIGNAL(toggled(bool)),this,SLOT(checkFlash())); +} + +//void CwmWidget::mousePressEvent(QMouseEvent *event) +//{ +// if (event->button() == Qt::RightButton) +// emit customContextMenuRequested(event->pos()); +//} + +void CwmWidget::connectionChanged() +{ + if (this->phone->getConnectionState() == DISCONNECTED) + { + emit this->phoneConnectionChanged(DISCONNECTED); + } + else if (this->phone->getConnectionState() == DEVICE) + { + emit this->phoneConnectionChanged(DEVICE); + connectSignals(); + mountsDisable(); + mountsUpdate(); + this->sdcardDisplay(); + this->buttonsEnabled(); + QFont font, fontStatus; + font.setPointSize(14); + fontStatus.setPointSize(10); + font.setBold(true); + fontStatus.setBold(true); + this->ui->label->setFont(font); + this->ui->plainTextEditStatus->setFont(fontStatus); + if (readLog == "read") + { + readLog = "Not Read"; + while (this == NULL && !this->isVisible()) + { + } + readFromLog(); + } + } + else if (this->phone->getConnectionState() == RECOVERY) + { + emit this->phoneConnectionChanged(RECOVERY); + disconnectSignals(); + mountsEnable(); + mountsUpdate(); + this->ui->tabWidget_2->setCurrentIndex(1); + this->buttonsDisabled(); + QFont font, fontStatus; + font.setPointSize(14); + fontStatus.setPointSize(10); + font.setBold(true); + fontStatus.setBold(true); + this->ui->label->setFont(font); + this->ui->plainTextEditStatus->setFont(fontStatus); + if (commandRunning == "running") + { + while (this == NULL && !this->isVisible()) + { + } + tailLog(); + } + + + + // QTimer::singleShot(2000, this, SLOT(tailLog())); + } + else if (this->phone->getConnectionState() == FASTBOOT) + { + emit this->phoneConnectionChanged(FASTBOOT); + disconnectSignals(); + } + return; +} + +void CwmWidget::on_pushButtonDirectoryUp_pressed() +{ + if (this->phone->cdUp()) + { + this ->ui->buttonInsert->setEnabled(false); + this->sdcardDisplay(); + } +} + +void CwmWidget::phoneContextMenu(const QPoint &pos) +{ + this->phoneMenu = new QMenu; + QSettings settings; + int layoutDirection = settings.value("layoutDirection",0).toInt(); + + if (layoutDirection == 0) + this->phoneMenu->setLayoutDirection(Qt::LeftToRight); + if (layoutDirection == 1) + this->phoneMenu->setLayoutDirection(Qt::RightToLeft); + QAction *usun,*odswiez,*nowyFolder,*zmienNazwe,*ukryte,*props, *sep; + + zmienNazwe = this->phoneMenu->addAction(QIcon(":icons/rename.png"),tr("rename", "phone right click menu"),this,SLOT(phoneRename())); + zmienNazwe->setData(QString("rename")); + nowyFolder = this->phoneMenu->addAction(QIcon(":icons/newDir.png"),tr("new dir", "phone right click menu"),this,SLOT(phoneNewDir())); + nowyFolder->setData(QString("new dir")); + odswiez = this->phoneMenu->addAction(QIcon(":icons/refresh.png"),tr("refresh", "phone right click menu"),this,SLOT(sdcardDisplay())); + odswiez->setData(QString("refresh")); + usun = this->phoneMenu->addAction(QIcon(":icons/remove.png"),tr("delete", "phone right click menu"),this,SLOT(phoneDelete())); + usun->setData(QString("delete")); + ukryte = this->phoneMenu->addAction(QIcon(":icons/hidden.png"),tr("hidden files", "phone right click menu"),this,SLOT(phoneHiddenFiles())); + ukryte->setData(QString("hidden files")); + sep = this->phoneMenu->addSeparator(); + props = this->phoneMenu->addAction(QIcon(":icons/info.png"),tr("Properties", "phone right click menu"),this,SLOT(propsDialog())); + props->setData(QString("properties")); + + QPoint pos2; + pos2.setX(pos.x()); + pos2.setY(pos.y()+20); + this->phoneMenu->exec(sdcardTableView->mapToGlobal(pos2)); +} + +void CwmWidget::phoneDelete() +{ + if (this->sdcardTableView->selectionModel()->selection().isEmpty()) + { + QMessageBox::information(this,"",tr("Select some items first!"),QMessageBox::Ok); + return; + } + + if (QMessageBox::question(this, tr("Deleting:"), tr("Are you sure???"), + QMessageBox::Ok | QMessageBox::No) == QMessageBox::No) + return; + + QModelIndexList indexList = this->sdcardTableView->selectionModel()->selectedRows(); + QModelIndex index; + while (!indexList.isEmpty()) + { + index = this->phoneSortModel->mapToSource(indexList.takeFirst()); + this->phone->remove(this->phoneModel->getFile(index.row()).fileName); + } + this->sdcardDisplay(); +} + +void CwmWidget::phoneDisplay(QTableView *tableView) +{ + QSettings settings; + tableView->setModel(this->phoneSortModel); + tableView->setDisabled(true); + this->phoneModel->clear(); + this->ui->lineEditPath->setText(this->phone->getPath()); + QString sdpath = this->ui->lineEditPath->text(); + if (sdpath.endsWith("/")) + this->ui->lineEditPath->setText(sdpath.remove(sdpath.length()-1,1)); + QList *fileList = NULL; + fileList = this->phone->getFileList(); + if (fileList == NULL) + return; + while (!fileList->isEmpty()) + { + this->phoneModel->insertFile(0, fileList->takeFirst()); + } + delete fileList; + tableView->resizeColumnsToContents(); + tableView->resizeRowsToContents(); + int i=0; + int rows = this->phoneModel->rowCount(); + for (i=0; isetRowHeight(i, 20); + tableView->sortByColumn(1, Qt::AscendingOrder); + tableView->setDisabled(false); + QStringList phoneColumnList = settings.value("phoneColumnList").toStringList(); + int col = this->phoneModel->columnCount(QModelIndex()); + for (i = 0; i < col; i++) + { + if (!phoneColumnList.contains(QString::number(i)) && !phoneColumnList.isEmpty()) + this->sdcardTableView->hideColumn(i); + else + this->sdcardTableView->showColumn(i); + } +} + +void CwmWidget::phoneHiddenFiles() +{ + this->phone->setHiddenFiles(!this->phone->getHiddenFilesState()); + this->sdcardDisplay(); +} + +void CwmWidget::phoneNewDir() +{ + if (!this->phone->makeDir("new dir")) + { + QMessageBox::information(this,tr("Error:"),tr("Directory was not created.\nMake sure directory doesn't exist and that you are allowed to do this!"),QMessageBox::Ok); + return; + } + this->sdcardDisplay(); + int row = this->phoneModel->getRow("new dir"); + QModelIndex index = this->phoneModel->index(row, 1, QModelIndex()); + this->sdcardTableView->selectRow(this->phoneSortModel->mapFromSource(index).row()); + QModelIndexList indexList = this->sdcardTableView->selectionModel()->selectedRows(1); + if (indexList.size() == 1) + { + QModelIndex index = indexList.first(); + this->sdcardTableView->edit(index); + connect (this->phoneModel, SIGNAL(dataChanged(QModelIndex,QModelIndex)), + this, SLOT(phoneRenameSlot(QModelIndex, QModelIndex))); + } +} + +void CwmWidget::phoneRename() +{ + QModelIndexList indexList = this->sdcardTableView->selectionModel()->selectedRows(1); + if (indexList.size() == 1) + { + QModelIndex index = indexList.first(); + this->sdcardTableView->edit(index); + connect (this->phoneModel, SIGNAL(dataChanged(QModelIndex,QModelIndex)), + this, SLOT(phoneRenameSlot(QModelIndex, QModelIndex))); + } +} + +void CwmWidget::phoneRenameSlot(QModelIndex indexS, QModelIndex indexE) +{ + disconnect (this->phoneModel, SIGNAL(dataChanged(QModelIndex, QModelIndex)), + this, SLOT(phoneRenameSlot(QModelIndex, QModelIndex))); + + if (indexS == indexE) + { + File tmpFile = this->phoneModel->getFile(indexS.row()); + QString oldFile = tmpFile.filePath; + oldFile.remove(this->phone->getPath()); + this->phone->rename(oldFile, indexS.data(Qt::DisplayRole).toString()); + this->sdcardDisplay(); + } +} + +void CwmWidget::sdcardLineEdit() +{ + if (phone->cd(ui->lineEditPath->text())) + { + this->phone->setPath(ui->lineEditPath->text()); + this->sdcardDisplay(); + } +} + +void CwmWidget::sdcardDisplay() +{ + this->phoneModel->setColoring(this->settings->color); + this->phone->setHiddenFiles(this->settings->phoneHiddenFiles); + this->sdcardTableView->horizontalHeader()->setVisible(this->settings->showPhoneColumnsHeaders); + this->phoneDisplay(this->sdcardTableView); + this->sdcardTableView->setFocus(); + int widthTab = this->sdcardTableView->width(); + int colIcon = 25; + int colName, colDate, colSize; + + this->sdcardTableView->resizeColumnsToContents(); + colSize = this->sdcardTableView->columnWidth(2); + colDate = this->sdcardTableView->columnWidth(3); + + this->sdcardTableView->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); + // this->sdcardTableView->verticalScrollBar()->adjustSize(); + // colName = widthTab - colIcon - colSize - colDate - this->sdcardTableView->verticalScrollBar()->width(); + + if (this->sdcardTableView->verticalScrollBar()->width() > 17) + this->sdcardTableView->verticalScrollBar()->adjustSize(); + + if (this->sdcardTableView->verticalScrollBar() == NULL) + colName = widthTab - colIcon - colSize - colDate; + else + colName = widthTab - colIcon - colSize - colDate - this->sdcardTableView->verticalScrollBar()->width(); + + this->sdcardTableView->setColumnWidth(0, colIcon); + this->sdcardTableView->setColumnWidth(1, colName -2); + this->sdcardTableView->setColumnWidth(2, colSize); + this->sdcardTableView->setColumnWidth(3, colDate + this->sdcardTableView->verticalScrollBar()->width()); + if (this->ui->lineEditPath->text() == "/sdcard" || this->ui->lineEditPath->text() == "/sdcard/") + this->ui->pushButtonDirectoryUp->setDisabled(true); + else if (this->ui->lineEditPath->text().startsWith("/sdcard")) + this->ui->pushButtonDirectoryUp->setEnabled(true); +} + +void CwmWidget::sdcardDoubleClick() +{ + if (!this->sdcardTableView->selectionModel()->selection().isEmpty()) + { + QModelIndex index; + QString fileName, fileType; + index = this->sdcardTableView->selectionModel()->selection().indexes().takeFirst(); + index = this->phoneSortModel->mapToSource(index); + fileName = this->phoneModel->getFile(index.row()).fileName; + fileType = this->phoneModel->getFile(index.row()).fileType; + if (fileName.contains(" -> ")) + { + fileName = fileName.split(" -> ").at(1); + } + if (fileType == "dir") + if (this->phone->cd(fileName)) + { + this->sdcardDisplay(); + this->ui->buttonInsert->setDisabled(true); + } + + if (fileType == "file") + this->on_buttonInsert_pressed(); + } +} + +void CwmWidget::propsDialog() +{ + QModelIndexList indexList = this->sdcardTableView->selectionModel()->selectedRows(1); + if (indexList.isEmpty()) + { + QMessageBox::information(this,"",tr("Select some item first!"),QMessageBox::Ok); + return; + } + if (indexList.size() == 1) + { + fipDialog *d = new fipDialog(this); + QModelIndex index = this->phoneSortModel->mapToSource(indexList.takeFirst()); + File tmpFile = this->phoneModel->getFile(index.row()); + QString file = tmpFile.filePath; + d->setData(file); + d->show(); + } + if (indexList.size() > 1) + { + QMessageBox::information(this,"",tr("Single item selection only!"),QMessageBox::Ok); + return; + } +} + +void CwmWidget::processFinished() +{ + connect(ui->tabWidget_2,SIGNAL(currentChanged(int)),this,SLOT(sdcardDisplay())); + processFind->start("\""+this->sdk+"\""+"adb shell rm -r /cache/qtadb/"); + processFind->waitForFinished(-1); + ui->plainTextEditStatus->setStyleSheet( "QPlainTextEdit {background-color:black;color:lightgreen;border: 1px solid #020202;border-radius: 1px;}" ); + this->ui->plainTextEditStatus->insertPlainText("--------------------\n"); + this->ui->plainTextEditStatus->insertPlainText("Process Finished!\n"); + this->ui->plainTextEditStatus->insertPlainText("--------------------\n"); + this->ui->plainTextEditStatus->ensureCursorVisible(); + if (which == "flash recovery") + { + which = ""; + QString flashout = this->ui->plainTextEditStatus->toPlainText(); + if (flashout.contains("error")) + { + ui->plainTextEditStatus->setStyleSheet( "QPlainTextEdit {background-color:black;color:red;border: 1px solid #020202;border-radius: 1px;}" ); + this->ui->plainTextEditStatus->insertPlainText("--------------------\n"); + this->ui->plainTextEditStatus->insertPlainText("Process Failed!\n"); + this->ui->plainTextEditStatus->insertPlainText("--------------------\n"); + this->ui->plainTextEditStatus->ensureCursorVisible(); + QMessageBox::information(this,"Flash New Recovery:","Flashing New Recovery FAILED!!!\nTry with moving img file to the root of /sdcard or changing its name to something more simple.\n\nSee Status for Detailes."); + } + else + { + commandRunning = "Not Running"; + if (QMessageBox::question(this, tr("Flash New Recovery:"),"Flashing Recovery Done!.\n\nDo you want to reboot Phone to test the New Recovey?",QMessageBox::Yes | QMessageBox::No) == QMessageBox::Yes) + this->phone->adbRebootRecovery(); + } + } + else if (commandRunning == "Not Running" && which != "fix permissions") + QMessageBox::information(0,"Advanced Menu:"," Process Finished! "); + else if (which == "fix permissions") + { + commandRunning = "Not Running"; + which = ""; + if (QMessageBox::question(this, tr("Fix Permissions:"),"Fix Permissions Done!\n\nDo you want to reboot Phone Now?",QMessageBox::Yes | QMessageBox::No) == QMessageBox::Yes) + this->phone->adbReboot(); + } + this->buttonsEnabled(); + this->ui->buttonSystem->setEnabled(true); + if (this->phone->getConnectionState() == RECOVERY) + mountsEnable(); +} + +void CwmWidget::finishedWhich() +{ + if (which == "sdbackup") + { + which = "sdrestore"; + ui->plainTextEditStatus->setStyleSheet( "QPlainTextEdit {background-color:black;color:lightgreen;border: 1px solid #020202;border-radius: 1px;}" ); + this->ui->plainTextEditStatus->insertPlainText("----------------------------\n"); + this->ui->plainTextEditStatus->insertPlainText("SD Card Backup Finished!\n"); + this->ui->plainTextEditStatus->insertPlainText("----------------------------\n"); + this->ui->plainTextEditStatus->insertPlainText("\nRebooting Phone...\n"); + this->ui->plainTextEditStatus->ensureCursorVisible(); + buttonsDisabled(); + QTimer::singleShot(2000, this, SLOT(createPartition())); + } + else if (which == "sdrestore") + { + which = ""; + commandRunning = "Not Running"; + ui->plainTextEditStatus->setStyleSheet( "QPlainTextEdit {background-color:black;color:lightgreen;border: 1px solid #020202;border-radius: 1px;}" ); + this->ui->plainTextEditStatus->insertPlainText("-----------------------------\n"); + this->ui->plainTextEditStatus->insertPlainText("SD Card Restore Finished!\n"); + this->ui->plainTextEditStatus->insertPlainText("-----------------------------\n"); + this->ui->plainTextEditStatus->ensureCursorVisible(); + buttonsEnabled(); + this->ui->buttonSystem->setEnabled(true); + if (this->phone->getConnectionState() == RECOVERY) + mountsEnable(); + if (QMessageBox::question(this,tr("Restore SD Card:"),"SD Card content is now Restored!\n\nDo you want to remove \"" + currentDir.replace("/","\\") + "\\SD_Card\" Backup folder?",QMessageBox::Yes | QMessageBox::No) == QMessageBox::No) + return; + if (!this->computer->deleteDir(QDir::currentPath()+"/SD_Card/")) + QMessageBox::information(this,tr("Delete SD Card Backup Folder:"),"Unable to remove \"" + currentDir.replace("/","\\")+"\\SD_Card\" Backup folder!\n\nRemove it manually."); + } + else if (which == "md5sum") + { + this->md5sumVerify(); + which = ""; + commandRunning = "Not Running"; + this->buttonsEnabled(); + this->ui->buttonSystem->setEnabled(true); + if (this->phone->getConnectionState() == RECOVERY) + mountsEnable(); + } + this->ui->plainTextEditStatus->ensureCursorVisible(); +} + +void CwmWidget::on_buttonFixPermissions_pressed() +{ + which = "fix permissions"; + QString tool = "/system/bin/fix_permissions"; + processFind->start("\""+sdk+"\"" + "adb shell find " + tool); + processFind->waitForFinished(-1); + QString outputFind = processFind->readAll(); + if (outputFind.contains("No such file")) + { + tool = "/system/xbin/fix_permissions"; + processFind->start("\""+sdk+"\"" + "adb shell find " + tool); + processFind->waitForFinished(-1); + outputFind = processFind->readAll(); + if (outputFind.contains("No such file")) + { + tool = this->adbPushTool("fix_permissions"); + } + } + commandRunning = "Not Running"; + this->processStarted(); + QString commandFixPerm="\""+sdk+"\"" + "adb shell su -c '" + tool + "'"; + process->start(commandFixPerm); + process->waitForReadyRead(-1); +} + +void CwmWidget::printProcess(QString processOut) +{ + int i; + for (i = 0; i < processOut.length(); i++) + { + if (processOut.at(i).unicode() == 13) + processOut[i] = ' '; + if (processOut.at(i).unicode() == 10) + processOut[i] = '\n'; + } + if (processOut.contains(QChar( 0x1b ), Qt::CaseInsensitive)) + { + processOut.remove("[0m"); + processOut.remove(QChar( 0x1b ), Qt::CaseInsensitive); + processOut.remove(QRegExp("\\[\\d;\\d+m")); + this->ui->plainTextEditStatus->insertPlainText(processOut); + } + else + { + this->ui->plainTextEditStatus->insertPlainText(processOut); + } + this->ui->plainTextEditStatus->ensureCursorVisible(); +} + +void CwmWidget::readFromProcess() +{ + QString processOut = QString::fromUtf8(process->readAllStandardOutput()); + printProcess(processOut); +} + +void CwmWidget::readFromProcessWhich() +{ + QTextStream rsyncStdoutStream(processWhich->readAllStandardOutput()); + QString processOut = rsyncStdoutStream.readAll(); + printProcess(processOut); +} + +void CwmWidget::buttonsDisabled() +{ + this->ui->buttonFixPermissions->setDisabled(true); + this->ui->buttonCreate->setDisabled(true); + this->ui->buttonWipe->setDisabled(true); + this->ui->buttonInstall->setDisabled(true); + this->ui->buttonBackup->setDisabled(true); + this->ui->buttonRestore->setDisabled(true); + this->ui->buttonUpdate->setDisabled(true); + this->ui->buttonFlash->setDisabled(true); + this->ui->tabWidget_2->setTabEnabled(0,false); + this->ui->checkBacBoot->setDisabled(true); + this->ui->checkBacCache->setDisabled(true); + this->ui->checkBacData->setDisabled(true); + this->ui->checkBacSdext->setDisabled(true); + this->ui->checkBacSystem->setDisabled(true); + this->ui->checkAfter->setDisabled(true); + this->ui->checkBefore->setDisabled(true); + this->ui->buttonFixMarket->setDisabled(true); +} + +QString CwmWidget::adbPushTool(QString toolName) +{ + disconnect(ui->tabWidget_2,SIGNAL(currentChanged(int)),this,SLOT(sdcardDisplay())); + processFind->start("\""+this->sdk+"\""+"adb push \""+QDir::currentPath()+"/tools/" + toolName + "\" /cache/qtadb/"+ toolName); + processFind->waitForFinished(-1); + processFind->start("\""+this->sdk+"\""+"adb shell chmod 755 /cache/qtadb/" + toolName); + processFind->waitForFinished(-1); + processFind->start("\""+this->sdk+"\""+"adb shell sync"); + processFind->waitForFinished(-1); + toolName.prepend("/cache/qtadb/"); + return toolName; +} + +void CwmWidget::on_buttonCreate_pressed() +{ + if (QMessageBox::warning(this, tr("Partition SD Card:"),tr("All DATA on SD Card will be LOST!!! \nAre you sure?"),QMessageBox::Ok | QMessageBox::Cancel) == QMessageBox::Cancel) + return; + if (this->ui->checkBackupSdcars->isChecked()) + { + ui->plainTextEditStatus->setStyleSheet( "QPlainTextEdit {background-color:black;color:white;border: 1px solid #020202;border-radius: 1px;}" ); + this->ui->tabWidget_2->setCurrentIndex(1); + this->ui->plainTextEditStatus->clear(); + this->ui->plainTextEditStatus->insertPlainText("-----------------------------\n"); + this->ui->plainTextEditStatus->insertPlainText("SD Card Backup Started...\n"); + this->ui->plainTextEditStatus->insertPlainText("-----------------------------\n"); + this->ui->plainTextEditStatus->ensureCursorVisible(); + this->buttonsDisabled(); + which = "sdbackup"; + this->backupPath = "/sdcard/LOST.DIR/"; + + + phone->setPath("/sdcard/"); + QList *fileList = NULL; + fileList = phone->getFileList(); + this->dialog = new dialogKopiuj(this, fileList, this->sdk, dialogKopiuj::PhoneToComputer, + "/sdcard/", QDir::currentPath()+"/SD_Card/"); + this->dialog->closeAfterFinished(); + this->dialog->show(); + connect(this->dialog, SIGNAL(finished(int)), this, SLOT(finishedWhich())); + connect(this->dialog, SIGNAL(progressValue(int,int)), this, SIGNAL(progressValue(int,int))); + connect(this->dialog, SIGNAL(finished(int)), this, SIGNAL(copyFinished(int))); + connect(this->dialog, SIGNAL(copyCanceled()), this, SLOT(sdbackupCanceled())); + } + else + { + which = "sdrestore"; + createPartition(); + } +} + +void CwmWidget::createPartition() +{ + if (which == "sdrestore") + { + QString size, type; + if (this->ui->radio128->isChecked()) + size = "128"; + if (this->ui->radio256->isChecked()) + size = "256"; + if (this->ui->radio512->isChecked()) + size = "512"; + if (this->ui->radio1024->isChecked()) + size = "1024"; + if (this->ui->radio2048->isChecked()) + size = "2048"; + if (this->ui->radio4096->isChecked()) + size = "4096"; + if (this->ui->radioExt2->isChecked()) + type = "ext2"; + if (this->ui->radioExt3->isChecked()) + type = "ext3"; + if (this->ui->radioExt4->isChecked()) + type = "ext4"; + this->adbPushTool("e2fsck"); + this->adbPushTool("parted"); + this->adbPushTool("sdparted"); + this->adbPushTool("tune2fs"); + this->adbPushTool("dopartition.sh"); + QString infoLine = "ui_print(\"Partitioning SD Card...\");"; + QString commandLine = "run_program(\"/cache/qtadb/dopartition.sh\", \"" + size + "M\", \"" + type + "\")"; + this->extendedcommandFile(infoLine, commandLine); + this->extendedcommandFile("execute commands", ""); + this->phone->adbRebootRecovery(); + } +} + +void CwmWidget::extendedcommandFile(QString infoLine, QString commandLine) +{ + QFile extendedcommand(QDir::currentPath()+"/tmp/extendedcommand"); + if (!commandLine.isEmpty()) + { + if (extendedcommand.open(QIODevice::WriteOnly) | QIODevice::Text) + { + QTextStream text(&extendedcommand); + QDateTime current = QDateTime::currentDateTime(); + QString time = current.toString ("ddd, MMMM d, yyyy, h:mm ap"); + text << "ui_print(\"QtADB Process Started...\");\n" << "ui_print(\"" + time + "\");\n" << infoLine + "\n" << commandLine; + extendedcommand.close(); + } + } + if (infoLine == "execute commands") + { + processFind->start("\""+this->sdk+"\""+"adb shell rm -f /cache/recovery/command"); + processFind->waitForFinished(-1); + processFind->start("\""+this->sdk+"\""+"adb push \""+QDir::currentPath()+"/tmp/extendedcommand\" /cache/recovery/"); + processFind->waitForFinished(-1); + extendedcommand.remove(); + commandRunning = "running"; + readLog = "read"; + this->ui->plainTextEditStatus->clear(); + ui->plainTextEditStatus->setStyleSheet( "QPlainTextEdit {background-color:black;color:lightgreen;border: 1px solid #020202;border-radius: 1px;}" ); + this->ui->plainTextEditStatus->insertPlainText("Rebooting to Recovery..."); + this->ui->tabWidget_2->setCurrentIndex(1); + } +} + +void CwmWidget::tailLog() +{ + processStarted(); + process->start("\""+this->sdk+"\""+"adb shell tail -f -n 1000 /tmp/recovery.log"); + process->waitForReadyRead(-1); +} + +void CwmWidget::readFromLog() +{ + QProcess tmpremove; + tmpremove.start("\""+this->sdk+"\""+"adb shell rm -r /cache/qtadb/"); + tmpremove.waitForFinished(-1); + this->ui->plainTextEditStatus->clear(); + this->ui->plainTextEditStatus->insertPlainText("--------------------\n"); + this->ui->plainTextEditStatus->insertPlainText("Log Begins...\n"); + this->ui->plainTextEditStatus->insertPlainText("--------------------\n"); + this->ui->plainTextEditStatus->ensureCursorVisible(); + ui->plainTextEditStatus->setStyleSheet( "QPlainTextEdit {background-color:black;color:lightgreen;border: 1px solid #020202;border-radius: 1px;}" ); + processFind->start("\""+this->sdk+"\""+"adb shell find /cache/recovery/log"); + processFind->waitForFinished(-1); + QString out = processFind->readAll(); + QProcess log; + log.setProcessChannelMode(QProcess::MergedChannels); + if (out.contains("No such file")) + log.start("\""+this->sdk+"\""+"adb shell cat /cache/recovery/last_log"); + else + log.start("\""+this->sdk+"\""+"adb shell cat /cache/recovery/log"); + log.waitForFinished(-1); + QString processOut = QString::fromUtf8(log.readAll()); + this->printProcess(processOut); + this->threadSdcard->sleep(1); + this->ui->plainTextEditStatus->insertPlainText("\n--------------------\n"); + this->ui->plainTextEditStatus->insertPlainText("Log End!\n"); + this->ui->plainTextEditStatus->insertPlainText("--------------------\n"); + this->ui->plainTextEditStatus->ensureCursorVisible(); + if (commandRunning == "running") + { + commandRunning = "Not Running"; + QMessageBox::information(0,"Advanced Menu:"," Process Finished! "); + } + QString sdFailed = this->ui->plainTextEditStatus->toPlainText(); + if (sdFailed.contains("Can't mount /sdcard")) + { + ui->plainTextEditStatus->setStyleSheet( "QPlainTextEdit {background-color:black;color:red;border: 1px solid #020202;border-radius: 1px;}" ); + QMessageBox::warning(this, tr("Log:"),"Timed out waiting for SD Card to mount! See Log for details.\n\nYou will need to repeat this operation."); + } + else + { + if (!this->backupPath.isEmpty()) + { + this->threadSdcard->sleep(3); + processFind->start("\""+this->sdk+"\"" + "adb shell find /dev/block/mmc*"); + processFind->waitForFinished(-1); + QString out = processFind->readAll(); + if (!out.contains("No such file")) + { + //this->ui->tabWidget->setCurrentIndex(3); + this->threadSdcard = new ThreadSdcard; + this->threadSdcard->backupPath = this->backupPath; + this->threadSdcard->sdk = this->sdk; + this->threadSdcard->start(); + connect(this->threadSdcard,SIGNAL(backupVerifiable()),this,SLOT(backupAvailable())); + this->ui->plainTextEditStatus->insertPlainText("\nWating for SD Card availability..."); + this->ui->plainTextEditStatus->ensureCursorVisible(); + } + else + { + if (QMessageBox::question(this, tr("Reboot:"),"Your phone failed to detect SD Card! Reboot is required.\n\nDo you want to Reboot it now?",QMessageBox::Yes | QMessageBox::No) == QMessageBox::No) + return; + if (!this->ui->lineBackup->text().isEmpty()) + { + backupPath = this->ui->lineBackup->text(); + which = "backupVerify"; + } + readLog == "read"; + this->phone->adbReboot(); + } + + } + } +} +void CwmWidget::processStarted() +{ + ui->plainTextEditStatus->setStyleSheet( "QPlainTextEdit {background-color:black;color:white;border: 1px solid #020202;border-radius: 1px;}" ); + this->ui->tabWidget_2->setCurrentIndex(1); + this->ui->plainTextEditStatus->clear(); + this->ui->plainTextEditStatus->insertPlainText("--------------------\n"); + this->ui->plainTextEditStatus->insertPlainText("Process Started...\n"); + this->ui->plainTextEditStatus->insertPlainText("--------------------\n"); + this->ui->plainTextEditStatus->ensureCursorVisible(); + this->buttonsDisabled(); + this->mountsDisable(); + this->ui->buttonSystem->setEnabled(false); +} + +void CwmWidget::buttonsEnabled() +{ + this->ui->checkLink2Sd->setEnabled(false); + this->ui->checkBackupSdcars->setDisabled(false); + this->ui->checkAfter->setDisabled(false); + this->ui->checkBefore->setDisabled(false); + this->ui->buttonFixPermissions->setEnabled(true); + this->ui->tabWidget_2->setTabEnabled(0,true); + this->ui->buttonCreate->setDisabled(true); + this->ui->buttonWipe->setDisabled(true); + this->ui->checkCache->setDisabled(false); + this->ui->checkBattery->setDisabled(false); + this->ui->buttonInstall->setDisabled(true); + this->ui->buttonBackup->setDisabled(true); + this->ui->buttonRestore->setDisabled(true); + this->ui->buttonUpdate->setDisabled(true); + this->ui->buttonFlash->setDisabled(true); + this->ui->checkBefore->setEnabled(false); + this->ui->checkAfter->setEnabled(false); + this->ui->labelBefore->setEnabled(false); + this->ui->labelAfter->setEnabled(false); + this->ui->buttonFixMarket->setDisabled(false); + this->ui->buttonRecovery->setEnabled(false); + if (this->ui->radio128->isChecked()) + this->ui->buttonCreate->setEnabled(true); + if (this->ui->radio256->isChecked()) + this->ui->buttonCreate->setEnabled(true); + if (this->ui->radio512->isChecked()) + this->ui->buttonCreate->setEnabled(true); + if (this->ui->radio1024->isChecked()) + this->ui->buttonCreate->setEnabled(true); + if (this->ui->radio2048->isChecked()) + this->ui->buttonCreate->setEnabled(true); + if (this->ui->radio4096->isChecked()) + this->ui->buttonCreate->setEnabled(true); + if (this->ui->checkData->isChecked()) + { + this->ui->buttonWipe->setEnabled(true); + this->ui->checkCache->setChecked(false); + this->ui->checkBattery->setChecked(false); + this->ui->checkCache->setDisabled(true); + this->ui->checkBattery->setDisabled(true); + } + if (this->ui->checkCache->isChecked()) + this->ui->buttonWipe->setEnabled(true); + if (this->ui->checkDalvik->isChecked()) + this->ui->buttonWipe->setEnabled(true); + if (this->ui->checkBattery->isChecked()) + this->ui->buttonWipe->setEnabled(true); + if (this->ui->radioInstallPath->isChecked()) + { + this->ui->buttonInstall->setDisabled(false); + this ->ui->lineInstallPath->setDisabled(false); + } + if (this->ui->radioUpdateZip->isChecked()) + { + this->ui->buttonInstall->setDisabled(false); + this ->ui->lineInstallPath->setDisabled(true); + this->ui->buttonInsert->setEnabled(false); + } + if (this->ui->checkDefaultBackupDir->isChecked()) + { + if (this->backupPath.isEmpty()) + { + QDateTime current = QDateTime::currentDateTime(); + QString time = current.toString ("ddd, MMMM d, yyyy, h:mm ap"); + time.remove(","); + time.replace(" ","-"); + time.replace(":","_"); + this->ui->lineBackup->setText("/sdcard/clockworkmod/backup/" + time.append("/")); + } + this->ui->buttonInsert->setEnabled(false); + this->ui->buttonBackup->setDisabled(false); + } + else + { + this->ui->lineBackup->clear(); + this->activateButtonInsert(); + } + if (!this->ui->lineBackup->text().isEmpty()) + this->ui->buttonBackup->setEnabled(true); + if (!this->ui->lineRestore->text().isEmpty()) + { + this->ui->checkBacBoot->setEnabled(true); + this->ui->checkBacCache->setEnabled(true); + this->ui->checkBacData->setEnabled(true); + this->ui->checkBacSdext->setEnabled(true); + this->ui->checkBacSystem->setEnabled(true); + if (this->ui->checkBacBoot->isChecked()) + this->ui->buttonRestore->setEnabled(true); + if (this->ui->checkBacCache->isChecked()) + this->ui->buttonRestore->setEnabled(true); + if (this->ui->checkBacData->isChecked()) + this->ui->buttonRestore->setEnabled(true); + if (this->ui->checkBacSdext->isChecked()) + this->ui->buttonRestore->setEnabled(true); + if (this->ui->checkBacSystem->isChecked()) + this->ui->buttonRestore->setEnabled(true); + } + if (!this->ui->lineUpdate->text().isEmpty()) + this->ui->buttonUpdate->setEnabled(true); + if (!this->ui->lineFlash->text().isEmpty()) + { + this->ui->buttonFlash->setEnabled(true); + this->ui->checkBefore->setEnabled(true); + this->ui->checkAfter->setEnabled(true); + this->ui->labelBefore->setEnabled(true); + this->ui->labelAfter->setEnabled(true); + } + if (this->ui->tabWidget_3->currentIndex() == 1) + { + QProcess down; + down.start("\"" + sdk + "\"" + "adb shell ls -l /cache/download"); + down.waitForReadyRead(-1); + QString out = down.readAll(); + if (out.contains("/cache/download ->")) + { + down.start("\"" + sdk + "\"" + "adb shell ls -l /sdcard/cache/download"); + down.waitForReadyRead(-1); + QString out = down.readAll(); + if (!out.contains("No such file")) + { + this->ui->buttonFixMarket->setText("Undo Fix Market"); + this->ui->label_12->setText("Your Market Cache Download is already moved to SD Card!"); + } + } + else + { + this->ui->buttonFixMarket->setText("Fix Market"); + this->ui->label_12->setText("Fixes the \"insufficient space\" issue in downloading applications from Google Market by moving Market Download Cache to SD Card."); + } + } + if (!this->ui->lineRecovery->text().isEmpty()) + this->ui->buttonRecovery->setEnabled(true); + if (this->ui->tabWidget->currentIndex() == 5) + { + if (!this->ui->lineUpdate->text().isEmpty()) + { + QProcess link; + link.start("\"" + sdk + "\"" + "adb shell find /system/etc/init.d/11link2sd"); + link.waitForReadyRead(-1); + QString out = link.readAll(); + if (!out.contains("No such file")) + this->ui->checkLink2Sd->setEnabled(true); + else + this->ui->checkLink2Sd->setText("Link2SD not detected."); + } + } +} + +void CwmWidget::on_buttonSdinfo_pressed() +{ + this->adbPushTool("parted"); + this->processStarted(); + process->start("\""+this->sdk+"\""+"adb shell /cache/qtadb/parted /dev/block/mmcblk0 print"); + process->waitForFinished(-1); + this->readFromProcess(); +} + +void CwmWidget::on_buttonWipe_pressed() +{ + QString mess, wipeData, wipeCache, wipeDalvik, wipeBattery, command, data, cache, dalvik, battery; + mess = wipeData = wipeCache = wipeBattery = wipeDalvik = data = cache = dalvik = battery = ""; + if (this->ui->checkData->isChecked()) + { + wipeData = "\n---Data/Factory Reset - this will erase all user data in Recovery(NOT in Android Privacy Settings), formating /data, /cache, /sd-ext and /sdcard/.android_secure;"; + data = "assert(format(\"/data\"));\nassert(format(\"/cache\"));\nassert(format(\"/sd-ext\"));\nassert(format(\"/sdcard/.android_secure\"));\n"; + } + if (this->ui->checkCache->isChecked()) + { + wipeCache = "\n---Cache - this will erase /cache;"; + cache = "assert(format(\"/cache\"));\n"; + } + if (this->ui->checkDalvik->isChecked()) + { + wipeDalvik = "\n---Dalvik Cache - this will erase /dalvik-cache in /data, /cache and /sd-ext;"; + this->adbPushTool("dowipedalvikcache.sh"); + dalvik = "run_program(\"/cache/qtadb/dowipedalvikcache.sh\");\n"; + } + if (this->ui->checkBattery->isChecked()) + { + wipeBattery = "\n---Battery Stats - this will erase /data/system/batterystats.bin reseting Battery Statistics;"; + this->adbPushTool("dowipebatterystats.sh"); + battery = "run_program(\"/cache/qtadb/dowipebatterystats.sh\");\n"; + } + mess = wipeData + wipeCache + wipeDalvik + wipeBattery; + if (QMessageBox::warning(this, tr("Wipe:"),"Wipe:" + mess + "\n\nAre you sure?",QMessageBox::Ok | QMessageBox::Cancel) == QMessageBox::Cancel) + return; + command = dalvik+ battery + data + cache; + this->extendedcommandFile("ui_print(\"Wiping...\");", command.trimmed()); + this->extendedcommandFile("execute commands", ""); + this->phone->adbRebootRecovery(); +} + +void CwmWidget::on_buttonInstall_pressed() +{ + QString installPath; + if (this->ui->radioUpdateZip->isChecked()) + installPath = "/sdcard/update.zip"; + if (this->ui->radioInstallPath->isChecked()) + { + installPath = this ->ui->lineInstallPath->text(); + if (installPath.isEmpty()) + { + QMessageBox::information(this, tr("Install Zip:"),tr("Select and confirm Zip to install from /sdcard below!")); + return; + } + if (!installPath.startsWith("/sdcard/")) + { + QMessageBox::information(this, tr("Install Zip:"),tr("Zip must be located on /sdcard !")); + return; + } + } + if (QMessageBox::question(this, tr("Install Zip:"),"Your phone will reboot in Recovery and \"" + installPath + "\" will be installed.\n\nAre you sure?",QMessageBox::Ok | QMessageBox::Cancel) == QMessageBox::Cancel) + return; + this->extendedcommandFile("ui_print(\"Installing...\");", "install_zip(\"" + installPath + "\");"); + this->extendedcommandFile("execute commands", ""); + this->phone->adbRebootRecovery(); +} + +void CwmWidget::on_buttonInsert_pressed() +{ + QModelIndexList indexList = sdcardTableView->selectionModel()->selectedRows(1); + if (indexList.isEmpty()) + { + QMessageBox::information(this,"Insert Selection:",tr("Select some item first!"),QMessageBox::Ok); + return; + } + if (indexList.size() > 1) + { + QMessageBox::information(this,"Insert Selection:",tr("Single item selection only!"),QMessageBox::Ok); + return; + } + if (indexList.size() == 1) + { + QModelIndex index = phoneSortModel->mapToSource(indexList.takeFirst()); + File tmpFile = phoneModel->getFile(index.row()); + QString itemPath = tmpFile.filePath; + QString itemType = tmpFile.fileType; + if (this->ui->tabWidget->currentIndex() == 2 && this->ui->radioInstallPath->isChecked()) + { + if (itemPath.startsWith("/sdcard/") && itemType == "file" && itemPath.endsWith(".zip")) + this ->ui->lineInstallPath->setText(itemPath); + else + QMessageBox::information(this,"Insert Selection:",tr("Valid Zip file must be selected!")); + } + if (this->ui->tabWidget->currentIndex() == 3 && !this->ui->checkDefaultBackupDir->isChecked()) + { + if (itemPath.startsWith("/sdcard/") && itemType == "dir") + { + if (itemPath.contains(" ")) + { + QMessageBox::information(this,"Insert Selection:",tr("No empty space allowed in Directory Path/Name!")); + return; + } + processFind->start("\""+this->sdk+"\""+"adb shell ls \"" + this->codec->toUnicode(itemPath.toUtf8()) + "\""); + processFind->waitForFinished(-1); + QString output = processFind->readAll(); + if (output.contains("nandroid.md5")) + if (QMessageBox::question(this, tr("Insert Selection:"),"Directory \"" + itemPath + "\" seems to contain Nandroid Backup already.\nDo you want to overwrite it?",QMessageBox::Yes | QMessageBox::No) == QMessageBox::No) + return; + disconnect(this->ui->lineBackup, SIGNAL(textChanged(QString)),this,SLOT(buttonsEnabled())); + this ->ui->lineBackup->setText(itemPath); + this->ui->buttonBackup->setEnabled(true); + connect(this->ui->lineBackup, SIGNAL(textChanged(QString)),this,SLOT(buttonsEnabled())); + } + else + QMessageBox::information(this,"Insert Selection:",tr("Directory must be selected!")); + } + if (this->ui->tabWidget->currentIndex() == 4) + { + if (itemPath.startsWith("/sdcard/") && itemType == "dir") + { + this ->ui->lineRestore->setText(itemPath); + if (QMessageBox::question(this, tr("Insert Selection:"),"Do you want to check Backup's MD5 Sum before Restore?",QMessageBox::Yes | QMessageBox::No) == QMessageBox::No) + return; + this ->ui->lineRestore->setDisabled(true); + this->buttonsDisabled(); + this->mountsDisable(); + this->ui->buttonSystem->setEnabled(false); + which = "md5sum"; + ui->plainTextEditStatus->setStyleSheet( "QPlainTextEdit {background-color:black;color:white;border: 1px solid #020202;border-radius: 1px;}" ); + this->ui->plainTextEditStatus->clear(); + this->ui->plainTextEditStatus->insertPlainText("---------------------------\n"); + this->ui->plainTextEditStatus->insertPlainText("Backup Verify: Started...\n"); + this->ui->plainTextEditStatus->insertPlainText("---------------------------\n"); + this->ui->tabWidget_2->setCurrentIndex(1); + this->adbPushTool("domd5sum.sh"); + processWhich->start("\""+sdk+"\"" + "adb shell /cache/qtadb/domd5sum.sh " + this->codec->toUnicode(itemPath.toUtf8())); + processWhich->waitForReadyRead(-1); + } + } + if (this->ui->tabWidget->currentIndex() == 5) + { + if (itemPath.startsWith("/sdcard/") && itemType == "file" && itemPath.endsWith(".zip")) + this ->ui->lineUpdate->setText(itemPath); + else + QMessageBox::information(this,"Insert Selection:",tr("Valid ROM file must be selected!")); + } + if (this->ui->tabWidget->currentIndex() == 6) + { + if (itemPath.startsWith("/sdcard/") && itemType == "file" && itemPath.endsWith(".zip")) + { + if (!this->ui->checkBefore->isChecked() && !this->ui->checkAfter->isChecked()) + this ->ui->lineFlash->setText(itemPath); + else + { + QMessageBox msgBox(this); + msgBox.setIcon(QMessageBox::Information); + msgBox.setWindowTitle("Insert Selection:"); + msgBox.setText("File: " + itemPath); + msgBox.setInformativeText("What is this file for:"); + QPushButton *before = msgBox.addButton(tr(" Install BEFORE "), QMessageBox::AcceptRole); + QPushButton *rom = msgBox.addButton(tr(" ROM to Flash "),QMessageBox::DestructiveRole); + QPushButton *after = msgBox.addButton(tr(" Install AFTER "),QMessageBox::ActionRole); + msgBox.addButton(QMessageBox::Cancel); + msgBox.setDefaultButton(QMessageBox::Cancel); + if (!this->ui->checkBefore->isChecked()) + msgBox.removeButton(before); + if (!this->ui->checkAfter->isChecked()) + msgBox.removeButton(after); + msgBox.exec(); + if (msgBox.clickedButton() == before) + this ->ui->labelBefore->setText("" + itemPath + ""); + else if (msgBox.clickedButton() == rom) + this ->ui->lineFlash->setText(itemPath); + else if (msgBox.clickedButton() == after) + this ->ui->labelAfter->setText("" + itemPath + ""); + } + } + else + QMessageBox::information(this,"Insert Selection:",tr("Valid ROM file must be selected!")); + } + if (this->ui->tabWidget_3->currentIndex() == 2) + { + if (itemPath.startsWith("/sdcard/") && itemType == "file" && itemPath.endsWith(".img")) + this ->ui->lineRecovery->setText(itemPath); + else + QMessageBox::information(this,"Insert Selection:",tr("Valid IMG file must be selected!")); + } + } +} + +void CwmWidget::activateButtonInsert() +{ + QModelIndexList indexList = sdcardTableView->selectionModel()->selectedRows(1); + if (indexList.size() == 1) + { + QModelIndex index = phoneSortModel->mapToSource(indexList.takeFirst()); + File tmpFile = phoneModel->getFile(index.row()); + QString itemPath = tmpFile.filePath; + QString itemType = tmpFile.fileType; + this->ui->lineEditPath->setText(itemPath); + if (this->ui->tabWidget->currentIndex() == 2 && this->ui->radioInstallPath->isChecked()) + { + if (itemPath.startsWith("/sdcard/") && itemType == "file" && itemPath.endsWith(".zip")) + { + this ->ui->buttonInsert->setEnabled(true); + } + else + { + this ->ui->buttonInsert->setEnabled(false); + } + } + if (this->ui->tabWidget->currentIndex() == 3 && !this->ui->checkDefaultBackupDir->isChecked()) + { + if (itemPath.startsWith("/sdcard/") && itemType == "dir") + { + this ->ui->buttonInsert->setEnabled(true); + } + else + { + this ->ui->buttonInsert->setEnabled(false); + } + } + if (this->ui->tabWidget->currentIndex() == 4) + { + if (itemPath.startsWith("/sdcard/") && itemType == "dir") + { + processFind->start("\""+this->sdk+"\""+"adb shell ls \"" + this->codec->toUnicode(itemPath.toUtf8()) + "\""); + processFind->waitForFinished(-1); + QString output = processFind->readAll(); + if (output.contains("nandroid.md5")) + { + this ->ui->buttonInsert->setEnabled(true); + } + else + { + this ->ui->buttonInsert->setEnabled(false); + } + } + else + { + this ->ui->buttonInsert->setEnabled(false); + } + } + if (this->ui->tabWidget->currentIndex() == 5) + { + if (itemPath.startsWith("/sdcard/") && itemType == "file" && itemPath.endsWith(".zip")) + { + this ->ui->buttonInsert->setEnabled(true); + } + else + { + this ->ui->buttonInsert->setEnabled(false); + } + } + if (this->ui->tabWidget->currentIndex() == 6) + { + if (itemPath.startsWith("/sdcard/") && itemType == "file" && itemPath.endsWith(".zip")) + { + this ->ui->buttonInsert->setEnabled(true); + } + else + { + this ->ui->buttonInsert->setEnabled(false); + } + } + if (this->ui->tabWidget_3->currentIndex() == 2) + { + if (itemPath.startsWith("/sdcard/") && itemType == "file" && itemPath.endsWith(".img")) + { + this ->ui->buttonInsert->setEnabled(true); + } + else + { + this ->ui->buttonInsert->setEnabled(false); + } + } + } + else + { + this ->ui->buttonInsert->setEnabled(false); + } + if (this ->ui->buttonInsert->isEnabled()) + this->ui->lineEditPath->setStyleSheet( "QLineEdit {background-color:white;color:green;}" ); + else + this->ui->lineEditPath->setStyleSheet( "QLineEdit {background-color:white;color:red;}" ); +} + +void CwmWidget::on_buttonBackup_pressed() +{ + backupPath = this->ui->lineBackup->text(); + if (backupPath.isEmpty()) + { + QMessageBox::information(this, tr("Backup ROM:"),tr("Select and confirm Directory for Nandroid Backup from /sdcard below!")); + return; + } + if (!backupPath.startsWith("/sdcard/")) + { + QMessageBox::information(this, tr("Backup ROM:"),tr("The Directory for Nandroid Backup must be located on /sdcard !")); + return; + } + if (QMessageBox::question(this, tr("Backup ROM:"),"Your phone will reboot in Recovery and Nandroid Backup will be made in \"" + backupPath + "\".\n\nDo you want to proceed?",QMessageBox::Ok | QMessageBox::Cancel) == QMessageBox::Cancel) + return; + which = "backupVerify"; + this->extendedcommandFile("ui_print(\"Backing up...\");", "assert(backup_rom(\"" + backupPath + "\"));"); + this->extendedcommandFile("execute commands", ""); + this->phone->adbRebootRecovery(); +} + +void CwmWidget::md5sumVerify() +{ + QString result = this->ui->plainTextEditStatus->toPlainText(); + if (result.contains("FAILED") || result.contains("WARNING")) + { + this ->ui->lineRestore->clear(); + this ->ui->lineRestore->setDisabled(false); + ui->plainTextEditStatus->setStyleSheet( "QPlainTextEdit {background-color:black;color:red;border: 1px solid #020202;border-radius: 1px;}" ); + this->ui->plainTextEditStatus->insertPlainText("-------------------------\n"); + this->ui->plainTextEditStatus->insertPlainText("Backup Verify: FAILED!!!\n"); + this->ui->plainTextEditStatus->insertPlainText("-------------------------\n"); + QMessageBox::warning(this,"Insert Selection:",tr("This Nandroid Backup is CORRUPT!\nSee result for details."),QMessageBox::Ok); + } + else + { + ui->plainTextEditStatus->setStyleSheet( "QPlainTextEdit {background-color:black;color:lightgreen;border: 1px solid #020202;border-radius: 1px;}" ); + this->ui->plainTextEditStatus->insertPlainText("-----------------------------\n"); + this->ui->plainTextEditStatus->insertPlainText("Backup Verify: SUCCESS!!!\n"); + this->ui->plainTextEditStatus->insertPlainText("-----------------------------\n"); + QMessageBox::information(this,"Insert Selection:",tr("This Nandroid Backup is GOOD."),QMessageBox::Ok); + this ->ui->lineRestore->setDisabled(false); + this ->ui->lineBackup->clear(); + this ->ui->checkDefaultBackupDir->setChecked(false); + } + if (!this->backupPath.isEmpty()) + this->backupPath = this->threadSdcard->backupPath = ""; +} + +void CwmWidget::on_buttonRestore_pressed() +{ + if (QMessageBox::question(this, tr("Restore Backup:"),"Your phone will reboot in Recovery and the selected Nandroid Backup will be restored.\n\nAre you sure?",QMessageBox::Ok | QMessageBox::Cancel) == QMessageBox::Cancel) + return; + QString no, no1, no2, no3, no4; + no = no1 = no2 = no3 = no4 = "no"; + if (this->ui->checkBacBoot->isChecked()) + no = ""; + if (this->ui->checkBacSystem->isChecked()) + no1 = ""; + if (this->ui->checkBacData->isChecked()) + no2 = ""; + if (this->ui->checkBacCache->isChecked()) + no3 = ""; + if (this->ui->checkBacSdext->isChecked()) + no4 = ""; + QString restorePath = this->ui->lineRestore->text(); + QString arg = "\"" + no + "boot\"" + ", \"" + no1 + "system\"" + ", \"" + no2 + "data\"" + ", \"" + no3 + "cache\"" + ", \"" + no4 + "sd-ext\""; + this->extendedcommandFile("ui_print(\"Restoring Nandroid Backup...\");", "assert(restore_rom(\"" + restorePath + "\", " + arg + "));"); + this->extendedcommandFile("execute commands", ""); + this->phone->adbRebootRecovery(); +} + +void ThreadSdcard::run() +{ + QProcess sd; + do + { + this->sleep(5); + sd.start("\""+this->sdk+"\"" + "adb shell find \"" + this->backupPath + "\""); + sd.waitForFinished(-1); + QString outsd = sd.readAll(); + if (!outsd.contains("No such file")) + break; + } + while (1 < 2); + emit backupVerifiable(); +} + +void CwmWidget::backupAvailable() +{ + this->threadSdcard->quit(); + disconnect(this->threadSdcard,SIGNAL(backupVerifiable()),this,SLOT(backupAvailable())); + QTextCursor tc = this->ui->plainTextEditStatus->textCursor(); + tc.movePosition( QTextCursor::StartOfLine ); + tc.select( QTextCursor::LineUnderCursor ); + tc.removeSelectedText(); + this->ui->plainTextEditStatus->insertPlainText("SD Card available...\n"); + this->ui->plainTextEditStatus->ensureCursorVisible(); + if (which == "sdrestore" && QDir(QDir::currentPath()+"/SD_Card").exists()) + { + if (!this->threadSdcard->backupPath.isEmpty()) + this->threadSdcard->backupPath = this->backupPath = ""; + this->backupPath = ""; + if (QMessageBox::question(this, tr("Create /sd-ext:"),"SD Card is repartitioned now.\n\nDo you want to Restore it's content to the newly created first fat32 partition?\n\nYou can answer \"No\" and do it manually later. The SD Card content is located in \n\"" + currentDir.replace("/","\\")+"\\SD_Card\".",QMessageBox::Yes | QMessageBox::No) == QMessageBox::No) + { + which = ""; + return; + } + ui->plainTextEditStatus->setStyleSheet( "QPlainTextEdit {background-color:black;color:white;border: 1px solid #020202;border-radius: 1px;}" ); + this->ui->tabWidget_2->setCurrentIndex(1); + this->ui->plainTextEditStatus->insertPlainText("-----------------------------\n"); + this->ui->plainTextEditStatus->insertPlainText("SD Card Restore Started...\n"); + this->ui->plainTextEditStatus->insertPlainText("-----------------------------\n"); + this->ui->plainTextEditStatus->ensureCursorVisible(); + processStarted(); + QList *fileList = NULL; + fileList = this->getFileList(); + this->dialog = new dialogKopiuj(this, fileList, this->sdk, dialogKopiuj::ComputerToPhone, + QDir::currentPath()+"/SD_Card/","/sdcard/" ); + this->dialog->closeAfterFinished(); + this->dialog->show(); + connect(this->dialog, SIGNAL(finished(int)), this, SLOT(finishedWhich())); + connect(this->dialog, SIGNAL(progressValue(int,int)), this, SIGNAL(progressValue(int,int))); + connect(this->dialog, SIGNAL(finished(int)), this, SIGNAL(copyFinished(int))); + connect(this->dialog, SIGNAL(copyCanceled()), this, SLOT(sdrestoreCanceled())); + } + else if (which == "") + return; + else if (which == "backupVerify") + { + this->ui->lineBackup->setText(this->threadSdcard->backupPath); + if (QMessageBox::question(this, tr("Backup ROM:"),tr("Do yuo want to verify MD5 Sum of the Backup you just did?\n\n You can press \"No\" and do it later by selecting it in \"Restore Backup\" tab."),QMessageBox::Yes | QMessageBox::No) == QMessageBox::No) + return; + this->buttonsDisabled(); + mountsDisable(); + which = "md5sum"; + ui->plainTextEditStatus->setStyleSheet( "QPlainTextEdit {background-color:black;color:white;border: 1px solid #020202;border-radius: 1px;}" ); + this->ui->plainTextEditStatus->clear(); + this->ui->plainTextEditStatus->insertPlainText("---------------------------\n"); + this->ui->plainTextEditStatus->insertPlainText("Backup Verify: Started...\n"); + this->ui->plainTextEditStatus->insertPlainText("---------------------------\n"); + this->ui->tabWidget_2->setCurrentIndex(1); + this->adbPushTool("domd5sum.sh"); + processWhich->start("\""+sdk+"\"" + "adb shell /cache/qtadb/domd5sum.sh \"" + this->threadSdcard->backupPath + "\"" ); + processWhich->waitForReadyRead(-1); + } +} + +void CwmWidget::on_buttonUpdate_pressed() +{ + QString updatePath = this->ui->lineUpdate->text(); + if (QMessageBox::question(this, tr("Update Current ROM:"),"Your phone will reboot in Recovery and the current ROM will be updated with \"" + updatePath + "\".\n\nAre you sure?",QMessageBox::Ok | QMessageBox::Cancel) == QMessageBox::Cancel) + return; + if (this->ui->checkLink2Sd->isChecked()) + { + this->adbPushTool("dowipedalviklink2sd.sh"); + this->adbPushTool("dolink2sd.sh"); + this->extendedcommandFile("ui_print(\"Updating Current ROM...\");", "run_program(\"/cache/qtadb/dowipedalviklink2sd.sh\");\nassert(format(\"/cache\"));\ninstall_zip(\"" + updatePath + "\");\nrun_program(\"/sbin/dolink2sd.sh\");"); + } + else + { + this->adbPushTool("dowipedalvikcache.sh"); + this->extendedcommandFile("ui_print(\"Updating Current ROM...\");", "run_program(\"/cache/qtadb/dowipedalvikcache.sh\");\nassert(format(\"/cache\"));\ninstall_zip(\"" + updatePath + "\");"); + } + this->extendedcommandFile("execute commands", ""); + this->phone->adbRebootRecovery(); +} + +void CwmWidget::checkFlash() +{ + QString before = this->ui->labelBefore->text(); + QString after = this->ui->labelAfter->text(); + if (this->ui->checkBefore->isChecked()) + { + if (before == "(like some wiper...)") + { + this->ui->labelBefore->setText( "Select Zip from /sdcard below..." ); + } + } + else + this->ui->labelBefore->setText( "(like some wiper...)" ); + if (this->ui->checkAfter->isChecked()) + { + if (after == "(like Google Apps, Theme...)") + { + this->ui->labelAfter->setText( "Select Zip from /sdcard below..." ); + } + } + else + this->ui->labelAfter->setText( "(like Google Apps, Theme...)" ); +} + +void CwmWidget::on_buttonFlash_pressed() +{ + QTextDocument docBefore, docAfter; + docBefore.setHtml(this->ui->labelBefore-> text()); + docAfter.setHtml(this->ui->labelAfter-> text()); + QString beforePath = docBefore.toPlainText(); + QString romPath = this->ui->lineFlash->text(); + QString afterPath = docAfter.toPlainText(); + QString msgBefore, msgAfter, commandBefore, commandAfter; + msgBefore = msgAfter = commandBefore = commandAfter = ""; + if (this->ui->checkBefore->isChecked()) + { + if (beforePath.startsWith("/sdcard/")) + { + msgBefore = "\n---\"" + beforePath + "\" will be installed;"; + commandBefore = "install_zip(\"" + beforePath + "\");\n"; + } + else + { + QMessageBox::information(this,"Flash New ROM:",tr("Did you check \"Install Zip...\" option(s)?\n\nSelect Zip(s) from /sdcard below and press [Confirm Selection]!")); + return; + } + } + if (this->ui->checkAfter->isChecked()) + { + if (afterPath.startsWith("/sdcard/")) + { + msgAfter = "\n---\"" + afterPath + "\" will be installed;"; + commandAfter = "install_zip(\"" + afterPath + "\");"; + } + else + { + QMessageBox::information(this,"Flash New ROM:",tr("Select Zip(s) to install from /sdcard below and press [Confirm Selection]!")); + return; + } + } + if (QMessageBox::question(this, tr("Flash ROM:"),"Your phone will reboot in Recovery and the following actions will be performed:\n---dalvik-cache will be wiped;\n---/boot, /system, /data and /cache partitions will be formated;" + msgBefore + "\n---\"" + romPath + "\" will be flashed;" + msgAfter + "\n\nAre you sure?",QMessageBox::Ok | QMessageBox::Cancel) == QMessageBox::Cancel) + return; + this->adbPushTool("dowipedalvikcache.sh"); + QString dalvik = "run_program(\"/cache/qtadb/dowipedalvikcache.sh\");\nassert(format(\"/data\"));\nassert(format(\"/cache\"));\nassert(format(\"/boot\"));\nassert(format(\"/system\"));\n"; + this->extendedcommandFile("ui_print(\"Flashing New ROM...\");", "run_program(\"/cache/qtadb/dowipedalvikcache.sh\");\nassert(format(\"/data\"));\nassert(format(\"/cache\"));\nassert(format(\"/boot\"));\nassert(format(\"/system\"));\n" + commandBefore + "install_zip(\"" + romPath + "\");\n" + commandAfter); + this->extendedcommandFile("execute commands", ""); + this->phone->adbRebootRecovery(); +} + +void CwmWidget::on_buttonFixMarket_pressed() +{ + QString market; + commandRunning = "Not Running"; + if (this->ui->buttonFixMarket->text() == "Undo Fix Market") + market = this->adbPushTool("undofixmarket.sh"); + else if (this->ui->buttonFixMarket->text() == "Fix Market") + market = this->adbPushTool("dofixmarket.sh"); + this->processStarted(); + process->start("\"" + sdk + "\"" + "adb shell " + market); + process->waitForReadyRead(-1); +} + +void CwmWidget::on_buttonRecovery_pressed() +{ + if (QMessageBox::question(this, tr("Flash New Recovery:"),"New Recovery is about to be flashed.\n\nAre you sure?",QMessageBox::Ok | QMessageBox::Cancel) == QMessageBox::Cancel) + return; + which = "flash recovery"; + QString imgPath = this->ui->lineRecovery->text(); + QString tool = "/system/bin/flash_image"; + processFind->start("\""+sdk+"\"" + "adb shell find " + tool); + processFind->waitForFinished(-1); + QString outputFind = processFind->readAll(); + if (outputFind.contains("No such file")) + tool = this->adbPushTool("flash_image"); + this->processStarted(); + process->start("\""+sdk+"\"" + "adb shell su -c \"" + tool + " recovery '" + this->codec->toUnicode(imgPath.toUtf8()) + "'\""); + process->waitForReadyRead(-1); +} + +void CwmWidget::sdbackupCanceled() +{ + if (!this->computer->deleteDir(QDir::currentPath()+"/SD_Card/")) + QMessageBox::information(this,tr("Delete SD Card Backup Folder:"),"Unable to remove \"" + currentDir.replace("/","\\")+"\\SD_Card\" Backup folder!\n\nRemove it manually."); + if (QMessageBox::question(this, tr("Backup SD Card:"),"Backup SD Card was Canceled.\n\nDo you want to continue with Partitioning the SD Card?\nALL SD Card DATA WILL BE LOST!!!",QMessageBox::Yes | QMessageBox::No) == QMessageBox::No) + { + if (!this->threadSdcard->backupPath.isEmpty()) + this->threadSdcard->backupPath = this->backupPath = ""; + this->backupPath = ""; + which = ""; + commandRunning = "Not Running"; + ui->plainTextEditStatus->setStyleSheet( "QPlainTextEdit {background-color:black;color:lightgreen;border: 1px solid #020202;border-radius: 1px;}" ); + this->ui->plainTextEditStatus->insertPlainText("----------------------------------\n"); + this->ui->plainTextEditStatus->insertPlainText("SD Card Backup Canceled!\n"); + this->ui->plainTextEditStatus->insertPlainText("SD Card Partitioning Canceled!\n"); + this->ui->plainTextEditStatus->insertPlainText("----------------------------------\n"); + this->ui->plainTextEditStatus->ensureCursorVisible(); + buttonsEnabled(); + this->ui->buttonSystem->setEnabled(true); + if (this->phone->getConnectionState() == RECOVERY) + mountsEnable(); + return; + } + finishedWhich(); +} + +void CwmWidget::sdrestoreCanceled() +{ + if (!this->threadSdcard->backupPath.isEmpty()) + this->threadSdcard->backupPath = this->backupPath = ""; + this->backupPath = ""; + which = ""; + commandRunning = "Not Running"; + ui->plainTextEditStatus->setStyleSheet( "QPlainTextEdit {background-color:black;color:lightgreen;border: 1px solid #020202;border-radius: 1px;}" ); + this->ui->plainTextEditStatus->insertPlainText("-----------------------------------\n"); + this->ui->plainTextEditStatus->insertPlainText("SD Card Partitioning Finished!\n"); + this->ui->plainTextEditStatus->insertPlainText("SD Card Restore Canceled!\n"); + this->ui->plainTextEditStatus->insertPlainText("-----------------------------------\n"); + this->ui->plainTextEditStatus->ensureCursorVisible(); + buttonsEnabled(); + this->ui->buttonSystem->setEnabled(true); + if (this->phone->getConnectionState() == RECOVERY) + mountsEnable(); + if (QMessageBox::question(this, tr("Restore SD Card:"),"Restore SD Card was Canceled.\n\nDo you want to remove \"" + currentDir.replace("/","\\")+"\\SD_Card\" Backup folder?",QMessageBox::Yes | QMessageBox::No) == QMessageBox::No) + return; + if (!this->computer->deleteDir(QDir::currentPath()+"/SD_Card/")) + QMessageBox::information(this,tr("Delete SD Card Backup Folder:"),"Unable to remove \"" + currentDir.replace("/","\\")+"\\SD_Card\" Backup folder!\n\nRemove it manually."); +} + +QList *CwmWidget::getFileList() +{ + QDir directory; + directory.setPath(QDir::currentPath()+"/SD_Card/"); + QFileInfoList fileInfoList = directory.entryInfoList(QDir::AllEntries | QDir::NoDotAndDotDot); + QFileInfo fileInfo; + File file; + QList *fileList = new QList; + QFileIconProvider *provider = new QFileIconProvider; + while (!fileInfoList.isEmpty()) + { + fileInfo = fileInfoList.takeFirst(); + file.fileIcon = provider->icon(fileInfo); + file.fileName = fileInfo.fileName(); + file.fileSize = QString::number(fileInfo.size()); + file.fileDate = fileInfo.lastModified().toString("MMM dd yyyy"); + file.filePath = fileInfo.absoluteFilePath(); + file.filePermissions = ""; + file.fileOwner = fileInfo.owner(); + if (fileInfo.isDir()) + file.fileType = "dir"; + else + file.fileType = "file"; + fileList->append(file); + } + delete provider; + return fileList; +} + +void CwmWidget::mountsEnable() +{ + this->ui->buttonCache->setEnabled(true); + this->ui->buttonData->setEnabled(true); + this->ui->buttonSystem->setEnabled(true); + this->ui->buttonSdext->setEnabled(true); + this->ui->buttonSdcard->setEnabled(true); +} + +void CwmWidget::mountsDisable() +{ + this->ui->buttonCache->setEnabled(false); + this->ui->buttonData->setEnabled(false); + // this->ui->buttonSystem->setEnabled(false); + this->ui->buttonSdext->setEnabled(false); + this->ui->buttonSdcard->setEnabled(false); +} + +void CwmWidget::mountsUpdate() +{ + if (this->ui->tabWidget_3->currentIndex() == 3) + { + QProcess df; + df.start("\""+sdk+"\"" + "adb shell df"); + df.waitForFinished(-1); + QString out = df.readAll(); + if (out.contains("/cache")) + this->ui->buttonCache-> setText("Unmount /cache"); + else + this->ui->buttonCache-> setText("Mount /cache"); + if (out.contains("/data")) + this->ui->buttonData-> setText("Unmount /data"); + else + this->ui->buttonData-> setText("Mount /data"); + if (this->phone->getConnectionState() == RECOVERY) + { + if (out.contains("/system")) + this->ui->buttonSystem-> setText("Unmount /system"); + else + this->ui->buttonSystem-> setText("Mount /system"); + } + if (this->phone->getConnectionState() == DEVICE) + { + df.start("\""+sdk+"\"" + "adb shell mount"); + df.waitForFinished(-1); + out = df.readAll(); + if (out.contains("/system type yaffs2 (ro")) + this->ui->buttonSystem-> setText("Remount /system Read/Write"); + else if (out.contains("/system type yaffs2 (rw")) + this->ui->buttonSystem-> setText("Remount /system Read-Only"); + } + if (out.contains("/sdext") || out.contains("/sd-ext")) + this->ui->buttonSdext-> setText("Unmount /sd-ext"); + else + this->ui->buttonSdext-> setText("Mount /sd-ext"); + if (out.contains("/sdcard")) + this->ui->buttonSdcard-> setText("Unmount /sdcard"); + else + this->ui->buttonSdcard-> setText("Mount /sdcard"); + } +} + +void CwmWidget::on_buttonCache_pressed() +{ + QString command = ""; + if (this->ui->buttonCache->text() == "Unmount /cache") + command = "umount"; + else if (this->ui->buttonCache->text() == "Mount /cache") + command = "mount"; + processFind->start("\""+sdk+"\"" + "adb shell " + command + " /cache"); + processFind->waitForFinished(-1); + mountsUpdate(); +} + +void CwmWidget::on_buttonData_pressed() +{ + QString command = ""; + if (this->ui->buttonData->text() == "Unmount /data") + command = "umount"; + else if (this->ui->buttonData->text() == "Mount /data") + command = "mount"; + processFind->start("\""+sdk+"\"" + "adb shell " + command + " /data"); + processFind->waitForFinished(-1); + mountsUpdate(); +} + +void CwmWidget::on_buttonSystem_pressed() +{ + QString command = ""; + if (this->ui->buttonSystem->text() == "Unmount /system") + command = "umount"; + else if (this->ui->buttonSystem->text() == "Mount /system") + command = "mount"; + else if (this->ui->buttonSystem->text() == "Remount /system Read/Write") + command = "mount -o remount,rw"; + else if (this->ui->buttonSystem->text() == "Remount /system Read-Only") + command = "mount -o remount,ro,noatime"; + processFind->start("\""+sdk+"\"" + "adb shell " + command + " /system"); + processFind->waitForFinished(-1); + mountsUpdate(); +} + +void CwmWidget::on_buttonSdext_pressed() +{ + QString command = ""; + if (this->ui->buttonSdext->text() == "Unmount /sd-ext") + command = "umount"; + else if (this->ui->buttonSdext->text() == "Mount /sd-ext") + command = "mount"; + processFind->start("\""+sdk+"\"" + "adb shell " + command + " /sd-ext"); + processFind->waitForFinished(-1); + mountsUpdate(); +} + +void CwmWidget::on_buttonSdcard_pressed() +{ + QString command = ""; + if (this->ui->buttonSdcard->text() == "Unmount /sdcard") + command = "umount"; + else if (this->ui->buttonSdcard->text() == "Mount /sdcard") + command = "mount"; + processFind->start("\""+sdk+"\"" + "adb shell " + command + " /sdcard"); + processFind->waitForFinished(-1); + mountsUpdate(); +} diff --git a/widgets/cwmwidget.h b/widgets/cwmwidget.h new file mode 100644 index 0000000..c5186b3 --- /dev/null +++ b/widgets/cwmwidget.h @@ -0,0 +1,159 @@ +/*********************************************************************** +*Copyright 2010-20XX by nijel +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +* +* @author nijel (nijel8@gmail.com) +* +************************************************************************/ + + +#ifndef CWMWIDGET_H +#define CWMWIDGET_H + +#include "../classes/phone.h" +#include "../classes/computer.h" +#include "../classes/models/filetablemodel.h" +#include "../classes/mytableview.h" +#include "settingswidget.h" +#include "../dialogs/fipdialog.h" +#include +#include +#include + + + +#include "../dialogs/dialogkopiuj.h" + + +namespace Ui { + class CwmWidget; +} + +class ThreadSdcard : public QThread +{ + Q_OBJECT +public: + void run(); + QString sdk, backupPath; + static void sleep(unsigned long secs){QThread::sleep(secs);} +signals: + void backupVerifiable(); +}; + +class CwmWidget : public QWidget +{ + Q_OBJECT + +public: + explicit CwmWidget(QWidget *parent = 0); + ~CwmWidget(); + static QString humanReadableSize(QString size); + Phone *phone; + Computer *computer; + SettingsWidget *settings; + FileTableModel *phoneModel; + FileSortModel *phoneSortModel; + MyTableView *sdcardTableView; + QTextCodec *codec; + +protected: + // void mousePressEvent(QMouseEvent *e); + +private: + Ui::CwmWidget *ui; + QString renameOldName; + bool sdcardChangeName; + bool NewDir; + QString sdk, which, commandRunning, readLog, backupPath, currentDir; + bool processShellIsRunning; + QMenu *phoneMenu; + QProcess *process; + QProcess *processFind; + QProcess *processWhich; + QProcess *proc; + ThreadSdcard *threadSdcard; + QList *getFileList(); + + + dialogKopiuj *dialog; + + +public slots: + void sdcardDisplay(); + +private slots: + void propsDialog(); + void sdcardDoubleClick(); + void sdcardLineEdit(); + void connectionChanged(); + void on_pushButtonDirectoryUp_pressed(); + void phoneRename(); + void phoneNewDir(); + void phoneDelete(); + void phoneHiddenFiles(); + void phoneRenameSlot(QModelIndex indexS, QModelIndex indexE); + void phoneDisplay(QTableView*); + void phoneContextMenu(const QPoint&); + void on_buttonFixPermissions_pressed(); + void printProcess(QString processOut); + void processFinished(); + void buttonsEnabled(); + void buttonsDisabled(); + QString adbPushTool(QString toolName); + void on_buttonCreate_pressed(); + void extendedcommandFile(QString infoLine, QString commandLine); + void tailLog(); + void readFromLog(); + void readFromProcess(); + void processStarted(); + void on_buttonSdinfo_pressed(); + void on_buttonWipe_pressed(); + void on_buttonInstall_pressed(); + void on_buttonInsert_pressed(); + void activateButtonInsert(); + void on_buttonBackup_pressed(); + void md5sumVerify(); + void on_buttonRestore_pressed(); + void backupAvailable(); + void on_buttonUpdate_pressed(); + void checkFlash(); + void on_buttonFlash_pressed(); + void finishedWhich(); + void readFromProcessWhich(); + void createPartition(); + void on_buttonFixMarket_pressed(); + void on_buttonRecovery_pressed(); + void sdrestoreCanceled(); + void sdbackupCanceled(); + void connectSignals(); + void disconnectSignals(); + void setTabCreate(int i); + void setTabFix(int i); + void mountsEnable(); + void mountsDisable(); + void mountsUpdate(); + void on_buttonCache_pressed(); + void on_buttonData_pressed(); + void on_buttonSystem_pressed(); + void on_buttonSdext_pressed(); + void on_buttonSdcard_pressed(); + +signals: + void phoneConnectionChanged(int); + void progressValue(int value, int max); + void copyFinished(int); + void copyCanceled(); +}; + +#endif // CWMWIDGET_H diff --git a/widgets/cwmwidget.ui b/widgets/cwmwidget.ui new file mode 100644 index 0000000..a560312 --- /dev/null +++ b/widgets/cwmwidget.ui @@ -0,0 +1,1791 @@ + + + CwmWidget + + + + 0 + 0 + 906 + 983 + + + + + 0 + 0 + + + + Form + + + 1.000000000000000 + + + + + 0 + 0 + 563 + 824 + + + + + 10 + + + 10 + + + 0 + + + 9 + + + + + QLayout::SetFixedSize + + + + + + 0 + 0 + + + + + 550 + 19 + + + + + 550 + 19 + + + + + + + + + 239 + 0 + 0 + + + + + + + + + 239 + 0 + 0 + + + + + + + + + 120 + 120 + 120 + + + + + + + + + 12 + 75 + true + false + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:14pt; font-weight:600; color:#ff0000;"> ADVANCED MENU: </span></p></body></html> + + + Qt::AlignCenter + + + Qt::NoTextInteraction + + + + + + + Qt::Vertical + + + QSizePolicy::Fixed + + + + 550 + 5 + + + + + + + + + + + 0 + 0 + + + + + 550 + 106 + + + + + 550 + 107 + + + + QTabWidget::pane { +background-color: rgba(255, 255, 255, 0); +border:2px solid #020202; +border-radius: 1px; +} + + + 0 + + + + Fix Permissions + + + + + + 48 + + + 0 + + + 5 + + + 0 + + + + + + 0 + 0 + + + + + 369 + 0 + + + + Reads through packages.xml file and performs chown/chmod command (changing owner/read-write-execute permissions) on each .apk and its data directory. Execute this if you get multiple FC (Force Close) messages after trying to run apps. + + + true + + + + + + + + 0 + 0 + + + + + 80 + 23 + + + + + 80 + 23 + + + + Fix Permissions + + + + + + + + + + Fix Market Cache + + + + + + 48 + + + 0 + + + 5 + + + 0 + + + + + + 0 + 0 + + + + + 369 + 0 + + + + <html><head/><body><p>Fixes the &quot;insufficient space&quot; issue in downloading applications from Google Market by moving Market Download Cache to SD Card.</p></body></html> + + + true + + + + + + + + 0 + 0 + + + + + 90 + 23 + + + + + 90 + 23 + + + + Fix Market + + + + + + + + + + Flash New Recovery + + + + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8pt; font-weight:400; font-style:normal;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"> Select Recovery image from /sdcard below and press [Flash] button.</p></body></html> + + + true + + + + + + + + + true + + + choose Recovery image from /sdcard below... + + + + + + + false + + + Flash + + + + + + + + + + + + Mount/Unmount + + + + + + 6 + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:8pt;">Mount/Unmount partitions in Recovery or Remount /system in Android with Read-Write/Read-Only access.</span></p></body></html> + + + + + + + + + Mount /cache + + + + + + + Mount /data + + + + + + + Mount /system + + + + + + + Mount /sd-ext + + + + + + + Mount /sdcard + + + + + + + + + + + + + + + 6 + + + QLayout::SetDefaultConstraint + + + 0 + + + + + Qt::Vertical + + + QSizePolicy::Fixed + + + + 550 + 5 + + + + + + + + + + true + + + + 0 + 0 + + + + + 550 + 211 + + + + + 550 + 211 + + + + + + + + + 212 + 212 + 212 + + + + + + + 216 + 216 + 216 + + + + + + + + + 255 + 255 + 255 + + + + + + + 216 + 216 + 216 + + + + + + + + + 255 + 255 + 255 + + + + + + + 240 + 240 + 240 + + + + + + + + false + + + QTabWidget::pane { +background-color: rgba(255, 255, 255, 0); +border:2px solid #020202; +border-radius: 1px; +} + + + QTabWidget::North + + + QTabWidget::Rounded + + + 0 + + + + Partition SD Card + + + + + 10 + 70 + 171 + 101 + + + + sd-ext Size: + + + + + 10 + 10 + 161 + 88 + + + + + + + 128 MB + + + + + + + 1024 MB + + + + + + + 512 MB + + + true + + + false + + + + + + + 4096 MB + + + + + + + 2048 MB + + + + + + + 256 MB + + + + + + + + + + 240 + 70 + 71 + 101 + + + + sd-ext Type: + + + + + 10 + 10 + 51 + 91 + + + + + + + ext2 + + + + + + + ext3 + + + true + + + + + + + ext4 + + + + + + + + + + 323 + 80 + 16 + 16 + + + + + + + + + + 340 + 80 + 191 + 39 + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:8pt;">Backup SD Card content to PC. You will be given an option to Restore it back to the newly created fat32 partition.</span></p></body></html> + + + true + + + + + + 340 + 140 + 181 + 25 + + + + + + + SD Card Info + + + + + + + Qt::Horizontal + + + QSizePolicy::Expanding + + + + 25 + 20 + + + + + + + + false + + + Create + + + + + + + + + 11 + 11 + 529 + 37 + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:8pt;">Create second /sd-ext partition on your SD Card for use with apps like Link2SD, apps2sd etc. Select </span><span style=" font-size:8pt;">/sd-ext</span><span style=" font-size:8pt;"> size and type, and press [Create]. Your phone will reboot in Recovery and fat32 and /sd-ext partitions will be created.</span></p></body></html> + + + true + + + + + + 11 + 50 + 371 + 16 + + + + + + + + + 235 + 0 + 0 + + + + + + + + + 235 + 0 + 0 + + + + + + + + + 120 + 120 + 120 + + + + + + + + + 10 + 75 + true + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:10pt; font-weight:600; color:#ff0000;">COUTION!!! All your data on SD Card will be destroyed!!!</span></p></body></html> + + + false + + + + + + Wipe + + + + false + + + + 400 + 100 + 75 + 23 + + + + Wipe + + + + + + 10 + 70 + 411 + 91 + + + + + + + wipe dada/factory reset + + + + + + + wipe dalvik-cache + + + + + + + wipe cache + + + + + + + wipe battery stats + + + + + + + + + 10 + 30 + 521 + 16 + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:8pt;">Select items to Wipe nad press [Wipe]. Your phone will reboot in Recovery and selected items will be wiped.</span></p></body></html> + + + + + + Install + + + + + 10 + 10 + 531 + 131 + + + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:8pt;">Select zip from /sdcard below and press [Install]. Your phone will reboot in Recovery and the selected zip will be installed.</span></p></body></html> + + + true + + + + + + + + + + + apply /sdcard/update.zip + + + + + + + + + + + + + + + + + + + true + + + choose zip from /sdcard below... + + + + + + + + + + + false + + + Install + + + + + + + + + + + Backup ROM + + + + + 10 + 0 + 531 + 141 + + + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:8pt;">Select Backup folder on /sdcard below and press [Backup]. All partitions will be backed up in Recovery. After Backup is finished and phone fully reboots back to normal you will be given a choice to verify the Backup's MD5 Sum.</span></p></body></html> + + + true + + + + + + + + + Use Default CWM Recovery Backup Location + + + + + + + + + + + + true + + + create or choose directory on /sdcard below... + + + + + + + false + + + Backup + + + + + + + + + + + + + Restore Backup + + + + + 9 + 87 + 531 + 61 + + + + + + + + + false + + + /boot + + + + + + + false + + + /system + + + + + + + false + + + /data + + + + + + + false + + + /cache + + + + + + + false + + + /sd-ext + + + + + + + + + + + + + + true + + + choose backup location on /sdcard below.. + + + + + + + false + + + Restore + + + + + + + + + + + 9 + 9 + 531 + 71 + + + + true + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:8pt;">Select folder with valid Nandroid Backup and verify backup's MD5 Sum if you wish. Then select images to restore(select all for full restore) and press [Restore]. </span></p></body></html> + + + true + + + + + + Update ROM + + + + + 10 + 10 + 531 + 131 + + + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:8pt;">This procedure reboots phone to Recovery, wipes cache and dalvik-cache, updates current ROM, and reboots. It is strongly recommended to Backup your current ROM first!!! Select the new ROM file from /sdcard below and press [Update].</span></p></body></html> + + + true + + + + + + + + + true + + + choose updated ROM from /sdcard below... + + + + + + + false + + + Update + + + + + + + + + + false + + + + 10 + 140 + 351 + 16 + + + + Copy Link2SD mount script to /system/etc/init.d/ after the Update. + + + + + + Flash ROM + + + + + 12 + 12 + 521 + 151 + + + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:8pt;">This procedure reboots phone to Recovery, wipes dalvik-cache, formats /boot, /system, /data and /cache partitions, installs zip before(if selected), installs the new ROM, installs zip after(if selected) and reboots. It is strongly recommended to Backup your current ROM first!!! Select all files from /sdcard below and press [Flash].</span></p></body></html> + + + true + + + + + + + + + + + false + + + + 0 + 0 + + + + Install Zip bedore flashing ROM: + + + + + + + false + + + (like some wiper...) + + + + + + + + + + + true + + + choose new ROM from /sdcard below... + + + + + + + false + + + Flash + + + + + + + + + + + false + + + + 0 + 0 + + + + Install Zip after flashing ROM: + + + + + + + false + + + (like Google Apps, Theme...) + + + + + + + + + + + + + + + + + 0 + 0 + + + + + 550 + 425 + + + + + 550 + 16777215 + + + + QTabWidget::pane { +background-color: rgba(255, 255, 255,0); +border:2px solid #020202; +border-radius: 1px; +padding: 1px; +} + + + 0 + + + + + :/icons/files.png:/icons/files.png + + + /sdcard + + + + + + 6 + + + QLayout::SetDefaultConstraint + + + 0 + + + 0 + + + + + + 0 + 0 + + + + + 30 + 25 + + + + + 30 + 25 + + + + + + + + + + + + 0 + 0 + + + + + 16777215 + 25 + + + + /sdcard + + + + + + + false + + + + 0 + 0 + + + + + 94 + 25 + + + + + 41 + 25 + + + + Confirm Selection + + + + + + + + + 6 + + + QLayout::SetDefaultConstraint + + + 0 + + + 0 + + + 0 + + + + + + + + + :/icons/shell.png:/icons/shell.png + + + Status + + + + + + + 0 + 0 + + + + + 0 + 0 + + + + + 16777215 + 16777215 + + + + + + + + + 144 + 238 + 144 + + + + + + + 0 + 0 + 0 + + + + + + + 144 + 238 + 144 + + + + + + + 144 + 238 + 144 + + + + + + + 0 + 0 + 0 + + + + + + + 0 + 0 + 0 + + + + + + + + + 144 + 238 + 144 + + + + + + + 0 + 0 + 0 + + + + + + + 144 + 238 + 144 + + + + + + + 144 + 238 + 144 + + + + + + + 0 + 0 + 0 + + + + + + + 0 + 0 + 0 + + + + + + + + + 144 + 238 + 144 + + + + + + + 0 + 0 + 0 + + + + + + + 144 + 238 + 144 + + + + + + + 144 + 238 + 144 + + + + + + + 0 + 0 + 0 + + + + + + + 0 + 0 + 0 + + + + + + + + + 10 + 75 + false + true + false + + + + IBeamCursor + + + QPlainTextEdit { +background-color:black; +color:lightgreen; +border: 1px solid #020202; +border-radius: 1px; +} + + + Ready + + + 0 + + + Qt::TextSelectableByKeyboard|Qt::TextSelectableByMouse + + + + + + + + + + + + + + + diff --git a/widgets/filewidget.cpp b/widgets/filewidget.cpp index 01717b5..83ceed7 100644 --- a/widgets/filewidget.cpp +++ b/widgets/filewidget.cpp @@ -322,6 +322,8 @@ FileWidget::FileWidget(QWidget *parent, SettingsWidget *settings) : connect(this->phoneModel, SIGNAL(copy(QStringList)), this, SLOT(copySlotToPhone(QStringList)), Qt::QueuedConnection); connect(this->phoneLeftModel, SIGNAL(copy(QStringList)), this, SLOT(copySlotToPhoneLeft(QStringList)), Qt::QueuedConnection); + pulled = new QFileSystemWatcher; + this->leftMode="computer"; this->leftDisplay(); this->settings->changeFont(); @@ -329,8 +331,10 @@ FileWidget::FileWidget(QWidget *parent, SettingsWidget *settings) : FileWidget::~FileWidget() { + this->computer->deleteDir(QDir::currentPath()+"/tmp/phone"); this->settings->phonePath = this->phone->getPath(); - this->settings->computerPath = this->computer->getPath(); + if (this->leftMode=="computer") + this->settings->computerPath = this->computer->getPath(); delete this->phone; delete this->phoneLeft; @@ -478,8 +482,8 @@ void FileWidget::resizeEvent(QResizeEvent *e) void FileWidget::mousePressEvent(QMouseEvent *event) { - if (event->button() == Qt::RightButton) - emit customContextMenuRequested(event->pos()); + if (event->button() == Qt::RightButton) + emit customContextMenuRequested(event->pos()); } void FileWidget::connectionChanged() @@ -583,14 +587,14 @@ void FileWidget::computerCopy() { if (this->leftTableView->selectionModel()->selection().isEmpty()) { - QMessageBox::information(this,"",tr("select some files first"),QMessageBox::Ok); + QMessageBox::information(this,"",tr("Select some items first!"),QMessageBox::Ok); return; } QSettings settings; if (settings.value("showCopyConfirmation", true).toBool()) { - if (QMessageBox::question(this,tr("copying"),tr("are you sure???"),QMessageBox::Ok | QMessageBox::No) == QMessageBox::No) + if (QMessageBox::question(this,tr("Copying:"),tr("Are you sure???"),QMessageBox::Ok | QMessageBox::No) == QMessageBox::No) return; } @@ -605,7 +609,7 @@ void FileWidget::computerCopy() filesToCopy = this->computerFilesToCopy(filesToCopy); if (filesToCopy->isEmpty()) { - QMessageBox::information(this,"",tr("theres nothing to copy. Maybe selected dirs are empty"),QMessageBox::Ok); + QMessageBox::information(this,"",tr("There's nothing to copy. Maybe selected directories are empty?!"),QMessageBox::Ok); return; } @@ -629,11 +633,11 @@ void FileWidget::computerDelete() { if (this->leftTableView->selectionModel()->selection().isEmpty()) { - QMessageBox::information(this,"",tr("select some files first"),QMessageBox::Ok); + QMessageBox::information(this,"",tr("Select some items first!"),QMessageBox::Ok); return; } - if (QMessageBox::question(this, tr("deleting"), tr("are you sure???"), + if (QMessageBox::question(this, tr("Deleting:"), tr("Are you sure???"), QMessageBox::Ok | QMessageBox::No) == QMessageBox::No) return; @@ -650,6 +654,7 @@ void FileWidget::computerDelete() void FileWidget::computerDisplay(QTableWidget *tableWidget) { QSettings settings; + QString packageName; this->computerModel->clear(); this->ui->leftLabelSelectedCount->setText(tr("getting files...")); this->leftTableView->setDisabled(true); @@ -662,28 +667,68 @@ void FileWidget::computerDisplay(QTableWidget *tableWidget) { // qApp->processEvents(); tmpFile = fileList->takeFirst(); + qDebug()<<"tmpFile.fileName =" <settings->showAppName || this->settings->showAppIcon) { - app = this->getAppInfo(tmpFile.filePath); - if (this->settings->showAppIcon) + packageName = settings.value(("apps/" + tmpFile.fileName), "").toString(); + settings.beginGroup("apps"); + QStringList settingsList=settings.childKeys(); + settings.endGroup(); + qDebug()<<"settingsList=settings.childKeys =" <", app->appName); - QString tmp=app->appVersion; - if (tmp.length()>15) - tmp=tmp.left(15)+"..."; - - appName.replace("", tmp); - appName.replace("", app->packageName); - if (this->settings->showAppName) - tmpFile.fileName = appName; - delete app; - app = NULL; - } + QString appName = this->settings->showAppNameConfig; + appName.replace("", app->appName); + QString tmp=app->appVersion; + if (tmp.length()>15) + tmp=tmp.left(15)+"..."; + + appName.replace("", tmp); + appName.replace("", app->packageName); + if (this->settings->showAppName) + tmpFile.fileName = appName; + delete app; + app = NULL; + } + else + { + + QString appNameset = settings.value("apps/" + packageName + "/appName").toString(); + QString appVersion = settings.value("apps/" + packageName + "/version").toString(); + if (this->settings->showAppIcon) + { + QByteArray ba; + QPixmap pix; + ba = settings.value("apps/" + packageName + "/icon").toByteArray(); + pix.loadFromData(ba); + QIcon icon(pix); + tmpFile.fileIcon = icon; + } + QString appName = this->settings->showAppNameConfig; + appName.replace("", appNameset); + QString tmp=appVersion; + if (tmp.length()>15) + tmp=tmp.left(15)+"..."; + + appName.replace("", tmp); + appName.replace("", packageName); + if (this->settings->showAppName) + tmpFile.fileName = appName; + delete app; + app = NULL; + } + + } } this->computerModel->insertFile(0, tmpFile); + // } } delete fileList; this->leftTableView->resizeColumnsToContents(); @@ -747,8 +792,8 @@ void FileWidget::computerNewDir() { if (!computer->makeDir("new dir")) { - QMessageBox::information(this,tr("error"), - tr("dir was not created.\nMake sure that you are allowed to do this"), + QMessageBox::information(this,tr("Error:"), + tr("Directory was not created.\nMake sure that you are allowed to do this"), QMessageBox::Ok); return; } @@ -857,6 +902,7 @@ void FileWidget::leftContextMenu(const QPoint &pos) void FileWidget::leftDisplay() { + // this->leftTableView->verticalScrollBar()->adjustSize(); if (this->leftMode=="computer") { ui->leftFileNameFilter->clear(); @@ -886,6 +932,8 @@ void FileWidget::leftDisplay() this->leftTableView->resizeColumnsToContents(); colSize = this->leftTableView->columnWidth(2); colDate = this->leftTableView->columnWidth(3); + if (this->leftTableView->verticalScrollBar()->width() > 17) + this->leftTableView->verticalScrollBar()->adjustSize(); if (this->leftTableView->verticalScrollBar() == NULL) colName = widthTab - colIcon - colSize - colDate; else @@ -895,7 +943,7 @@ void FileWidget::leftDisplay() this->leftTableView->setColumnWidth(0, colIcon); this->leftTableView->setColumnWidth(1, colName - 2); this->leftTableView->setColumnWidth(2, colSize); - this->leftTableView->setColumnWidth(3, colDate); + this->leftTableView->setColumnWidth(3, colDate + this->leftTableView->verticalScrollBar()->width()); } void FileWidget::leftDoubleClick() @@ -933,12 +981,35 @@ void FileWidget::leftDoubleClick() { QModelIndex index = this->leftTableView->selectionModel()->selection().indexes().takeFirst(); index = this->phoneLeftSortModel->mapToSource(index); - QString fileName = this->phoneLeftModel->getFile(index.row()).fileName; + QString fileType; + fileName = this->phoneLeftModel->getFile(index.row()).fileName; + filePath = this->phoneLeftModel->getFile(index.row()).filePath; + fileType = this->phoneLeftModel->getFile(index.row()).fileType; if (this->phoneLeft->cd(fileName)) { this->leftDisplay(); } + else if (fileType == "file") + { + pulled->removePath(QDir::currentPath()+"/tmp/phone/" + fileName); + removeFile(); + msg = new QMessageBox(this); + msg->setText("Loading file... Please, wait..."); + msg->setIcon(QMessageBox::Information); + msg->setWindowTitle("Open file:"); + msg->setStandardButtons(QMessageBox::Ok); + edit = new QProcess; + connect(edit, SIGNAL(started()), msg, SLOT(exec())); + connect(edit, SIGNAL(finished(int)), msg, SLOT(accept())); + edit->start("\""+sdk+"\""+"adb pull \""+filePath+"\" \""+QDir::currentPath()+"/tmp/phone/" + fileName+ "\""); + edit->waitForFinished(-1); + disconnect(edit, SIGNAL(started()), msg, SLOT(exec())); + disconnect(edit, SIGNAL(finished(int)), msg, SLOT(accept())); + QDesktopServices::openUrl(QUrl("file:///" + QDir::currentPath()+"/tmp/phone/" + fileName, QUrl::TolerantMode)); + pulled->addPath(QDir::currentPath()+"/tmp/phone/" + fileName); + connect(pulled, SIGNAL(fileChanged(QString)), this, SLOT(saveFile())); + } } } } @@ -962,7 +1033,7 @@ void FileWidget::leftSelectedCount() { QModelIndexList indexList = this->leftTableView->selectionModel()->selectedRows(1); QString word(QString::number(indexList.size()) + "/" + - QString::number(this->computerModel->rowCount())+ " " + tr("selected", "selected label below table")); + QString::number(this->computerModel->rowCount())+ " " + tr("selected (double click file to open it)", "selected label below table")); this->ui->leftLabelSelectedCount->setText(word); } @@ -1022,18 +1093,74 @@ void FileWidget::on_leftPushButtonPhoneComputerSwitch_pressed() { if ((this->phoneLeft->getConnectionState() == RECOVERY) || (this->phoneLeft->getConnectionState() == DEVICE)) { + QString oldPath; if (this->leftMode=="computer") { + oldPath = this->computer->getPath(); + QStringList phonePaths; + phonePaths << "/sdcard/" << "/data/" << "/data/app/" << "/sd-ext/" << "/system/" << "/system/app/"; + ui->leftComboBox->clear(); + ui->leftComboBox->addItems(phonePaths); + this->leftMode="phone"; ui->leftPushButtonPhoneComputerSwitch->setIcon(QIcon(":/icons/computer.png")); this->leftTableView->setModel(this->phoneLeftSortModel); - this->leftDisplay(); + // this->leftDisplay(); + + + disconnect(ui->leftComboBox->lineEdit(),SIGNAL(returnPressed()),this,SLOT(leftComboBox())); + disconnect(ui->leftComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(leftComboBoxScroll())); + connect(ui->leftComboBox->lineEdit(),SIGNAL(returnPressed()),this,SLOT(leftComboBoxPhone())); + connect(ui->leftComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(leftComboBoxPhone())); } else { + oldPath = this->phoneLeft->getPath(); + ui->leftComboBox->clear(); + QPair para; + QFileIconProvider *provider = new QFileIconProvider; + para.second = QDesktopServices::storageLocation(QDesktopServices::DesktopLocation); + para.first = provider->icon(QFileInfo(para.second)); + this->ui->leftComboBox->addItem(para.first, para.second); + + para.second = QDesktopServices::storageLocation(QDesktopServices::DocumentsLocation); + para.first = provider->icon(QFileInfo(para.second)); + this->ui->leftComboBox->addItem(para.first, para.second); + + para.second = QDesktopServices::storageLocation(QDesktopServices::HomeLocation); + para.first = provider->icon(QFileInfo(para.second)); + this->ui->leftComboBox->addItem(para.first, para.second); + + QFileInfoList lista = QDir::drives(); + while(!lista.isEmpty()) + { + para.second = lista.takeFirst().filePath(); + para.first = provider->icon(QFileInfo(para.second)); + this->ui->leftComboBox->addItem(para.first, para.second); + } + delete provider; + + this->leftMode="computer"; ui->leftPushButtonPhoneComputerSwitch->setIcon(QIcon(":/icons/phone.png")); this->leftTableView->setModel(this->computerSortModel); + + + disconnect(ui->leftComboBox->lineEdit(),SIGNAL(returnPressed()),this,SLOT(leftComboBoxPhone())); + disconnect(ui->leftComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(leftComboBoxPhone())); + connect(ui->leftComboBox->lineEdit(),SIGNAL(returnPressed()),this,SLOT(leftComboBox())); + connect(ui->leftComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(leftComboBoxScroll())); + } + if (this->leftMode=="computer") + { + this->ui->leftComboBox->setEditText(oldPath); + this->phoneLeft->cd(oldPath); + leftComboBoxPhone(); + } + else + { + this->ui->leftComboBox->setEditText(oldPath); + this->computer->cd(oldPath); this->leftDisplay(); } } @@ -1142,7 +1269,8 @@ void FileWidget::phoneContextMenu(const QPoint &pos,QTableView *tableView) this->phoneLeftMenu->setLayoutDirection(Qt::LeftToRight); if (layoutDirection == 1) this->phoneLeftMenu->setLayoutDirection(Qt::RightToLeft); - QAction *usun,*selectAll,*selectNone,*odswiez,*nowyFolder,*zmienNazwe,*ukryte, *copy/*, *install*/; + QAction *usun,*selectAll,*selectNone,*odswiez,*nowyFolder,*zmienNazwe,*ukryte, *copy, *props, *sep; + zmienNazwe = this->phoneLeftMenu->addAction(QIcon(":icons/rename.png"),tr("rename", "phone right click menu"),this,SLOT(phoneRename())); zmienNazwe->setData(QString("rename")); selectAll = this->phoneLeftMenu->addAction(QIcon(":icons/selectAll.png"),tr("select all", "phone right click menu"),this,SLOT(leftSelectAll())); @@ -1159,6 +1287,9 @@ void FileWidget::phoneContextMenu(const QPoint &pos,QTableView *tableView) usun->setData(QString("delete")); ukryte = this->phoneLeftMenu->addAction(QIcon(":icons/hidden.png"),tr("hidden files", "phone right click menu"),this,SLOT(phoneHiddenFiles())); ukryte->setData(QString("hidden files")); + sep = this->phoneLeftMenu->addSeparator(); + props = this->phoneLeftMenu->addAction(QIcon(":icons/info.png"),tr("Properties", "phone right click menu"),this,SLOT(propsDialog())); + props->setData(QString("properties")); // install = menu->addAction(QIcon(":icons/install.png"),tr("install"),this,SLOT(installAppFromPhone())); } @@ -1173,7 +1304,7 @@ void FileWidget::phoneContextMenu(const QPoint &pos,QTableView *tableView) this->phoneRightMenu->setLayoutDirection(Qt::LeftToRight); if (layoutDirection == 1) this->phoneRightMenu->setLayoutDirection(Qt::RightToLeft); - QAction *usun,*selectAll,*selectNone,*odswiez,*nowyFolder,*zmienNazwe,*ukryte, *copy, *openInNewTab/*, *install*/; + QAction *usun,*selectAll,*selectNone,*odswiez,*nowyFolder,*zmienNazwe,*ukryte, *copy, *openInNewTab, *props, *sep; zmienNazwe = this->phoneRightMenu->addAction(QIcon(":icons/rename.png"),tr("rename", "phone right click menu"),this,SLOT(phoneRename())); zmienNazwe->setData(QString("rename")); @@ -1193,6 +1324,9 @@ void FileWidget::phoneContextMenu(const QPoint &pos,QTableView *tableView) ukryte->setData(QString("hidden files")); openInNewTab = this->phoneRightMenu->addAction(QApplication::style()->standardIcon(QStyle::SP_DirIcon),tr("open in new tab", "phone right click menu"),this,SLOT(phoneOpenInNewTab())); openInNewTab->setData(QString("open in new tab")); + sep = this->phoneRightMenu->addSeparator(); + props = this->phoneRightMenu->addAction(QIcon(":icons/info.png"),tr("Properties", "phone right click menu"),this,SLOT(propsDialog())); + props->setData(QString("properties")); } if (rightTableView->model() == this->findModel) { @@ -1205,6 +1339,8 @@ void FileWidget::phoneContextMenu(const QPoint &pos,QTableView *tableView) this->phoneRightMenu->actions().at(3)->setVisible(false);//copy this->phoneRightMenu->actions().at(6)->setVisible(false);//delete + this->phoneRightMenu->actions().at(9)->setVisible(false); + this->phoneRightMenu->actions().at(10)->setVisible(false); } else if (rightTableView->model() == this->phoneSortModel) @@ -1218,6 +1354,8 @@ void FileWidget::phoneContextMenu(const QPoint &pos,QTableView *tableView) this->phoneRightMenu->actions().at(3)->setVisible(true);//copy this->phoneRightMenu->actions().at(6)->setVisible(true);//delete + this->phoneRightMenu->actions().at(9)->setVisible(true); + this->phoneRightMenu->actions().at(10)->setVisible(true); } QPoint pos2; @@ -1255,13 +1393,13 @@ void FileWidget::phoneCopy() if (tableView->selectionModel()->selection().isEmpty()) { - QMessageBox::information(this,"",tr("select some files first"),QMessageBox::Ok); + QMessageBox::information(this,"",tr("Select some items first!"),QMessageBox::Ok); return; } QSettings settings; if (settings.value("showCopyConfirmation", true).toBool()) { - if (QMessageBox::question(this,tr("copying"),tr("are you sure???"),QMessageBox::Ok | QMessageBox::No) == QMessageBox::No) + if (QMessageBox::question(this,tr("Copying:"),tr("Are you sure???"),QMessageBox::Ok | QMessageBox::No) == QMessageBox::No) return; } @@ -1276,7 +1414,7 @@ void FileWidget::phoneCopy() filesToCopy = this->phoneFilesToCopy(filesToCopy, phoneTmp); if (filesToCopy->isEmpty()) { - QMessageBox::information(this,"",tr("theres nothing to copy. Maybe selected dirs are empty"),QMessageBox::Ok); + QMessageBox::information(this,"Copying:",tr("There's nothing to copy. Maybe selected directories are empty?!"),QMessageBox::Ok); return; } @@ -1325,11 +1463,11 @@ void FileWidget::phoneDelete() if (tableView->selectionModel()->selection().isEmpty()) { - QMessageBox::information(this,"",tr("select some files first"),QMessageBox::Ok); + QMessageBox::information(this,"",tr("Select some items first!"),QMessageBox::Ok); return; } - if (QMessageBox::question(this, tr("deleting"), tr("are you sure???"), + if (QMessageBox::question(this, tr("Deleting:"), tr("Are you sure???"), QMessageBox::Ok | QMessageBox::No) == QMessageBox::No) return; @@ -1495,7 +1633,7 @@ void FileWidget::phoneNewDir() if (!phoneTmp->makeDir("new dir")) { - QMessageBox::information(this,tr("error"),tr("dir was not created.\nMake sure that you are allowed to do this"),QMessageBox::Ok); + QMessageBox::information(this,tr("Error:"),tr("Directory was not created.\nMake sure directory doesn't exist and that you are allowed to do this!"),QMessageBox::Ok); return; } if (rightTableView->hasFocus()) @@ -1642,8 +1780,27 @@ void FileWidget::rightContextMenu(const QPoint &pos) void FileWidget::rightComboBox() { - if (phone->cd(ui->rightComboBox->lineEdit()->text())) + QString cboxdir = ui->rightComboBox->lineEdit()->text(); + if (cboxdir == "/sd-ext/") + { + QSettings settings; + cboxdir = settings.value("sdFolder").toString(); + if (cboxdir == "empty" || cboxdir.isEmpty()) + { + QMessageBox::information(this,"sd-ext:","Detect /sd-ext/ partition in Settings!"); + } + if (cboxdir == "") + { + QMessageBox::critical(this,"sd-ext:","Cannot detect /sd-ext/ partition!\nEnter path in Settings manualy."); + ui->rightComboBox->lineEdit()->setText(""); + } + } + qDebug()<<"phonePath ="<cd(cboxdir)) + { + this->phone->setPath(cboxdir); this->rightDisplay(); + } // QString path=this->phone->getPath(); // this->phone->setPath(ui->rightComboBox->lineEdit()->text().toUtf8()); // if (this->phone->cd(".")) @@ -1669,6 +1826,8 @@ void FileWidget::rightDisplay() this->rightTableView->resizeColumnsToContents(); colSize = this->rightTableView->columnWidth(2); colDate = this->rightTableView->columnWidth(3); + if (this->rightTableView->verticalScrollBar()->width() > 17) + this->rightTableView->verticalScrollBar()->adjustSize(); if (this->rightTableView->verticalScrollBar() == NULL) colName = widthTab - colIcon - colSize - colDate; else @@ -1678,7 +1837,7 @@ void FileWidget::rightDisplay() this->rightTableView->setColumnWidth(0, colIcon); this->rightTableView->setColumnWidth(1, colName - 2); this->rightTableView->setColumnWidth(2, colSize); - this->rightTableView->setColumnWidth(3, colDate); + this->rightTableView->setColumnWidth(3, colDate + this->rightTableView->verticalScrollBar()->width()); if (this->rightTabBar->count()>0) { @@ -1693,21 +1852,27 @@ void FileWidget::rightDoubleClick() if (!this->rightTableView->selectionModel()->selection().isEmpty()) { QModelIndex index; - QString fileName; + QString fileType; + File file; if (rightTableView->model()==this->findModel) { - File file; index = this->rightTableView->selectionModel()->selection().indexes().takeFirst(); file = this->findModel->getFile(index.row()); fileName=file.fileName; if (file.fileType == "file") + { fileName = fileName.left(fileName.lastIndexOf("/")); + filePath = this->phoneModel->getFile(index.row()).filePath; + fileType = this->phoneModel->getFile(index.row()).fileType; + } } else { index = this->rightTableView->selectionModel()->selection().indexes().takeFirst(); index = this->phoneSortModel->mapToSource(index); fileName = this->phoneModel->getFile(index.row()).fileName; + filePath = this->phoneModel->getFile(index.row()).filePath; + fileType = this->phoneModel->getFile(index.row()).fileType; } if (fileName.contains(" -> ")) @@ -1718,6 +1883,26 @@ void FileWidget::rightDoubleClick() { this->rightDisplay(); } + else if (fileType == "file") + { + pulled->removePath(QDir::currentPath()+"/tmp/phone/" + fileName); + removeFile(); + msg = new QMessageBox(this); + msg->setText("Loading file... Please, wait..."); + msg->setIcon(QMessageBox::Information); + msg->setWindowTitle("Open file:"); + msg->setStandardButtons(QMessageBox::Ok); + edit = new QProcess; + connect(edit, SIGNAL(started()), msg, SLOT(exec())); + connect(edit, SIGNAL(finished(int)), msg, SLOT(accept())); + edit->start("\""+sdk+"\""+"adb pull \""+filePath+"\" \""+QDir::currentPath()+"/tmp/phone/" + fileName+ "\""); + edit->waitForFinished(-1); + disconnect(edit, SIGNAL(started()), msg, SLOT(exec())); + disconnect(edit, SIGNAL(finished(int)), msg, SLOT(accept())); + QDesktopServices::openUrl(QUrl("file:///" + QDir::currentPath()+"/tmp/phone/" + fileName, QUrl::TolerantMode)); + pulled->addPath(QDir::currentPath()+"/tmp/phone/" + fileName); + connect(pulled, SIGNAL(fileChanged(QString)), this, SLOT(saveFile())); + } } } @@ -1739,7 +1924,7 @@ void FileWidget::rightSelectedCount() { QModelIndexList indexList = this->rightTableView->selectionModel()->selectedRows(1); QString word(QString::number(indexList.size()) + "/" + - QString::number(this->rightTableView->model()->rowCount(QModelIndex()))+ " " + tr("selected")); + QString::number(this->rightTableView->model()->rowCount(QModelIndex()))+ " " + tr("selected (double click file to open it)")); this->ui->rightLabelSelectedCount->setText(word); } @@ -1796,7 +1981,7 @@ void FileWidget::showAppInfo() } else { - QMessageBox::information(this, tr("information"), tr("It's not an application"), QMessageBox::Ok); + QMessageBox::information(this, tr("Information:"), tr("It's not an application!"), QMessageBox::Ok); } } } @@ -1809,7 +1994,7 @@ void ThreadFind::run() QString output; QString path, file; QStringList strList; - proces->start("\""+this->sdk+"\"adb shell busybox find "+this->path+" -iname \'*"+this->fileName+"*\'"); + proces->start("\""+this->sdk+"\"adb shell find "+this->path+" -iname \'*"+this->fileName+"*\'"); Phone phone(this->sdk,false); phone.setConnectionState(DEVICE); @@ -1911,7 +2096,7 @@ void FileWidget::installAppFromComputer() if (this->leftTableView->selectionModel()->selection().isEmpty()) { - QMessageBox::information(this, "install", "there is no files to install", QMessageBox::Ok); + QMessageBox::information(this, "Install:", "There is no files to install!", QMessageBox::Ok); return; } @@ -1933,7 +2118,7 @@ void FileWidget::installAppFromComputer() // selected.package.append(this->app->appFile); - if (QMessageBox::question(this,tr("install"),tr("are you sure???"),QMessageBox::Ok | QMessageBox::No) == QMessageBox::No) + if (QMessageBox::question(this,tr("Install:"),tr("Are you sure???"),QMessageBox::Ok | QMessageBox::No) == QMessageBox::No) return; // int i=0; @@ -2008,9 +2193,14 @@ App * FileWidget::getAppInfo(QString filePath) } aaptLines.removeFirst(); } - - if (!settings.contains(app->packageName)) + qDebug()<<"filePath = "<appFile.lastIndexOf("/"); + qDebug()<<"x = "<appFile.right(app->appFile.length()- x-1); + qDebug()<<"apkFilename = "<packageName)); { + settings.setValue(apkFilename, app->packageName); settings.setValue(app->packageName+"/icoName", app->icoName); settings.setValue(app->packageName+"/appName", QString::fromUtf8(app->appName.toAscii())); settings.setValue(app->packageName+"/version", app->appVersion); @@ -2020,13 +2210,15 @@ App * FileWidget::getAppInfo(QString filePath) temp.append(".png"); if (!settings.contains(app->packageName+"/icon")) { - unpack(app->appFile, QDir::currentPath()+"/icons/", app->icoName, temp); + unpack(app->appFile, QDir::currentPath()+"/tmp/", app->icoName, temp); - QFile icon(QDir::currentPath()+"/icons/"+app->packageName.toLatin1()+".png"); + QFile icon(QDir::currentPath()+"/tmp/"+app->packageName.toLatin1()+".png"); icon.open(QIODevice::ReadWrite); ba = icon.readAll(); settings.setValue(app->packageName+"/icon", ba); //- zapisanie pixmap w QSettings icon.remove(); + QDir dir; + dir.rmdir (QDir::currentPath()+"/icons"); } ba = settings.value(app->packageName+"/icon").toByteArray(); pix.loadFromData(ba); @@ -2079,7 +2271,7 @@ void FileWidget::copySlotToComputer(QStringList list) QSettings settings; if (settings.value("showCopyConfirmation", true).toBool()) { - if (QMessageBox::question(this,tr("copying"),tr("are you sure???"),QMessageBox::Ok | QMessageBox::No) == QMessageBox::No) + if (QMessageBox::question(this,tr("Copying:"),tr("Are you sure???"),QMessageBox::Ok | QMessageBox::No) == QMessageBox::No) return; } @@ -2094,7 +2286,7 @@ void FileWidget::copySlotToComputer(QStringList list) filesToCopy = this->phoneFilesToCopy(filesToCopy, this->phone); if (filesToCopy->isEmpty()) { - QMessageBox::information(this,"",tr("theres nothing to copy. Maybe selected dirs are empty"),QMessageBox::Ok); + QMessageBox::information(this,"Copying:",tr("There's nothing to copy. Maybe selected directories are empty?!"),QMessageBox::Ok); return; } @@ -2127,7 +2319,7 @@ void FileWidget::copySlotToPhone(QStringList list) QSettings settings; if (settings.value("showCopyConfirmation", true).toBool()) { - if (QMessageBox::question(this,tr("copying"),tr("are you sure???"),QMessageBox::Ok | QMessageBox::No) == QMessageBox::No) + if (QMessageBox::question(this,tr("Copying:"),tr("Are you sure???"),QMessageBox::Ok | QMessageBox::No) == QMessageBox::No) return; } @@ -2146,7 +2338,7 @@ void FileWidget::copySlotToPhone(QStringList list) if (filesToCopy->isEmpty()) { - QMessageBox::information(this,"",tr("theres nothing to copy. Maybe selected dirs are empty"),QMessageBox::Ok); + QMessageBox::information(this,"Copying:",tr("There's nothing to copy. Maybe selected directories are empty?!"),QMessageBox::Ok); return; } @@ -2181,7 +2373,7 @@ void FileWidget::copySlotToPhoneLeft(QStringList list) QSettings settings; if (settings.value("showCopyConfirmation", true).toBool()) { - if (QMessageBox::question(this,tr("copying"),tr("are you sure???"),QMessageBox::Ok | QMessageBox::No) == QMessageBox::No) + if (QMessageBox::question(this,tr("Copying:"),tr("Are you sure???"),QMessageBox::Ok | QMessageBox::No) == QMessageBox::No) return; } @@ -2198,7 +2390,7 @@ void FileWidget::copySlotToPhoneLeft(QStringList list) if (filesToCopy->isEmpty()) { - QMessageBox::information(this,"",tr("theres nothing to copy. Maybe selected dirs are empty"),QMessageBox::Ok); + QMessageBox::information(this,"Copying:",tr("There's nothing to copy. Maybe selected directories are empty?!"),QMessageBox::Ok); return; } @@ -2220,3 +2412,125 @@ void FileWidget::copySlotToPhoneLeft(QStringList list) connect(this->dialog,SIGNAL(finished(int)),this,SLOT(leftRefresh())); connect(this->dialog,SIGNAL(finished(int)),this,SLOT(rightRefresh())); } + +void FileWidget::propsDialog() +{ + QTableView * tableView; + Phone * phoneTmp; + FileSortModel * sortModel; + FileTableModel * fileModel; + if (this->leftTableView->hasFocus()) + { + phoneTmp = this->phoneLeft; + tableView = this->leftTableView; + sortModel = this->phoneLeftSortModel; + fileModel = this->phoneLeftModel; + } + else + { + phoneTmp = this->phone; + tableView = this->rightTableView; + sortModel = this->phoneSortModel; + fileModel = this->phoneModel; + } + + QModelIndexList indexList = tableView->selectionModel()->selectedRows(1); + if (indexList.isEmpty()) + { + QMessageBox::information(this,"",tr("Select some item first!"),QMessageBox::Ok); + return; + } + if (indexList.size() == 1) + { + fipDialog *d = new fipDialog(this); + QModelIndex index = sortModel->mapToSource(indexList.takeFirst()); + File tmpFile = fileModel->getFile(index.row()); + QString file = tmpFile.filePath; + d->setData(file); + d->show(); + } + if (indexList.size() > 1) + { + QMessageBox::information(this,"",tr("Single item selection only!"),QMessageBox::Ok); + return; + } +} + +void FileWidget::leftComboBoxPhone() +{ + QString cboxdir = ui->leftComboBox->lineEdit()->text(); + if (cboxdir == "/sd-ext/") + { + QSettings settings; + cboxdir = settings.value("sdFolder").toString(); + if (cboxdir == "empty" || cboxdir.isEmpty()) + { + QMessageBox::information(this,"sd-ext:","Detect /sd-ext/ partition in Settings!"); + } + if (cboxdir == "") + { + QMessageBox::critical(this,"sd-ext:","Cannot detect /sd-ext/ partition!\nEnter path in Settings manualy."); + ui->leftComboBox->lineEdit()->setText(""); + } + } + qDebug()<<"phonePath ="<cd(cboxdir)) + { + this->phoneLeft->setPath(cboxdir); + this->leftDisplay(); + } +} + +void FileWidget::saveFile() +{ + disconnect(pulled, SIGNAL(fileChanged(QString)), this, SLOT(saveFile())); + pulled->removePath(QDir::currentPath()+"/tmp/phone/" + fileName); + if (QMessageBox::information(this,"Open file:","File was changed!\n\nSave changes to Phone?",QMessageBox::Save | QMessageBox::Discard) == QMessageBox::Save) + { + edit->start("\""+sdk+"\""+"adb shell stat \"" + filePath + "\""); + edit->waitForFinished(-1); + QString output = edit->readAll(); + int start = output.indexOf("Access:",Qt::CaseSensitive); + start+=7; + int end = output.indexOf("Uid:",start,Qt::CaseSensitive); + QString fPerm = output.mid(start, end-start); + fPerm = fPerm.trimmed(); //(0777/lrwxrwxrwx) + QStringList permList = fPerm.split("/"); + QString chmod = permList[0].right(3); + QString folder = filePath.left(filePath.lastIndexOf("/")); + if (folder.startsWith("/system")) + { + edit->start("\""+sdk+"\""+"adb shell mount -o remount,rw /system"); + edit->waitForFinished(-1); + } + msg->setText("Saving file to Phone... Please, wait..."); + connect(edit, SIGNAL(started()), msg, SLOT(exec())); + connect(edit, SIGNAL(finished(int)), msg, SLOT(accept())); + edit->start("\""+sdk+"\""+"adb push \""+QDir::currentPath()+"/tmp/phone/" + fileName + "\" \"" + folder + "\""); + edit->waitForFinished(-1); + disconnect(edit, SIGNAL(started()), msg, SLOT(exec())); + disconnect(edit, SIGNAL(finished(int)), msg, SLOT(accept())); + edit->start("\""+sdk+"\""+"adb shell chmod " + chmod.append(" \"") + filePath + "\""); + edit->waitForFinished(-1); + if (folder.startsWith("/system")) + { + edit->start("\""+sdk+"\""+"adb shell mount -o remount,ro,noatime /system"); + edit->waitForFinished(-1); + } + removeFile(); + rightDisplay(); + if (this->leftMode=="phone") + leftDisplay(); + } + else + { + removeFile(); + return; + } +} + +void FileWidget::removeFile() +{ + QDir dir; + dir.remove(QDir::currentPath()+"/tmp/phone/" + fileName); +} diff --git a/widgets/filewidget.h b/widgets/filewidget.h index d690b45..138be92 100644 --- a/widgets/filewidget.h +++ b/widgets/filewidget.h @@ -29,6 +29,7 @@ #include "../classes/models/filetablemodel.h" #include "../classes/mytableview.h" #include "settingswidget.h" +#include "../dialogs/fipdialog.h" #include namespace Ui { @@ -40,6 +41,7 @@ class ThreadFind : public QThread Q_OBJECT public: void run(); + static void sleep(unsigned long secs){QThread::sleep(secs);} QString path; QString fileName; QString sdk; @@ -72,6 +74,7 @@ class FileWidget : public QWidget MyTableView *rightTableView; MyTableView *leftTableView; + protected: void changeEvent(QEvent *e); virtual void keyPressEvent( QKeyEvent *e ); @@ -107,8 +110,10 @@ class FileWidget : public QWidget QMenu *computerMenu, *phoneLeftMenu, *phoneRightMenu; - - QString oldComputerPath; + QFileSystemWatcher *pulled; + QProcess *edit; + QString oldComputerPath, fileName, filePath; + QMessageBox *msg; public slots: void rightDisplay(); @@ -116,6 +121,8 @@ public slots: static App * getAppInfo(QString filePath); private slots: + void propsDialog(); + void on_pushButton_pressed(); void foundFile(File); void findFinished(); @@ -130,6 +137,7 @@ private slots: void leftComboBoxScroll(); void rightComboBox(); void leftComboBox(); + void leftComboBoxPhone(); void leftTableWidgetActivated(); void rightTableWidgetActivated(); @@ -188,6 +196,9 @@ private slots: void copySlotToComputer(QStringList list); void copySlotToPhone(QStringList list); void copySlotToPhoneLeft(QStringList list); + void saveFile(); + void removeFile(); + signals: void phoneConnectionChanged(int); void progressValue(int value, int max); diff --git a/widgets/filewidget.ui b/widgets/filewidget.ui index e5a2f87..2dff995 100644 --- a/widgets/filewidget.ui +++ b/widgets/filewidget.ui @@ -7,7 +7,7 @@ 0 0 759 - 233 + 839 @@ -22,7 +22,7 @@ 10 10 737 - 160 + 751 @@ -188,6 +188,11 @@ /data/app/ + + + /sd-ext/ + + /system/ diff --git a/widgets/messagewidget.cpp b/widgets/messagewidget.cpp index 29e2164..3d4cf42 100644 --- a/widgets/messagewidget.cpp +++ b/widgets/messagewidget.cpp @@ -258,7 +258,7 @@ void MessageWidget::sendToClient(QString message) socket->disconnectFromHost(); } else - QMessageBox::warning(this,"connection problem", "connection to client failed", QMessageBox::Close); + QMessageBox::warning(this,"Connection problem:", "Connection to client failed!", QMessageBox::Close); delete socket; } @@ -268,7 +268,7 @@ void MessageWidget::connectToClient() socket->connectToHost(this->clientIP,4444,QTcpSocket::ReadWrite); if (!socket->waitForConnected(2000)) { - QMessageBox::warning(this,"connection problem", "connection to client failed", QMessageBox::Close); + QMessageBox::warning(this,"Connection problem:", "Connection to client failed!", QMessageBox::Close); } delete socket; } diff --git a/widgets/phoneinfowidget.cpp b/widgets/phoneinfowidget.cpp index 3368c1a..661fbf8 100644 --- a/widgets/phoneinfowidget.cpp +++ b/widgets/phoneinfowidget.cpp @@ -145,7 +145,7 @@ void PhoneInfoWidget::showPhoneInfo() - proces->start("\""+sdk+"\""+"adb shell busybox cat /sys/class/power_supply/battery/capacity"); + proces->start("\""+sdk+"\""+"adb shell cat /sys/class/power_supply/battery/capacity"); proces->waitForReadyRead(-1); tmp=proces->readLine(); ui->progressBarBatteryLevel->setValue(tmp.toInt()); @@ -154,7 +154,7 @@ void PhoneInfoWidget::showPhoneInfo() QString sdFolder; // QStringList lines, split; // sdFolder.clear(); -// proces->start("\"" + this->sdk + "\"adb shell busybox mount"); +// proces->start("\"" + this->sdk + "\"adb shell mount"); // proces->waitForFinished(-1); // tmp = proces->readAll(); // qDebug()<<"Get phone info mount - "<start("\""+sdk+"\""+"adb shell busybox df"); + proces->start("\""+sdk+"\""+"adb shell df"); tmp.clear(); while (true) diff --git a/widgets/phoneinfowidget.ui b/widgets/phoneinfowidget.ui index fa1402b..f2747f1 100644 --- a/widgets/phoneinfowidget.ui +++ b/widgets/phoneinfowidget.ui @@ -365,7 +365,7 @@ border: 1px solid black; - /ext + /sdext diff --git a/widgets/recoverywidget.cpp b/widgets/recoverywidget.cpp index 5633ec6..3e1b6af 100644 --- a/widgets/recoverywidget.cpp +++ b/widgets/recoverywidget.cpp @@ -172,7 +172,7 @@ void RecoveryWidget::fixUIDoutput() void RecoveryWidget::flashZip() { - if (QMessageBox::question(this, tr("Flash Zip"), tr("Are you sure??"), QMessageBox::Yes | QMessageBox::No) == QMessageBox::No) + if (QMessageBox::question(this, tr("Flash Zip:"), tr("Are you sure??"), QMessageBox::Yes | QMessageBox::No) == QMessageBox::No) return; this->romFileName = QFileDialog::getOpenFileName(this, tr("Open ROM File"), "/", tr("Zip files (*.zip)")); QFileInfo fInfo = QFileInfo(this->romFileName); @@ -234,15 +234,15 @@ void RecoveryWidget::mountSDcard() tmp = process->readAll(); if (tmp.contains("enabled")) { - QMessageBox::information(this, tr("USB mounted"), tr("SD card is mounted as usb drive"), QMessageBox::Ok); + QMessageBox::information(this, tr("USB mounted:"), tr("SD card is mounted as usb drive."), QMessageBox::Ok); } else if (tmp.contains("disabled")) { - QMessageBox::information(this, tr("USB unmounted"), tr("SD card is unmounted"), QMessageBox::Ok); + QMessageBox::information(this, tr("USB unmounted:"), tr("SD card is unmounted."), QMessageBox::Ok); } else { - QMessageBox::warning(this, tr("Error"), tmp, QMessageBox::Ok); + QMessageBox::warning(this, tr("Error:"), tmp, QMessageBox::Ok); } process->terminate(); delete process; @@ -485,11 +485,11 @@ void RecoveryWidget::nandroidRestoreFound() if (tmpStr.contains("Error")) { - QMessageBox::warning(this, "Error", tmpStr, QMessageBox::Ok); + QMessageBox::warning(this, "Error:", tmpStr, QMessageBox::Ok); this->ui->textNandroidRestore->insertPlainText(tr("Finished")); } else - this->ui->textNandroidRestore->insertPlainText(tr("Finished\nChoose one backup from combo above to restore it")); + this->ui->textNandroidRestore->insertPlainText(tr("Finished\nChoose one backup from combo above to restore it.")); this->nandroidRestoreCombo(); } @@ -529,12 +529,12 @@ void RecoveryWidget::wipeBattery() process->terminate(); output = process->readAll(); delete process; - QMessageBox::information(this, tr("Information"), output, QMessageBox::Ok); + QMessageBox::information(this, tr("Information:"), output, QMessageBox::Ok); } void RecoveryWidget::wipeData() { - if (QMessageBox::question(this, tr("Wipe data"), tr("Are you sure??"), QMessageBox::Yes | QMessageBox::No) == QMessageBox::No) + if (QMessageBox::question(this, tr("Wipe data:"), tr("Are you sure??"), QMessageBox::Yes | QMessageBox::No) == QMessageBox::No) return; this->procesNandroid.setProcessChannelMode(QProcess::MergedChannels); this->procesNandroid.start("\"" + sdk + "\"adb shell echo \'--wipe_data\'>/cache/recovery/command"); diff --git a/widgets/sdfiles.h b/widgets/sdfiles.h new file mode 100644 index 0000000..0837fdb --- /dev/null +++ b/widgets/sdfiles.h @@ -0,0 +1,22 @@ +#ifndef SDFILES_H +#define SDFILES_H + +#include + +namespace Ui { +class SdFiles; +} + +class SdFiles : public QWidget +{ + Q_OBJECT + +public: + explicit SdFiles(QWidget *parent = 0); + ~SdFiles(); + +private: + Ui::SdFiles *ui; +}; + +#endif // SDFILES_H diff --git a/widgets/sdfiles.ui b/widgets/sdfiles.ui new file mode 100644 index 0000000..a837b22 --- /dev/null +++ b/widgets/sdfiles.ui @@ -0,0 +1,21 @@ + + + + + SdFiles + + + + 0 + 0 + 400 + 300 + + + + Form + + + + + diff --git a/widgets/settingswidget.cpp b/widgets/settingswidget.cpp index d442811..b425aa0 100644 --- a/widgets/settingswidget.cpp +++ b/widgets/settingswidget.cpp @@ -60,6 +60,10 @@ SettingsWidget::SettingsWidget(QWidget *parent) : connect(this->ui->listWidget, SIGNAL(currentRowChanged(int)), this, SLOT(changePage(int))); connect(&this->animation.animation, SIGNAL(finished()), this, SLOT(animationFinished())); connect(this->ui->buttonDetectSdExt, SIGNAL(clicked()), this, SLOT(detectSdExtFolder())); + connect(this->ui->buttonBrowseFolder, SIGNAL(clicked()), this, SLOT(on_buttonBrowseFolder_pressed())); + + connect(this->ui->editBacFolder, SIGNAL(returnPressed()), this, SLOT(appsBackupFolderExists())); + connect(this->ui->buttonSaveSettings, SIGNAL(clicked()), this, SLOT(appsBackupFolderExists())); ui->listWidgetCurvePicker->setIconSize(QSize(64,64)); @@ -69,6 +73,7 @@ SettingsWidget::SettingsWidget(QWidget *parent) : this->getSettings(); this->changeFont(); + } void SettingsWidget::animationFinished() @@ -170,7 +175,7 @@ void SettingsWidget::changeEvent(QEvent *e) void SettingsWidget::setSettingsToDefaults() { - if (QMessageBox::question(this,tr("Reset settings??"),tr("Are you sure you want restore settings to defaults???"),QMessageBox::Ok | QMessageBox::No) == QMessageBox::No) + if (QMessageBox::question(this,tr("Reset settings?"),tr("Are you sure you want restore settings to defaults???"),QMessageBox::Ok | QMessageBox::No) == QMessageBox::No) return; this->alwaysCloseCopy = true; this->phoneHiddenFiles = true; @@ -182,13 +187,14 @@ void SettingsWidget::setSettingsToDefaults() this->showPhoneColumnsHeaders = true; this->dialogKopiujShowModal = true; this->killDemonOnExit = false; - this->checkForUpdatesOnStart = true; + this->checkForUpdatesOnStart = false; this->color = true; this->colorShellFiles = true; this->showAppIcon = false; this->showAppName = false; this->getQR = false; this->getCyrketVer = false; + // this->BackupAppsOnSdcard = false; this->showCopyConfirmation = true; this->phonePath = "/"; @@ -216,6 +222,8 @@ void SettingsWidget::setSettingsToDefaults() this->backupColumnList.clear(); this->computerColumnList.clear(); this->phoneColumnList.clear(); + this->appsBackupFolder.clear(); + this->setSettings(); } @@ -236,6 +244,18 @@ void SettingsWidget::settingsSlotChanged() this->ui->editAppName->setEnabled(true); else this->ui->editAppName->setDisabled(true); +/* + if (this->ui->checkBackOnSdcard->isChecked()) + { + this->ui->editBacFolder->setDisabled(true); + this->ui->buttonBrowseFolder->setDisabled(true); + } + else + { + this->ui->editBacFolder->setEnabled(true); + this->ui->buttonBrowseFolder->setEnabled(true); + } + */ } void SettingsWidget::on_buttonRemoveSettings_pressed() @@ -266,6 +286,7 @@ void SettingsWidget::saveSettings() settings->setValue("rememberPhonePath", this->ui->radioPhoneRemPath->isChecked()); // settings->setValue("getQR", this->ui->checkGetQrcode->isChecked()); settings->setValue("getCyrketVer", this->ui->checkCyrketVer->isChecked()); + // settings->setValue("BackupAppsOnSdcard", this->ui->checkBackOnSdcard->isChecked()); settings->setValue("fontAppFamily", this->fontApp.family()); settings->setValue("fontAppSize", this->fontApp.pointSize()); settings->setValue("fontTablesFamily", this->fontTables.family()); @@ -300,6 +321,15 @@ void SettingsWidget::saveSettings() settings->setValue("shellBackgroundColor", this->ui->shellLabelCurrentBackground->palette().background().color()); settings->setValue("shellFontColor", this->ui->shellLabelCurrentFont->palette().background().color()); settings->setValue("sdFolder", this->ui->editSdExt->text()); + + //if (!this->ui->checkBackOnSdcard->isChecked()) + // { + // this->ui->editBacFolder->clear(); + // settings->setValue("AppsBackupFolder", this->ui->editBacFolder->text()); + //} + // else + settings->setValue("appsBackupFolder", this->ui->editBacFolder->text()); + settings->setValue("showCopyConfirmation",ui->checkBoxShowCopyConfirmation->isChecked()); int columns = this->appsColumnModel->rowCount(QModelIndex()); QStringList columnsList; @@ -402,6 +432,7 @@ void SettingsWidget::getSettings() this->showAppName = settings->value("showAppName", false).toBool(); this->getQR = settings->value("getQR", false).toBool(); this->getCyrketVer = settings->value("getCyrketVer", false).toBool(); + // this->BackupAppsOnSdcard = settings->value("BackupAppsOnSdcard", false).toBool(); this->enableAnimations = settings->value("enableAnimations", true).toBool(); this->animationCurve = settings->value("curve", int(QEasingCurve::OutBounce)).toInt(); this->clearSettings = false; @@ -442,6 +473,8 @@ void SettingsWidget::getSettings() settings->setValue("sdFolder", this->sdFolder); } + this->appsBackupFolder = settings->value("appsBackupFolder").toString(); + this->appColumnList = settings->value("appColumnList").toStringList(); this->backupColumnList = settings->value("backupColumnList").toStringList(); this->computerColumnList = settings->value("computerColumnList").toStringList(); @@ -526,6 +559,7 @@ void SettingsWidget::setSettings() this->ui->editAppName->setText(this->showAppNameConfig); // this->ui->checkGetQrcode->setChecked(this->getQR); this->ui->checkCyrketVer->setChecked(this->getCyrketVer); + // this->ui->checkBackOnSdcard->setChecked(this->BackupAppsOnSdcard); this->ui->checkColorShellFiles->setChecked(this->colorShellFiles); ui->checkBoxShowCopyConfirmation->setChecked(this->showCopyConfirmation); @@ -552,6 +586,7 @@ void SettingsWidget::setSettings() this->setBackgroundColor(ui->shellLabelCurrentBackground, this->shellBackgroundColor); this->setBackgroundColor(ui->shellLabelCurrentFont, this->shellFontColor); this->ui->editSdExt->setText(this->sdFolder); + this->ui->editBacFolder->setText(this->appsBackupFolder); this->ui->spinToolBarIconSize->setValue(this->toolBarIconSize.height()); if (this->toolBarHideButton) @@ -753,7 +788,7 @@ void SettingsWidget::changeFont() void SettingsWidget::on_buttonAssociate_clicked() { - if (QMessageBox::question(this,tr("Associate??"),tr("Are you sure you want to associate *.apk files with QtADB???"),QMessageBox::Ok | QMessageBox::No) == QMessageBox::No) + if (QMessageBox::question(this,tr("Associate files:"),tr("Are you sure you want to associate *.apk files with QtADB???"),QMessageBox::Ok | QMessageBox::No) == QMessageBox::No) return; QSettings settings("HKEY_LOCAL_MACHINE\\SOFTWARE\\Classes\\", QSettings::NativeFormat); @@ -801,7 +836,7 @@ void SettingsWidget::detectSdExtFolder() QString output; this->sdFolder = ""; - shell->start("\"" + this->sdkPath + "\"adb shell 'busybox stat /data/app |grep \"File\"'"); + shell->start("\"" + this->sdkPath + "\"adb shell 'stat /data/app | grep \"File\"'"); shell->waitForFinished(); output = shell->readAll(); if (output.contains("->")) @@ -812,7 +847,7 @@ void SettingsWidget::detectSdExtFolder() } else { - shell->start("\"" + this->sdkPath + "\"adb shell busybox mount"); + shell->start("\"" + this->sdkPath + "\"adb shell mount"); shell->waitForFinished(); output = shell->readAll(); if (output.contains("ext")) @@ -869,13 +904,80 @@ void SettingsWidget::on_pushButtonChangeSDKPath_pressed() if (!sdkOk) { - QMessageBox *msgBox = new QMessageBox(QMessageBox::Critical, QObject::tr("error"), QObject::tr("there is no adb binary in here!")); + QMessageBox *msgBox = new QMessageBox(QMessageBox::Critical, QObject::tr("Error:"), QObject::tr("There is no adb binary in this location!")); msgBox->exec(); } else { QSettings settings; settings.setValue("sdkPath",sdk); - this->sdkPath = sdk; + this->sdkPath = sdk; + } +} + +void SettingsWidget::on_buttonBrowseFolder_pressed() +{ + QString appsBackFolder=QFileDialog::getExistingDirectory(NULL,QObject::tr("Choose Folder to Backup Selected Apps and/or Data..."),directory.path()); + + if (appsBackFolder.isNull()) + return; + QSettings settings; + settings.setValue("appsBackupFolder",appsBackFolder); + this->appsBackupFolder = appsBackFolder; + this->ui->editBacFolder->setText(this->appsBackupFolder); + this->appsBackupFolderExists(); +} + +void SettingsWidget::appsBackupFolderExists() +{ + Computer *computer = new Computer; + QString newAppsBackupFolder = this->ui->editBacFolder->text(); + if (newAppsBackupFolder.isEmpty()) + return; + if (newAppsBackupFolder.contains("/sdcard/")) + { + QProcess *sdcard=new QProcess(); + sdcard->setProcessChannelMode(QProcess::MergedChannels); + QString command; + QString outputLine; + if (!newAppsBackupFolder.endsWith("/")) + { + QSettings settings; + this->ui->editBacFolder->setText(newAppsBackupFolder.append("/")); + settings.setValue("appsBackupFolder",newAppsBackupFolder); + } + command = "\""+this->sdkPath+"\""+"adb shell ls \""+newAppsBackupFolder+"\""; + qDebug()<start(command); + sdcard->waitForFinished(-1); + outputLine=sdcard->readLine(); + qDebug()<sdkPath+"\""+"adb shell mkdir \""+newAppsBackupFolder+"\""; + qDebug()<start(command); + sdcard->waitForFinished(-1); + outputLine=sdcard->readLine(); + sdcard->terminate(); + delete sdcard; + if (outputLine.contains(QRegExp("can't create directory"))) + QMessageBox::critical(this,"Backup Apps on Phone:","Can't create " "\"" + newAppsBackupFolder + "\"" "\nCheck path entered and make sure you are allowed to create folders!"); + } + } + else + { + if (!QDir(newAppsBackupFolder).exists()) + { + if (computer->makeDir(newAppsBackupFolder) == false) + { + QMessageBox::critical(this,"Backup Apps on PC:","Can't create " "\"" + newAppsBackupFolder + "\"" "\nCheck path and make sure you are allowed to create folders!"); + } + } } } diff --git a/widgets/settingswidget.h b/widgets/settingswidget.h index e04cfc6..b352872 100644 --- a/widgets/settingswidget.h +++ b/widgets/settingswidget.h @@ -27,6 +27,9 @@ #include "../classes/models/apptablemodel.h" #include "../classes/models/backuptablemodel.h" #include "../classes/models/filetablemodel.h" +#include "../classes/computer.h" + +#include namespace Ui { @@ -60,12 +63,15 @@ class SettingsWidget : public QWidget bool enableAnimations; bool getQR; bool getCyrketVer; + // bool BackupAppsOnSdcard; bool showCopyConfirmation; QString phonePath; QString computerPath; QString showAppNameConfig; QString sdkPath; + QString appsBackupFolder; + QString editBacFolder; QString wlanIP; QString sdFolder; @@ -88,6 +94,7 @@ class SettingsWidget : public QWidget void setSettings(); + int currentIndex; QStandardItemModel *appsColumnModel; QStringList appColumnList; @@ -113,6 +120,7 @@ class SettingsWidget : public QWidget void createCurveIcons(); Animation animation; void setBackgroundColor(QLabel *label, QColor color); + QDir directory; public slots: void saveSettings(); @@ -120,6 +128,12 @@ public slots: private slots: void on_pushButtonChangeSDKPath_pressed(); + + void on_buttonBrowseFolder_pressed(); + + void appsBackupFolderExists(); + + void getSettings(); void settingsSlotChanged(); void chooseFontApp(); @@ -141,6 +155,8 @@ private slots: signals: void settingsChanged(); + + void stateChanged (int state); }; #endif // SETTINGSWIDGET_H diff --git a/widgets/settingswidget.ui b/widgets/settingswidget.ui index ed8f80c..a1809f6 100644 --- a/widgets/settingswidget.ui +++ b/widgets/settingswidget.ui @@ -121,6 +121,13 @@ + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:8pt;">Clear QtADB entries from system registry. Do this first if you want to remove QtADB from your PC.</span></p></body></html> + Remove settings from system @@ -134,8 +141,11 @@ 0 + + Reset settings to default values. + - Set defaults + Set default settings @@ -147,6 +157,9 @@ 0 + + Save current settings to system registry. + Save Settings @@ -163,15 +176,22 @@ true + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:8pt;">Associate .apk files on PC with QtADB. Enables apps Info/Install/Uninstall directly from Windows Explorer without opening QtADB.</span></p></body></html> + - Associate apk files with QtADB + Associate .apk files with QtADB - 0 + 4 @@ -186,6 +206,13 @@ + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:8pt;">Save position and size of QtADB window on exit.</span></p></body></html> + Save position and size of window on exit @@ -193,6 +220,9 @@ + + Autohide Copy dialog window after copying finishes. + Always close copy window after finished @@ -532,7 +562,7 @@ - + 10 @@ -950,7 +980,7 @@ Both - + 10 @@ -1205,7 +1235,7 @@ - + Qt::Vertical @@ -1294,14 +1324,14 @@ - + Check app version on internet - + QAbstractItemView::NoEditTriggers @@ -1311,17 +1341,17 @@ - + - + Show/hide apps columns: - + Show/hide backups columns: @@ -1333,7 +1363,7 @@ - sd ext folder + sdext folder @@ -1349,6 +1379,37 @@ + + + + + + apps backup folder + + + + + + + Qt::ImhNone + + + true + + + Browse for PC folder or set path to folder on Phone's /sdcard/ and press [Enter]... + + + + + + + Browse + + + + + @@ -1679,8 +1740,11 @@ + + QtADB requires Android SDK to work properly. Browse to the installation folder to Set/Change Android SDK path. + - Change sdk path... + Set Android SDK path diff --git a/widgets/shellwidget.cpp b/widgets/shellwidget.cpp index 4877e3f..3bfa6d8 100644 --- a/widgets/shellwidget.cpp +++ b/widgets/shellwidget.cpp @@ -1,545 +1,561 @@ -/*********************************************************************** -*Copyright 2010-20XX by 7ymekk -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -* -* @author 7ymekk (7ymekk@gmail.com) -* -************************************************************************/ - - -#include "shellwidget.h" -#include "ui_shellwidget.h" - -/* - dodac 2 listy stringow: - - commandList - w konstruktorze wczytywac komendy busyboxa i shella, a pozniej szift+tab bedzie podpowiadal komendy - - fileList - przy przechodzeniu miedzy folderami (komenda 'cd') bedzie wywolywana metoda Phone::getFileList a nastepnie po nacisnieciu tab bedzie podpwiadac foldery - * obie listy maja byc posortowane alfabetycznie. - * aby uzyskac podpowiedz nie trzeba wpisywac duzych liter -*/ - -ShellWidget::ShellWidget(QWidget *parent) : - QTextEdit(parent) -{ - this->insertedChars = 0; - this->cursorPosition = 0; - this->commandHistoryPosition = 0; - this->cursor = this->textCursor(); - this->setCursorWidth(3); - this->setTextCursor(cursor); - this->setContextMenuPolicy(Qt::CustomContextMenu); - - QSettings settings; - this->sdk=settings.value("sdkPath").toString(); - - this->fontColor = settings.value("shellFontColor", Qt::black).value(); - - QPalette palette = this->palette(); - palette.setColor(QPalette::Base, settings.value("shellBackgroundColor", Qt::white).value()); - - this->setPalette(palette); - - this->setTextColor(this->fontColor); - - //qDebug()<<"MainWindow::showPageShell() - process shell is not running, starting..."; - this->process.setProcessChannelMode(QProcess::MergedChannels); - this->process.start("\""+sdk+"\""+"adb shell"); - - connect(&this->process, SIGNAL(readyRead()), this, SLOT(readFromProcess())); -} - -ShellWidget::~ShellWidget() -{ - this->process.close(); -} - -void ShellWidget::keyPressEvent(QKeyEvent *e) -{ - if (e->modifiers() == Qt::ControlModifier) - { - if (e->key() == Qt::Key_C) - { - this->process.write(QString(QChar(0x3)).toAscii()); - } - else if (e->key() == Qt::Key_Left) - { - if (this->cursorPosition < this->insertedChars) - { - int pos = this->cursor.position(); - this->cursor.movePosition(QTextCursor::PreviousWord); - this->setTextCursor(this->cursor); - this->cursorPosition+=pos-this->cursor.position(); - } - } - else if (e->key() == Qt::Key_Right) - { - if (this->cursorPosition > 0) - { - int pos = this->cursor.position(); - this->cursor.movePosition(QTextCursor::NextWord); - this->setTextCursor(this->cursor); - this->cursorPosition-=this->cursor.position()-pos; - } - } - else if (e->key() == Qt::Key_Backspace) - { - //usun poprzedzajace slowo - } - else if (e->key() == Qt::Key_Delete) - { - //usun nastepne slowo - } - return; - } - else if ((e->modifiers() & Qt::SHIFT) && (e->modifiers() & Qt::CTRL)) - { - if (e->key() == Qt::Key_V) - { - QClipboard *clipboard = QApplication::clipboard(); - QString tmp = clipboard->text(QClipboard::Clipboard); - if (tmp.length()>0) - { - this->insertedChars+=tmp.length(); - this->command.insert(this->command.length()-this->cursorPosition,tmp); - this->insertPlainText(tmp); - } - } - else if (e->key() == Qt::Key_C) - { - QClipboard *clipboard = QApplication::clipboard(); - QString tmp = this->textCursor().selection().toPlainText(); - - clipboard->setText(tmp,QClipboard::Clipboard); - } - return; - } - - this->cursor.movePosition(QTextCursor::End); - this->cursor.movePosition(QTextCursor::Left,QTextCursor::MoveAnchor,this->cursorPosition); - this->setTextCursor(this->cursor); - - if (e->key() == Qt::Key_Return) - { - this->cursor.movePosition(QTextCursor::End); - this->setTextCursor(this->cursor); - this->cursorPosition = 0; - this->insertedChars = 0; - executeCommand(this->command); - this->command.clear(); - this->commandHistoryPosition = -1; - } - else if (e->key() == Qt::Key_Up) - { - if (this->commandHistory.length() -1 > this->commandHistoryPosition) - { - if (command.length()>0) - { - this->cursor.movePosition(QTextCursor::End); - for (int i = 0 ; i < this->insertedChars ; i++) - this->cursor.deletePreviousChar(); - this->cursorPosition = 0; - this->insertedChars = 0; - command.clear(); - } - this->commandHistoryPosition++; - this->command = this->commandHistory.at(this->commandHistoryPosition); - this->insertedChars = this->command.length(); - this->insertPlainText(this->command); - } - } - else if (e->key() == Qt::Key_Down) - { - if (this->commandHistoryPosition > 0) - { - if (command.length()>0) - { - this->cursor.movePosition(QTextCursor::End); - for (int i = 0 ; i < this->insertedChars ; i++) - this->cursor.deletePreviousChar(); - this->cursorPosition = 0; - this->insertedChars = 0; - command.clear(); - } - this->commandHistoryPosition--; - this->command = this->commandHistory.at(this->commandHistoryPosition); - this->insertedChars = this->command.length(); - this->insertPlainText(this->command); - } - } - else if (e->key() == Qt::Key_Left) - { - if (this->cursorPosition < this->insertedChars) - { - this->cursor.movePosition(QTextCursor::Left); - this->setTextCursor(this->cursor); - this->cursorPosition++; - } - } - else if (e->key() == Qt::Key_Right) - { - if (this->cursorPosition > 0) - { - this->cursor.movePosition(QTextCursor::Right); - this->setTextCursor(this->cursor); - this->cursorPosition--; - } - } - else if (e->key() == Qt::Key_Delete) - { - if (this->cursorPosition > 0) - { - this->cursor.movePosition(QTextCursor::Right); - this->setTextCursor(this->cursor); - this->cursor.deletePreviousChar(); - this->command.remove(this->command.length()-this->cursorPosition-1,1); - this->insertedChars--; - this->cursorPosition--; - } - } - else if (e->key() == Qt::Key_Backspace) - { - if (this->insertedChars > this->cursorPosition) - { - this->cursor.deletePreviousChar(); - this->command.remove(this->command.length()-this->cursorPosition-1,1); - this->insertedChars--; - } - } - else if(e->key() == Qt::Key_Escape) - { - this->process.write(QString(QChar(0x3)).toAscii()); - } - else if (e->text().length()>0) - { - this->insertPlainText(e->text()); - this->insertedChars++; - this->command.insert(this->command.length()-this->cursorPosition,e->text()); - } - -} - -void ShellWidget::executeCommand(QString command) -{ - if (command == "qtadb -help") - { - this->append(tr("\nQtADB shell help\n")); - this->append(tr("CTRL+C - interrupt executing command")); - this->append(tr("ESC - interrupt executing command")); - this->append(tr("Shift+CTRL+C - copy selected text to clipboard")); - this->append(tr("Shift+CTRL+V - paste text from clipboard")); - this->append(tr("Enter/Return - execute command")); - this->append(tr("Up (arrow) - display previous executed command")); - this->append(tr("Down (arrow) - display next executed command")); - this->append(tr("Left(arrow) - move cursor to the left")); - this->append(tr("Right(arrow) - move cursor to the right")); - this->append(tr("CTRL+Left(arrow) - move cursor to the left skipping over the word")); - this->append(tr("CTRL+Right(arrow) - move cursor to the right skipping over the word")); - this->append(tr("Delete - delete next char")); - this->append(tr("Backspace - delete previous char")); - this->process.write("\n"); - } - else - { - this->process.write(command.toLatin1()+"\n"); - } - this->commandHistory.prepend(command); -} - -void ShellWidget::readFromProcess() -{ - QString tmp = QString::fromUtf8(this->process.readAll()); - QStringList tmp2; - QString print; - int i; - - for (i = 0; i < tmp.length(); i++) - { - if (tmp.at(i).unicode() == 13) - tmp[i] = ' '; - if (tmp.at(i).unicode() == 10) - tmp[i] = '\n'; - } - tmp.remove(0,tmp.indexOf("\n")); - if (tmp.contains(QChar( 0x1b ), Qt::CaseInsensitive)) - { - QSettings settings; - tmp.remove("[0m"); - if (settings.value("colorShellFiles").toBool()) - { - tmp2 = tmp.split(QChar( 0x1b ), QString::SkipEmptyParts, Qt::CaseInsensitive); - - while (tmp2.size() > 0) - { - print = tmp2.takeFirst(); - if (print.contains("0;30"))//black - { - this->setTextColor(this->fontColor); - } - else if (print.contains("0;34"))//blue - { - this->setTextColor(Qt::blue); - } - else if (print.contains("0;32"))//green - { - this->setTextColor(Qt::green); - } - else if (print.contains("0;36"))//cyan - { - this->setTextColor(Qt::cyan); - } - else if (print.contains("0;31"))//red - { - this->setTextColor(Qt::red); - } - else if (print.contains("0;35"))//purple - { - this->setTextColor(QColor::fromRgb(0, 0, 0)); - } - else if (print.contains("0;33"))//brown - { - this->setTextColor(QColor::fromRgb(0, 0, 0)); - } - else if (print.contains("0;37"))//light gray - { - this->setTextColor(Qt::lightGray); - } - else if (print.contains("1;30"))//dark gray - { - this->setTextColor(Qt::darkGray); - } - else if (print.contains("[1;34"))//dark gray - { - this->setTextColor(Qt::blue); - } - else if (print.contains("1;32"))//light green - { - this->setTextColor(Qt::green); - } - else if (print.contains("1;36"))//light cyan - { - this->setTextColor(Qt::cyan); - } - else if (print.contains("1;31"))//light red - { - this->setTextColor(Qt::red); - } - else if (print.contains("1;35"))//light purple - { - this->setTextColor(QColor::fromRgb(0, 0, 0)); - } - else if (print.contains("1;33"))//yellow - { - this->setTextColor(Qt::yellow); - } - else if (print.contains("1;37"))//white - { - this->setTextColor(Qt::white); - } - print.remove(QRegExp("\\[\\d;\\d+m")); - this->insertPlainText(print); - this->setTextColor(this->fontColor); - } - } - else - { - tmp.remove(QChar( 0x1b ), Qt::CaseInsensitive); - tmp.remove(QRegExp("\\[\\d;\\d+m")); - this->insertPlainText(tmp); - } - } - else - { - this->append(tmp); - } - this->ensureCursorVisible(); - - //qDebug()<<"readShell() - "<setupUi(this); - connect(ui->editShell, SIGNAL(returnPressed()), this, SLOT(writeShell())); - this->commandModel = new QStringListModel; - this->completer = new QCompleter; - this->completer->setCompletionMode(QCompleter::UnfilteredPopupCompletion); - this->completer->setMaxVisibleItems(10); - this->completer->setModel(this->commandModel); - this->completer->setModelSorting(QCompleter::CaseInsensitivelySortedModel); - - this->ui->editShell->setCompleter(this->completer); - this->processShellIsRunning = false; - - connect(this->procesShell, SIGNAL(finished(int)), this, SLOT(shellFinished())); -} -void ShellWidget::changeEvent(QEvent *e) -{ - QWidget::changeEvent(e); - switch (e->type()) { - case QEvent::LanguageChange: - ui->retranslateUi(this); - break; - default: - break; - } -} - -void ShellWidget::keyPressEvent(QKeyEvent *e) -{ - if(ui->editShell->hasFocus() && e->key() == Qt::Key_Escape) - { - this->procesShell->write(QString(QChar(0x3)).toAscii()); - } - if(ui->editShell->hasFocus() && e->key() == Qt::Key_Down) - { - this->completer->complete(); - } - -} - - -void ShellWidget::readShell() -{ - QString tmp = QString::fromUtf8(this->procesShell->readAll()); - QStringList tmp2; - QString print; - int i; - - - for (i = 0; i < tmp.length(); i++) - { - if (tmp.at(i).unicode() == 13) - tmp[i] = ' '; - if (tmp.at(i).unicode() == 10) - tmp[i] = '\n'; - } - if (tmp.contains(QChar( 0x1b ), Qt::CaseInsensitive)) - { - QSettings settings; - tmp.remove("[0m"); - if (settings.value("colorShellFiles").toBool()) - { - tmp2 = tmp.split(QChar( 0x1b ), QString::SkipEmptyParts, Qt::CaseInsensitive); - while (tmp2.size() > 0) - { - print = tmp2.takeFirst(); - if (print.contains("0;30"))//black - { -// this->ui->textShell->setTextColor(Qt::black); - this->ui->textShell->setTextColor(this->fontColor); - } - else if (print.contains("0;34"))//blue - { - this->ui->textShell->setTextColor(Qt::blue); - } - else if (print.contains("0;32"))//green - { - this->ui->textShell->setTextColor(Qt::green); - } - else if (print.contains("0;36"))//cyan - { - this->ui->textShell->setTextColor(Qt::cyan); - } - else if (print.contains("0;31"))//red - { - this->ui->textShell->setTextColor(Qt::red); - } - else if (print.contains("0;35"))//purple - { - this->ui->textShell->setTextColor(QColor::fromRgb(0, 0, 0)); - } - else if (print.contains("0;33"))//brown - { - this->ui->textShell->setTextColor(QColor::fromRgb(0, 0, 0)); - } - else if (print.contains("0;37"))//light gray - { - this->ui->textShell->setTextColor(Qt::lightGray); - } - else if (print.contains("1;30"))//dark gray - { - this->ui->textShell->setTextColor(Qt::darkGray); - } - else if (print.contains("[1;34"))//dark gray - { - this->ui->textShell->setTextColor(Qt::blue); - } - else if (print.contains("1;32"))//light green - { - this->ui->textShell->setTextColor(Qt::green); - } - else if (print.contains("1;36"))//light cyan - { - this->ui->textShell->setTextColor(Qt::cyan); - } - else if (print.contains("1;31"))//light red - { - this->ui->textShell->setTextColor(Qt::red); - } - else if (print.contains("1;35"))//light purple - { - this->ui->textShell->setTextColor(QColor::fromRgb(0, 0, 0)); - } - else if (print.contains("1;33"))//yellow - { - this->ui->textShell->setTextColor(Qt::yellow); - } - else if (print.contains("1;37"))//white - { - this->ui->textShell->setTextColor(Qt::white); - } - print.remove(QRegExp("\\[\\d;\\d+m")); - this->ui->textShell->insertPlainText(print); - this->ui->textShell->setTextColor(this->fontColor); - } - } - else - { - tmp.remove(QChar( 0x1b ), Qt::CaseInsensitive); - tmp.remove(QRegExp("\\[\\d;\\d+m")); - this->ui->textShell->insertPlainText(tmp); - } - } - else - { - this->ui->textShell->append(tmp); - } - - qDebug()<<"readShell() - "<procesShell,SIGNAL(readyRead()),this,SLOT(readShell())); - disconnect(this->procesShell, SIGNAL(finished(int)), this, SLOT(shellFinished())); -} - -void ShellWidget::writeShell() -{ - QString tmp; - - tmp = this->ui->editShell->text(); - if (!this->commandList.contains(tmp)) - this->commandList.append(tmp); - this->commandModel->setStringList(this->commandList); - tmp.append("\n"); - this->procesShell->write(tmp.toUtf8()); - - this->ui->editShell->clear(); -} -*/ +/*********************************************************************** +*Copyright 2010-20XX by 7ymekk +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +* +* @author 7ymekk (7ymekk@gmail.com) +* +************************************************************************/ + + +#include "shellwidget.h" +#include "ui_shellwidget.h" + + +//extern QString sdk; +//extern QString adb; +//extern QString aapt; +//extern QProcess *adbProces; +//extern QString busybox; +//extern QString fastboot; + + +/* + dodac 2 listy stringow: + - commandList - w konstruktorze wczytywac komendy busyboxa i shella, a pozniej szift+tab bedzie podpowiadal komendy + - fileList - przy przechodzeniu miedzy folderami (komenda 'cd') bedzie wywolywana metoda Phone::getFileList a nastepnie po nacisnieciu tab bedzie podpwiadac foldery + * obie listy maja byc posortowane alfabetycznie. + * aby uzyskac podpowiedz nie trzeba wpisywac duzych liter +*/ + +ShellWidget::ShellWidget(QWidget *parent) : + QTextEdit(parent) +{ + this->insertedChars = 0; + this->cursorPosition = 0; + this->commandHistoryPosition = 0; + this->cursor = this->textCursor(); + this->setCursorWidth(3); + this->setTextCursor(cursor); + this->setContextMenuPolicy(Qt::CustomContextMenu); + QSettings settings; + this->fontColor = settings.value("shellFontColor", Qt::black).value(); + + QPalette palette = this->palette(); + palette.setColor(QPalette::Base, settings.value("shellBackgroundColor", Qt::white).value()); + + this->setPalette(palette); + + this->setTextColor(this->fontColor); + + //qDebug()<<"MainWindow::showPageShell() - process shell is not running, starting..."; + this->sdk=settings.value("sdkPath").toString(); + + this->process.setProcessChannelMode(QProcess::MergedChannels); + this->process.start("\""+sdk+"\""+"adb shell"); + + connect(&this->process, SIGNAL(readyRead()), this, SLOT(readFromProcess())); + this->insertPlainText("QtADB shell. Type 'qtadb -help' for instructions\n"); +} + +ShellWidget::~ShellWidget() +{ + this->process.close(); +} + +void ShellWidget::Refresh(){ + if (this->process.state() != QProcess::Running){ + this->process.start("\""+sdk+"\""+"adb shell"); + } +} + +void ShellWidget::keyPressEvent(QKeyEvent *e) +{ + if (e->modifiers() == Qt::ControlModifier) + { + if (e->key() == Qt::Key_C) + { + this->process.write(QString(QChar(0x3)).toAscii()); + } + else if (e->key() == Qt::Key_Left) + { + if (this->cursorPosition < this->insertedChars) + { + int pos = this->cursor.position(); + this->cursor.movePosition(QTextCursor::PreviousWord); + this->setTextCursor(this->cursor); + this->cursorPosition+=pos-this->cursor.position(); + } + } + else if (e->key() == Qt::Key_Right) + { + if (this->cursorPosition > 0) + { + int pos = this->cursor.position(); + this->cursor.movePosition(QTextCursor::NextWord); + this->setTextCursor(this->cursor); + this->cursorPosition-=this->cursor.position()-pos; + } + } + else if (e->key() == Qt::Key_Backspace) + { + //usun poprzedzajace slowo + } + else if (e->key() == Qt::Key_Delete) + { + //usun nastepne slowo + } + return; + } + else if ((e->modifiers() & Qt::SHIFT) && (e->modifiers() & Qt::CTRL)) + { + if (e->key() == Qt::Key_V) + { + QClipboard *clipboard = QApplication::clipboard(); + QString tmp = clipboard->text(QClipboard::Clipboard); + if (tmp.length()>0) + { + this->insertedChars+=tmp.length(); + this->command.insert(this->command.length()-this->cursorPosition,tmp); + this->insertPlainText(tmp); + } + } + else if (e->key() == Qt::Key_C) + { + QClipboard *clipboard = QApplication::clipboard(); + QString tmp = this->textCursor().selection().toPlainText(); + + clipboard->setText(tmp,QClipboard::Clipboard); + } + return; + } + + this->cursor.movePosition(QTextCursor::End); + this->cursor.movePosition(QTextCursor::Left,QTextCursor::MoveAnchor,this->cursorPosition); + this->setTextCursor(this->cursor); + + if (e->key() == Qt::Key_Return) + { + Refresh(); + this->cursor.movePosition(QTextCursor::End); + this->setTextCursor(this->cursor); + this->cursorPosition = 0; + this->insertedChars = 0; + executeCommand(this->command); + this->command.clear(); + this->commandHistoryPosition = -1; + } + else if (e->key() == Qt::Key_Up) + { + if (this->commandHistory.length() -1 > this->commandHistoryPosition) + { + if (command.length()>0) + { + this->cursor.movePosition(QTextCursor::End); + for (int i = 0 ; i < this->insertedChars ; i++) + this->cursor.deletePreviousChar(); + this->cursorPosition = 0; + this->insertedChars = 0; + command.clear(); + } + this->commandHistoryPosition++; + this->command = this->commandHistory.at(this->commandHistoryPosition); + this->insertedChars = this->command.length(); + this->insertPlainText(this->command); + } + } + else if (e->key() == Qt::Key_Down) + { + if (this->commandHistoryPosition > 0) + { + if (command.length()>0) + { + this->cursor.movePosition(QTextCursor::End); + for (int i = 0 ; i < this->insertedChars ; i++) + this->cursor.deletePreviousChar(); + this->cursorPosition = 0; + this->insertedChars = 0; + command.clear(); + } + this->commandHistoryPosition--; + this->command = this->commandHistory.at(this->commandHistoryPosition); + this->insertedChars = this->command.length(); + this->insertPlainText(this->command); + } + } + else if (e->key() == Qt::Key_Left) + { + if (this->cursorPosition < this->insertedChars) + { + this->cursor.movePosition(QTextCursor::Left); + this->setTextCursor(this->cursor); + this->cursorPosition++; + } + } + else if (e->key() == Qt::Key_Right) + { + if (this->cursorPosition > 0) + { + this->cursor.movePosition(QTextCursor::Right); + this->setTextCursor(this->cursor); + this->cursorPosition--; + } + } + else if (e->key() == Qt::Key_Delete) + { + if (this->cursorPosition > 0) + { + this->cursor.movePosition(QTextCursor::Right); + this->setTextCursor(this->cursor); + this->cursor.deletePreviousChar(); + this->command.remove(this->command.length()-this->cursorPosition-1,1); + this->insertedChars--; + this->cursorPosition--; + } + } + else if (e->key() == Qt::Key_Backspace) + { + if (this->insertedChars > this->cursorPosition) + { + this->cursor.deletePreviousChar(); + this->command.remove(this->command.length()-this->cursorPosition-1,1); + this->insertedChars--; + } + } + else if(e->key() == Qt::Key_Escape) + { + this->process.write(QString(QChar(0x3)).toAscii()); + } + else if (e->text().length()>0) + { + this->insertPlainText(e->text()); + this->insertedChars++; + this->command.insert(this->command.length()-this->cursorPosition,e->text()); + } + +} + +void ShellWidget::executeCommand(QString command) +{ + if (command == "qtadb -help") + { + this->append(tr("\nQtADB shell help\n")); + this->append(tr("CTRL+C - interrupt executing command")); + this->append(tr("ESC - interrupt executing command")); + this->append(tr("Shift+CTRL+C - copy selected text to clipboard")); + this->append(tr("Shift+CTRL+V - paste text from clipboard")); + this->append(tr("Enter/Return - execute command")); + this->append(tr("Up (arrow) - display previous executed command")); + this->append(tr("Down (arrow) - display next executed command")); + this->append(tr("Left(arrow) - move cursor to the left")); + this->append(tr("Right(arrow) - move cursor to the right")); + this->append(tr("CTRL+Left(arrow) - move cursor to the left skipping over the word")); + this->append(tr("CTRL+Right(arrow) - move cursor to the right skipping over the word")); + this->append(tr("Delete - delete next char")); + this->append(tr("Backspace - delete previous char")); + this->process.write("\n"); + } + else + { + this->process.write(command.toLatin1()+"\n"); + } + this->commandHistory.prepend(command); +} + +void ShellWidget::readFromProcess() +{ + QString tmp = QString::fromUtf8(this->process.readAll()); + QStringList tmp2; + QString print; + int i; + + for (i = 0; i < tmp.length(); i++) + { + if (tmp.at(i).unicode() == 13) + tmp[i] = ' '; + if (tmp.at(i).unicode() == 10) + tmp[i] = '\n'; + } + tmp.remove(0,tmp.indexOf("\n")); + if (tmp.contains(QChar( 0x1b ), Qt::CaseInsensitive)) + { + QSettings settings; + tmp.remove("[0m"); + if (settings.value("colorShellFiles").toBool()) + { + tmp2 = tmp.split(QChar( 0x1b ), QString::SkipEmptyParts, Qt::CaseInsensitive); + + while (tmp2.size() > 0) + { + print = tmp2.takeFirst(); + if (print.contains("0;30"))//black + { + this->setTextColor(this->fontColor); + } + else if (print.contains("0;34"))//blue + { + this->setTextColor(Qt::blue); + } + else if (print.contains("0;32"))//green + { + this->setTextColor(Qt::green); + } + else if (print.contains("0;36"))//cyan + { + this->setTextColor(Qt::cyan); + } + else if (print.contains("0;31"))//red + { + this->setTextColor(Qt::red); + } + else if (print.contains("0;35"))//purple + { + this->setTextColor(QColor::fromRgb(0, 0, 0)); + } + else if (print.contains("0;33"))//brown + { + this->setTextColor(QColor::fromRgb(0, 0, 0)); + } + else if (print.contains("0;37"))//light gray + { + this->setTextColor(Qt::lightGray); + } + else if (print.contains("1;30"))//dark gray + { + this->setTextColor(Qt::darkGray); + } + else if (print.contains("[1;34"))//dark gray + { + this->setTextColor(Qt::blue); + } + else if (print.contains("1;32"))//light green + { + this->setTextColor(Qt::green); + } + else if (print.contains("1;36"))//light cyan + { + this->setTextColor(Qt::cyan); + } + else if (print.contains("1;31"))//light red + { + this->setTextColor(Qt::red); + } + else if (print.contains("1;35"))//light purple + { + this->setTextColor(QColor::fromRgb(0, 0, 0)); + } + else if (print.contains("1;33"))//yellow + { + this->setTextColor(Qt::yellow); + } + else if (print.contains("1;37"))//white + { + this->setTextColor(Qt::white); + } + print.remove(QRegExp("\\[\\d;\\d+m")); + this->insertPlainText(print); + this->setTextColor(this->fontColor); + } + } + else + { + tmp.remove(QChar( 0x1b ), Qt::CaseInsensitive); + tmp.remove(QRegExp("\\[\\d;\\d+m")); + this->insertPlainText(tmp); + } + } + else + { + this->append(tmp); + } + this->ensureCursorVisible(); + + //qDebug()<<"readShell() - "<setupUi(this); + connect(ui->editShell, SIGNAL(returnPressed()), this, SLOT(writeShell())); + this->commandModel = new QStringListModel; + this->completer = new QCompleter; + this->completer->setCompletionMode(QCompleter::UnfilteredPopupCompletion); + this->completer->setMaxVisibleItems(10); + this->completer->setModel(this->commandModel); + this->completer->setModelSorting(QCompleter::CaseInsensitivelySortedModel); + + this->ui->editShell->setCompleter(this->completer); + this->processShellIsRunning = false; + + connect(this->procesShell, SIGNAL(finished(int)), this, SLOT(shellFinished())); +} +void ShellWidget::changeEvent(QEvent *e) +{ + QWidget::changeEvent(e); + switch (e->type()) { + case QEvent::LanguageChange: + ui->retranslateUi(this); + break; + default: + break; + } +} + +void ShellWidget::keyPressEvent(QKeyEvent *e) +{ + if(ui->editShell->hasFocus() && e->key() == Qt::Key_Escape) + { + this->procesShell->write(QString(QChar(0x3)).toAscii()); + } + if(ui->editShell->hasFocus() && e->key() == Qt::Key_Down) + { + this->completer->complete(); + } + +} + + +void ShellWidget::readShell() +{ + QString tmp = QString::fromUtf8(this->procesShell->readAll()); + QStringList tmp2; + QString print; + int i; + + + for (i = 0; i < tmp.length(); i++) + { + if (tmp.at(i).unicode() == 13) + tmp[i] = ' '; + if (tmp.at(i).unicode() == 10) + tmp[i] = '\n'; + } + if (tmp.contains(QChar( 0x1b ), Qt::CaseInsensitive)) + { + QSettings settings; + tmp.remove("[0m"); + if (settings.value("colorShellFiles").toBool()) + { + tmp2 = tmp.split(QChar( 0x1b ), QString::SkipEmptyParts, Qt::CaseInsensitive); + while (tmp2.size() > 0) + { + print = tmp2.takeFirst(); + if (print.contains("0;30"))//black + { +// this->ui->textShell->setTextColor(Qt::black); + this->ui->textShell->setTextColor(this->fontColor); + } + else if (print.contains("0;34"))//blue + { + this->ui->textShell->setTextColor(Qt::blue); + } + else if (print.contains("0;32"))//green + { + this->ui->textShell->setTextColor(Qt::green); + } + else if (print.contains("0;36"))//cyan + { + this->ui->textShell->setTextColor(Qt::cyan); + } + else if (print.contains("0;31"))//red + { + this->ui->textShell->setTextColor(Qt::red); + } + else if (print.contains("0;35"))//purple + { + this->ui->textShell->setTextColor(QColor::fromRgb(0, 0, 0)); + } + else if (print.contains("0;33"))//brown + { + this->ui->textShell->setTextColor(QColor::fromRgb(0, 0, 0)); + } + else if (print.contains("0;37"))//light gray + { + this->ui->textShell->setTextColor(Qt::lightGray); + } + else if (print.contains("1;30"))//dark gray + { + this->ui->textShell->setTextColor(Qt::darkGray); + } + else if (print.contains("[1;34"))//dark gray + { + this->ui->textShell->setTextColor(Qt::blue); + } + else if (print.contains("1;32"))//light green + { + this->ui->textShell->setTextColor(Qt::green); + } + else if (print.contains("1;36"))//light cyan + { + this->ui->textShell->setTextColor(Qt::cyan); + } + else if (print.contains("1;31"))//light red + { + this->ui->textShell->setTextColor(Qt::red); + } + else if (print.contains("1;35"))//light purple + { + this->ui->textShell->setTextColor(QColor::fromRgb(0, 0, 0)); + } + else if (print.contains("1;33"))//yellow + { + this->ui->textShell->setTextColor(Qt::yellow); + } + else if (print.contains("1;37"))//white + { + this->ui->textShell->setTextColor(Qt::white); + } + print.remove(QRegExp("\\[\\d;\\d+m")); + this->ui->textShell->insertPlainText(print); + this->ui->textShell->setTextColor(this->fontColor); + } + } + else + { + tmp.remove(QChar( 0x1b ), Qt::CaseInsensitive); + tmp.remove(QRegExp("\\[\\d;\\d+m")); + this->ui->textShell->insertPlainText(tmp); + } + } + else + { + this->ui->textShell->append(tmp); + } + + qDebug()<<"readShell() - "<procesShell,SIGNAL(readyRead()),this,SLOT(readShell())); + disconnect(this->procesShell, SIGNAL(finished(int)), this, SLOT(shellFinished())); +} + +void ShellWidget::writeShell() +{ + QString tmp; + + tmp = this->ui->editShell->text(); + if (!this->commandList.contains(tmp)) + this->commandList.append(tmp); + this->commandModel->setStringList(this->commandList); + tmp.append("\n"); + this->procesShell->write(tmp.toUtf8()); + + this->ui->editShell->clear(); +} +*/ diff --git a/widgets/shellwidget.h b/widgets/shellwidget.h index ddceca2..a27e886 100644 --- a/widgets/shellwidget.h +++ b/widgets/shellwidget.h @@ -31,6 +31,7 @@ class ShellWidget : public QTextEdit ~ShellWidget(); void setProcessPath(QString processPath); QString getProcessPath(); + void Refresh(); protected: void keyPressEvent(QKeyEvent *e); @@ -40,11 +41,10 @@ class ShellWidget : public QTextEdit int cursorPosition; QString command; QProcess process; - QString processPath; + QString processPath, sdk; QTextCursor cursor; QColor fontColor; - QString sdk; QStringList commandHistory; QStringList commands; @@ -80,7 +80,6 @@ class ShellWidget : public QWidget Ui::ShellWidget *ui; QProcess *procesShell; bool processShellIsRunning; - QString sdk; QCompleter *completer; QStringList commandList; QStringListModel *commandModel; diff --git a/zasoby.qrc b/zasoby.qrc index e6b5111..1548861 100644 --- a/zasoby.qrc +++ b/zasoby.qrc @@ -39,21 +39,6 @@ languages/qtadb_en.qm - languages/qtadb_pl.qm - languages/qtadb_el.qm - languages/qtadb_es.qm - languages/qtadb_it.qm - languages/qtadb_nl.qm - languages/qtadb_cs.qm - languages/qtadb_de.qm - languages/qtadb_hu.qm - languages/qtadb_sv.qm - languages/qtadb_ja.qm - languages/qtadb_ar.qm - languages/qtadb_ru.qm - languages/qtadb_pt.qm - languages/qtadb_sr.qm - languages/qtadb_zh.qm qml/messageView.qml