From b6b482046d4c5bccebded3d460723e3cda36e8c4 Mon Sep 17 00:00:00 2001 From: codestation Date: Wed, 28 Aug 2013 17:53:02 -0430 Subject: [PATCH] Added backup manager. --- README.md | 6 +----- clientmanager.h | 3 ++- database.cpp | 2 +- mainwidget.cpp | 10 ++++++++++ mainwidget.h | 4 ++++ qcma.pro | 15 ++++++++++++--- utils.cpp | 20 ++++++++++++++++++++ utils.h | 1 + 8 files changed, 51 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index 2dde4cc..a932e10 100644 --- a/README.md +++ b/README.md @@ -15,6 +15,7 @@ official CMA and also offer some features missing in the original one. * Basic metadata for single songs (album, artist, title, cover art). * Basic metadata for videos (duration, dimensions, thumbnail). * Basic metadata for photos (dimensions, thumbnails). +* Simple backup browser: view and delete the backups on your PC without a Vita. * Easy wireless pairing (show PIN to the user when a Vita is detected). * Ability to restart the connection if the Vita is reconnected. @@ -24,11 +25,6 @@ official CMA and also offer some features missing in the original one. * Fix streaming for music. ## Planned features -* **Backup browser**: provide a human readable listing of the games saved on the -computer (name, icon, side on disk) and provide some actions (delete savedata, -patches or the whole game without need of the Vita). Also some sort of interface -to prepare VHBL homebrew in the folder of the exploited savedata. - * **DLNA bridge**: connect an existing DLNA server to interface with the Vita using the wireless streaming feature. diff --git a/clientmanager.h b/clientmanager.h index a718599..1e7602c 100644 --- a/clientmanager.h +++ b/clientmanager.h @@ -15,11 +15,12 @@ public: void start(); void stop(); + Database db; + private: int thread_count; QMutex mutex; - Database db; QThread *usb_thread; QThread *wireless_thread; diff --git a/database.cpp b/database.cpp index 0e42bed..ccb32c4 100644 --- a/database.cpp +++ b/database.cpp @@ -279,7 +279,7 @@ CMAObject *Database::pathToObjectInternal(const root_list &list, const char *pat root_list::const_iterator skipped_first = ++list.begin(); for(root_list::const_iterator obj = skipped_first; obj != list.end(); ++obj) { - if(strcmp(path, (*obj)->metadata.path) == 0) { + if(strcasecmp(path, (*obj)->metadata.path) == 0) { return (*obj); } } diff --git a/mainwidget.cpp b/mainwidget.cpp index b083339..10c98a1 100644 --- a/mainwidget.cpp +++ b/mainwidget.cpp @@ -99,6 +99,7 @@ void MainWidget::connectSignals() connect(&manager, SIGNAL(deviceConnected(QString)), this, SLOT(receiveMessage(QString))); connect(&manager, SIGNAL(deviceConnected(QString)), this, SLOT(setTrayTooltip(QString))); connect(&manager, SIGNAL(deviceDisconnected()), this, SLOT(deviceDisconnect())); + form.db = &manager.db; } void MainWidget::setTrayTooltip(QString message) @@ -106,19 +107,28 @@ void MainWidget::setTrayTooltip(QString message) trayIcon->setToolTip(message); } +void MainWidget::openManager() +{ + form.loadBackupListing(0); + form.show(); +} + void MainWidget::createTrayIcon() { options = new QAction(tr("&Settings"), this); reload = new QAction(tr("&Refresh database"), this); + backup = new QAction(tr("Backup Manager"), this); quit = new QAction(tr("&Quit"), this); connect(options, SIGNAL(triggered()), &dialog, SLOT(open())); + connect(backup, SIGNAL(triggered()), this, SLOT(openManager())); connect(reload, SIGNAL(triggered()), &manager, SLOT(refreshDatabase())); connect(quit, SIGNAL(triggered()), this, SLOT(stopServer())); QMenu *trayIconMenu = new QMenu(this); trayIconMenu->addAction(options); trayIconMenu->addAction(reload); + trayIconMenu->addAction(backup); trayIconMenu->addSeparator(); trayIconMenu->addAction(quit); diff --git a/mainwidget.h b/mainwidget.h index f52cb26..4c6f9af 100644 --- a/mainwidget.h +++ b/mainwidget.h @@ -22,6 +22,7 @@ #include "configwidget.h" #include "clientmanager.h" +#include "backupmanagerform.h" #include "cmaclient.h" #include @@ -46,10 +47,12 @@ private: bool first_run; ConfigWidget dialog; + BackupManagerForm form; QSystemTrayIcon *trayIcon; QAction *quit; QAction *reload; QAction *options; + QAction *backup; ClientManager manager; const static QStringList path_list; @@ -60,6 +63,7 @@ private slots: void setTrayTooltip(QString message); void showPin(int pin); void stopServer(); + void openManager(); }; #endif // MAINWIDGET_H diff --git a/qcma.pro b/qcma.pro index 99b2e8b..1b217cb 100644 --- a/qcma.pro +++ b/qcma.pro @@ -28,7 +28,10 @@ SOURCES += main.cpp \ cmabroadcast.cpp \ avdecoder.cpp \ cmaevent.cpp \ - clientmanager.cpp + clientmanager.cpp \ + backupmanagerform.cpp \ + backupitem.cpp \ + confirmdialog.cpp HEADERS += \ capability.h \ @@ -45,7 +48,10 @@ HEADERS += \ cmabroadcast.h \ avdecoder.h \ cmaevent.h \ - clientmanager.h + clientmanager.h \ + backupmanagerform.h \ + backupitem.h \ + confirmdialog.h CONFIG += link_pkgconfig PKGCONFIG += libvitamtp libavformat libavcodec libavutil libswscale @@ -61,6 +67,9 @@ OTHER_FILES += \ README.md FORMS += \ - configwidget.ui + configwidget.ui \ + backupmanagerform.ui \ + backupitem.ui \ + confirmdialog.ui diff --git a/utils.cpp b/utils.cpp index 8f14184..db134a4 100644 --- a/utils.cpp +++ b/utils.cpp @@ -155,3 +155,23 @@ QByteArray getThumbnail(const QString &path, DataType type, metadata_t *metadata } return data; } + +QString readable_size(quint64 size, bool use_gib) +{ + QStringList list; + list << "KiB" << "MiB"; + if(use_gib) { + list << "GiB"; + } + + QStringListIterator i(list); + QString unit("bytes"); + + float size_f = size; + + while(size_f >= 1024.0 && i.hasNext()) { + unit = i.next(); + size_f /= 1024.0; + } + return QString().setNum(size_f,'f',2) + " " + unit; +} diff --git a/utils.h b/utils.h index 4026ac0..b1614e7 100644 --- a/utils.h +++ b/utils.h @@ -48,5 +48,6 @@ public: bool removeRecursively(const QString &dirName); bool getDiskSpace(const QString &dir, quint64 *free, quint64 *total); QByteArray getThumbnail(const QString &path, DataType type, metadata_t *metadata); +QString readable_size(quint64 size, bool use_gib = false); #endif // UTILS_H