Added backup manager.

This commit is contained in:
codestation
2013-08-28 17:53:02 -04:30
parent 3530e28b43
commit b6b482046d
8 changed files with 51 additions and 10 deletions

View File

@@ -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 single songs (album, artist, title, cover art).
* Basic metadata for videos (duration, dimensions, thumbnail). * Basic metadata for videos (duration, dimensions, thumbnail).
* Basic metadata for photos (dimensions, thumbnails). * 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). * Easy wireless pairing (show PIN to the user when a Vita is detected).
* Ability to restart the connection if the Vita is reconnected. * 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. * Fix streaming for music.
## Planned features ## 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 * **DLNA bridge**: connect an existing DLNA server to interface with the Vita
using the wireless streaming feature. using the wireless streaming feature.

View File

@@ -15,11 +15,12 @@ public:
void start(); void start();
void stop(); void stop();
Database db;
private: private:
int thread_count; int thread_count;
QMutex mutex; QMutex mutex;
Database db;
QThread *usb_thread; QThread *usb_thread;
QThread *wireless_thread; QThread *wireless_thread;

View File

@@ -279,7 +279,7 @@ CMAObject *Database::pathToObjectInternal(const root_list &list, const char *pat
root_list::const_iterator skipped_first = ++list.begin(); root_list::const_iterator skipped_first = ++list.begin();
for(root_list::const_iterator obj = skipped_first; obj != list.end(); ++obj) { 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); return (*obj);
} }
} }

View File

@@ -99,6 +99,7 @@ void MainWidget::connectSignals()
connect(&manager, SIGNAL(deviceConnected(QString)), this, SLOT(receiveMessage(QString))); connect(&manager, SIGNAL(deviceConnected(QString)), this, SLOT(receiveMessage(QString)));
connect(&manager, SIGNAL(deviceConnected(QString)), this, SLOT(setTrayTooltip(QString))); connect(&manager, SIGNAL(deviceConnected(QString)), this, SLOT(setTrayTooltip(QString)));
connect(&manager, SIGNAL(deviceDisconnected()), this, SLOT(deviceDisconnect())); connect(&manager, SIGNAL(deviceDisconnected()), this, SLOT(deviceDisconnect()));
form.db = &manager.db;
} }
void MainWidget::setTrayTooltip(QString message) void MainWidget::setTrayTooltip(QString message)
@@ -106,19 +107,28 @@ void MainWidget::setTrayTooltip(QString message)
trayIcon->setToolTip(message); trayIcon->setToolTip(message);
} }
void MainWidget::openManager()
{
form.loadBackupListing(0);
form.show();
}
void MainWidget::createTrayIcon() void MainWidget::createTrayIcon()
{ {
options = new QAction(tr("&Settings"), this); options = new QAction(tr("&Settings"), this);
reload = new QAction(tr("&Refresh database"), this); reload = new QAction(tr("&Refresh database"), this);
backup = new QAction(tr("Backup Manager"), this);
quit = new QAction(tr("&Quit"), this); quit = new QAction(tr("&Quit"), this);
connect(options, SIGNAL(triggered()), &dialog, SLOT(open())); connect(options, SIGNAL(triggered()), &dialog, SLOT(open()));
connect(backup, SIGNAL(triggered()), this, SLOT(openManager()));
connect(reload, SIGNAL(triggered()), &manager, SLOT(refreshDatabase())); connect(reload, SIGNAL(triggered()), &manager, SLOT(refreshDatabase()));
connect(quit, SIGNAL(triggered()), this, SLOT(stopServer())); connect(quit, SIGNAL(triggered()), this, SLOT(stopServer()));
QMenu *trayIconMenu = new QMenu(this); QMenu *trayIconMenu = new QMenu(this);
trayIconMenu->addAction(options); trayIconMenu->addAction(options);
trayIconMenu->addAction(reload); trayIconMenu->addAction(reload);
trayIconMenu->addAction(backup);
trayIconMenu->addSeparator(); trayIconMenu->addSeparator();
trayIconMenu->addAction(quit); trayIconMenu->addAction(quit);

View File

@@ -22,6 +22,7 @@
#include "configwidget.h" #include "configwidget.h"
#include "clientmanager.h" #include "clientmanager.h"
#include "backupmanagerform.h"
#include "cmaclient.h" #include "cmaclient.h"
#include <QAction> #include <QAction>
@@ -46,10 +47,12 @@ private:
bool first_run; bool first_run;
ConfigWidget dialog; ConfigWidget dialog;
BackupManagerForm form;
QSystemTrayIcon *trayIcon; QSystemTrayIcon *trayIcon;
QAction *quit; QAction *quit;
QAction *reload; QAction *reload;
QAction *options; QAction *options;
QAction *backup;
ClientManager manager; ClientManager manager;
const static QStringList path_list; const static QStringList path_list;
@@ -60,6 +63,7 @@ private slots:
void setTrayTooltip(QString message); void setTrayTooltip(QString message);
void showPin(int pin); void showPin(int pin);
void stopServer(); void stopServer();
void openManager();
}; };
#endif // MAINWIDGET_H #endif // MAINWIDGET_H

View File

@@ -28,7 +28,10 @@ SOURCES += main.cpp \
cmabroadcast.cpp \ cmabroadcast.cpp \
avdecoder.cpp \ avdecoder.cpp \
cmaevent.cpp \ cmaevent.cpp \
clientmanager.cpp clientmanager.cpp \
backupmanagerform.cpp \
backupitem.cpp \
confirmdialog.cpp
HEADERS += \ HEADERS += \
capability.h \ capability.h \
@@ -45,7 +48,10 @@ HEADERS += \
cmabroadcast.h \ cmabroadcast.h \
avdecoder.h \ avdecoder.h \
cmaevent.h \ cmaevent.h \
clientmanager.h clientmanager.h \
backupmanagerform.h \
backupitem.h \
confirmdialog.h
CONFIG += link_pkgconfig CONFIG += link_pkgconfig
PKGCONFIG += libvitamtp libavformat libavcodec libavutil libswscale PKGCONFIG += libvitamtp libavformat libavcodec libavutil libswscale
@@ -61,6 +67,9 @@ OTHER_FILES += \
README.md README.md
FORMS += \ FORMS += \
configwidget.ui configwidget.ui \
backupmanagerform.ui \
backupitem.ui \
confirmdialog.ui

View File

@@ -155,3 +155,23 @@ QByteArray getThumbnail(const QString &path, DataType type, metadata_t *metadata
} }
return data; 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;
}

View File

@@ -48,5 +48,6 @@ public:
bool removeRecursively(const QString &dirName); bool removeRecursively(const QString &dirName);
bool getDiskSpace(const QString &dir, quint64 *free, quint64 *total); bool getDiskSpace(const QString &dir, quint64 *free, quint64 *total);
QByteArray getThumbnail(const QString &path, DataType type, metadata_t *metadata); QByteArray getThumbnail(const QString &path, DataType type, metadata_t *metadata);
QString readable_size(quint64 size, bool use_gib = false);
#endif // UTILS_H #endif // UTILS_H