"
- "";
-
-BackupItem::BackupItem(QWidget *obj_parent) :
- QWidget(obj_parent),
- ui(new Ui::BackupItem)
-{
- ui->setupUi(this);
- // connect the buttons
- connect(ui->openButton, SIGNAL(clicked()), this, SLOT(openDirectory()));
- connect(ui->deleteButton, SIGNAL(clicked()), this, SLOT(removeEntry()));
-}
-
-BackupItem::~BackupItem()
-{
- delete ui;
-}
-
-void BackupItem::openDirectory()
-{
- QDesktopServices::openUrl(QUrl("file:///" + m_path));
-}
-
-void BackupItem::removeEntry()
-{
- emit deleteEntry(this);
-}
-
-const QPixmap *BackupItem::getIconPixmap()
-{
- return ui->itemPicture->pixmap();
-}
-
-void BackupItem::setDirectory(const QString &path)
-{
- m_path = path;
-}
-
-void BackupItem::setItemInfo(const QString &name, const QString &item_size, const QString &extra)
-{
- ui->gameLabel->setText(gameTemplate.arg(name));
- ui->sizeLabel->setText(sizeTemplate.arg(item_size));
- ui->infoLabel->setText(infoTemplate.arg(extra));
-}
-
-int BackupItem::getIconWidth()
-{
- return ui->itemPicture->width();
-}
-
-void BackupItem::setItemIcon(const QString &path, int item_width, bool try_dds)
-{
- ui->itemPicture->setMinimumWidth(item_width);
- QPixmap pixmap(path);
- if((pixmap.width() <= 0 || pixmap.height() <= 0) && try_dds) {
- QImage image;
- if(loadDDS(path, &image)) {
- pixmap = QPixmap::fromImage(image);
- }
- }
- ui->itemPicture->setPixmap(pixmap);
-}
-
-bool BackupItem::lessThan(const BackupItem *s1, const BackupItem *s2)
-{
- return s1->title.compare(s2->title) < 0;
-}
-
diff --git a/src/forms/backupitem.h b/src/forms/backupitem.h
deleted file mode 100644
index b68b5bb..0000000
--- a/src/forms/backupitem.h
+++ /dev/null
@@ -1,63 +0,0 @@
-/*
- * QCMA: Cross-platform content manager assistant for the PS Vita
- *
- * Copyright (C) 2013 Codestation
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
-
-#ifndef BACKUPITEM_H
-#define BACKUPITEM_H
-
-#include
-
-namespace Ui {
-class BackupItem;
-}
-
-class BackupItem : public QWidget
-{
- Q_OBJECT
-
-public:
- explicit BackupItem(QWidget *parent = 0);
- ~BackupItem();
-
- void setItemInfo(const QString &name, const QString &size, const QString &extra);
- void setItemIcon(const QString &m_path, int width = 48, bool try_dds = false);
- void setDirectory(const QString &m_path);
- const QPixmap *getIconPixmap();
- int getIconWidth();
-
- static bool lessThan(const BackupItem *s1, const BackupItem *s2);
-
- int ohfi;
- QString title;
-
-private:
- QString m_path;
- Ui::BackupItem *ui;
- static const QString gameTemplate;
- static const QString sizeTemplate;
- static const QString infoTemplate;
-
-signals:
- void deleteEntry(BackupItem *entry);
-
-private slots:
- void openDirectory();
- void removeEntry();
-};
-
-#endif // BACKUPITEM_H
diff --git a/src/forms/backupitem.ui b/src/forms/backupitem.ui
deleted file mode 100644
index 0197067..0000000
--- a/src/forms/backupitem.ui
+++ /dev/null
@@ -1,154 +0,0 @@
-
-
- BackupItem
-
-
-
- 0
- 0
- 638
- 75
-
-
-
-
- 0
- 0
-
-
-
-
-
-
-
-
-
-
-
-
- 48
- 48
-
-
-
-
- 0
- 48
-
-
-
-
-
-
- true
-
-
- Qt::AlignCenter
-
-
-
-
-
-
- 5
-
-
-
-
- <p><span style=" font-size:12pt; font-weight:600;">Game Name</span></p>
-
-
-
-
-
-
-
-
-
- 0
- 0
-
-
-
-
- 90
- 0
-
-
-
- <p><span style=" font-size:10pt;">0.00 GiB</span></p>
-
-
-
-
-
-
-
- 0
- 0
-
-
-
- <html><head/><body><p><span style=" font-size:9pt;">[APP] [SAVE] [UPDATE] [DLC]</span></p></body></html>
-
-
- Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter
-
-
-
-
-
-
-
-
-
-
- Qt::Horizontal
-
-
-
- 40
- 20
-
-
-
-
-
-
-
-
- 0
- 0
-
-
-
-
- 0
- 32
-
-
-
- Delete entry
-
-
-
-
-
-
-
- 0
- 32
-
-
-
- Open folder
-
-
-
-
-
-
-
-
-
-
diff --git a/src/forms/backupmanagerform.cpp b/src/forms/backupmanagerform.cpp
deleted file mode 100644
index 72dfeff..0000000
--- a/src/forms/backupmanagerform.cpp
+++ /dev/null
@@ -1,257 +0,0 @@
-/*
- * QCMA: Cross-platform content manager assistant for the PS Vita
- *
- * Copyright (C) 2013 Codestation
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
-
-#include "backupmanagerform.h"
-#include "ui_backupmanagerform.h"
-#include "cmaobject.h"
-#include "sforeader.h"
-#include "confirmdialog.h"
-#include "cmautils.h"
-#include "gui/filterlineedit.h"
-
-#include
-#include
-#include
-#include
-
-#include
-
-BackupManagerForm::BackupManagerForm(Database *db, QWidget *obj_parent) :
- QDialog(obj_parent), m_db(db),
- ui(new Ui::BackupManagerForm)
-{
- ui->setupUi(this);
- setupForm();
-}
-
-BackupManagerForm::~BackupManagerForm()
-{
- delete ui;
-}
-
-void BackupManagerForm::setupForm()
-{
- this->resize(800, 480);
- connect(ui->backupComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(loadBackupListing(int)));
- ui->tableWidget->setVerticalScrollMode(QAbstractItemView::ScrollPerPixel);
- ui->tableWidget->horizontalHeader()->hide();
-}
-
-void BackupManagerForm::removeEntry(BackupItem *item)
-{
- ConfirmDialog msgBox;
-
- msgBox.setMessageText(tr("Are you sure to remove the backup of the following entry?"), item->title);
- msgBox.setMessagePixmap(*item->getIconPixmap(), item->getIconWidth());
-
- if(msgBox.exec() == 0) {
- return;
- }
-
- QMutexLocker locker(&m_db->mutex);
-
- int parent_ohfi = m_db->getParentId(item->ohfi);
- removeRecursively(m_db->getAbsolutePath(item->ohfi));
- m_db->deleteEntry(item->ohfi);
-
- for(int i = 0; i < ui->tableWidget->rowCount(); ++i) {
- BackupItem *iter_item = static_cast(ui->tableWidget->cellWidget(i, 0));
- if(iter_item == item) {
- ui->tableWidget->removeRow(i);
- break;
- }
- }
-
- if(parent_ohfi > 0) {
- setBackupUsage(m_db->getObjectSize(parent_ohfi));
- }
-}
-
-void BackupManagerForm::setBackupUsage(qint64 usage_size)
-{
- ui->usageLabel->setText(tr("Backup disk usage: %1").arg(readable_size(usage_size, true)));
-}
-
-void BackupManagerForm::loadBackupListing(int index)
-{
- int ohfi;
- bool sys_dir;
- int img_width;
-
- //TODO: load all the accounts in the combobox
- ui->accountBox->clear();
- ui->accountBox->addItem(QSettings().value("lastOnlineId", tr("Default account")).toString());
-
- if(index < 0) {
- index = ui->backupComboBox->currentIndex();
- }
-
- ui->tableWidget->clear();
-
- switch(index) {
- case 0:
- ohfi = VITA_OHFI_VITAAPP;
- img_width = 48;
- sys_dir = true;
- break;
- case 1:
- ohfi = VITA_OHFI_PSPAPP;
- img_width = 80;
- sys_dir = true;
- break;
- case 2:
- ohfi = VITA_OHFI_PSMAPP;
- img_width = 48;
- sys_dir = true;
- break;
- case 3:
- ohfi = VITA_OHFI_PSXAPP;
- img_width = 48;
- sys_dir = true;
- break;
- case 4:
- ohfi = VITA_OHFI_PSPSAVE;
- img_width = 80;
- sys_dir = false;
- break;
- case 5:
- ohfi = VITA_OHFI_BACKUP;
- img_width = 48;
- sys_dir = false;
- break;
- default:
- ohfi = VITA_OHFI_VITAAPP;
- img_width = 48;
- sys_dir = true;
- }
-
- m_db->mutex.lock();
-
- // get the item list
- metadata_t *meta = NULL;
- int row_count = m_db->getObjectMetadatas(ohfi, &meta);
- ui->tableWidget->setRowCount(row_count);
-
- // exit if there aren't any items
- if(row_count == 0) {
- setBackupUsage(0);
- m_db->mutex.unlock();
- return;
- }
-
- // adjust the table item width to fill all the widget
- QHeaderView *vert_header = ui->tableWidget->verticalHeader();
- QHeaderView *horiz_header = ui->tableWidget->horizontalHeader();
-#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)
- horiz_header->setSectionResizeMode(QHeaderView::Stretch);
-#else
- horiz_header->setResizeMode(QHeaderView::Stretch);
-#endif
- qint64 backup_size = m_db->getObjectSize(ohfi);
- setBackupUsage(backup_size);
- QString path = m_db->getAbsolutePath(ohfi);
- QList item_list;
-
- metadata_t *first = meta;
- while(meta) {
- QString base_path = path + QDir::separator() + meta->name;
- QString parent_path = sys_dir ? base_path + QDir::separator() + "sce_sys" : base_path;
- SfoReader reader;
- QString game_name;
-
- // retrieve the game name from the SFO
- if(reader.load(QDir(parent_path).absoluteFilePath(sys_dir ? "param.sfo" : "PARAM.SFO"))) {
- game_name = QString::fromUtf8(reader.value("TITLE", meta->name));
- } else {
- game_name = QString(meta->name);
- }
-
- BackupItem *item = new BackupItem();
- // save the game title and ohfi for sorting/deleting
- item->ohfi = meta->ohfi;
- item->title = game_name;
-
- connect(item, SIGNAL(deleteEntry(BackupItem*)), this, SLOT(removeEntry(BackupItem*)));
-
- // show better size info for multi GiB backups
- bool use_gb = ohfi == VITA_OHFI_BACKUP && meta->size > 1024*1024*1024;
- QString read_size = readable_size(meta->size, use_gb);
-
- QString info;
-
- // check if is listing PS Vita games
- if(index == 0) {
- if(QDir(base_path + QDir::separator() + "app").exists()) {
- info.append(tr(" [GAME]"));
- }
- if(QDir(base_path + QDir::separator() + "savedata").exists()) {
- info.append(tr(" [SAVE]"));
- }
- if(QDir(base_path + QDir::separator() + "patch").exists()) {
- info.append(tr(" [UPDATE]"));
- }
- if(QDir(base_path + QDir::separator() + "addcont").exists()) {
- info.append(tr(" [DLC]"));
- }
- }
-
- item->setItemInfo(game_name, read_size, info);
- item->setItemIcon(QDir(parent_path).absoluteFilePath(sys_dir ? "icon0.png" : "ICON0.PNG"), img_width, ohfi == VITA_OHFI_PSMAPP);
- item->setDirectory(path + QDir::separator() + meta->name);
- item->resize(646, 68);
-
- item_list << item;
- meta = meta->next_metadata;
- }
-
- m_db->freeMetadata(first);
-
- qSort(item_list.begin(), item_list.end(), BackupItem::lessThan);
-
- int row;
- QList::iterator it;
- vert_header->setUpdatesEnabled(false);
-
- // insert the sorted items into the table
- for(it = item_list.begin(), row = 0; it != item_list.end(); ++it, ++row) {
- ui->tableWidget->setCellWidget(row, 0, *it);
- vert_header->resizeSection(row, 68);
- }
-
- vert_header->setUpdatesEnabled(true);
- m_db->mutex.unlock();
-
- // apply filter
- this->on_filterLineEdit_textChanged(ui->filterLineEdit->text());
-}
-
-void BackupManagerForm::on_filterLineEdit_textChanged(const QString &arg1)
-{
- if(arg1 != tr("Filter")) {
- for(int i = 0; i < ui->tableWidget->rowCount(); ++i) {
- BackupItem *item = (BackupItem*) ui->tableWidget->cellWidget(i, 0);
-
- if(item->title.contains(arg1, Qt::CaseInsensitive)) {
- ui->tableWidget->setRowHidden(i, false);
- } else {
- ui->tableWidget->setRowHidden(i, true);
- }
- }
- }
-}
diff --git a/src/forms/backupmanagerform.h b/src/forms/backupmanagerform.h
deleted file mode 100644
index 2613df3..0000000
--- a/src/forms/backupmanagerform.h
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
- * QCMA: Cross-platform content manager assistant for the PS Vita
- *
- * Copyright (C) 2013 Codestation
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
-
-#ifndef BACKUPMANAGERFORM_H
-#define BACKUPMANAGERFORM_H
-
-#include "database.h"
-#include "backupitem.h"
-
-#include
-
-namespace Ui {
-class BackupManagerForm;
-}
-
-class BackupManagerForm : public QDialog
-{
- Q_OBJECT
-
-public:
- explicit BackupManagerForm(Database *db, QWidget *parent = 0);
- ~BackupManagerForm();
-
- Database *m_db;
-
-private:
- void setupForm();
- void setBackupUsage(qint64 size);
-
- Ui::BackupManagerForm *ui;
-
-public slots:
- void loadBackupListing(int index);
- void removeEntry(BackupItem *item);
-private slots:
- void on_filterLineEdit_textChanged(const QString &arg1);
-};
-
-#endif // BACKUPMANAGERFORM_H
diff --git a/src/forms/backupmanagerform.ui b/src/forms/backupmanagerform.ui
deleted file mode 100644
index 20ef02c..0000000
--- a/src/forms/backupmanagerform.ui
+++ /dev/null
@@ -1,139 +0,0 @@
-
-
- BackupManagerForm
-
-
-
- 0
- 0
- 857
- 478
-
-
-
- Backup Manager
-
-
-
-
-
-
-
-
-
- Online ID / Username
-
-
-
-
-
-
-
-
-
-
-
- QFormLayout::AllNonFixedFieldsGrow
-
-
-
-
- Backup Type
-
-
- 2
-
-
-
-
-
-
-
- PS Vita Games
-
-
-
-
- PSP Games
-
-
-
-
- PSM Games
-
-
-
-
- PSOne Games
-
-
-
-
- PSP Savedatas
-
-
-
-
- Backups
-
-
-
-
-
-
-
-
-
-
-
- 1
-
-
-
-
-
-
-
-
-
- Backup disk usage
-
-
-
-
-
-
- Qt::Horizontal
-
-
-
- 40
- 20
-
-
-
-
-
-
-
- FilterLineEdit { color:gray; font-style:italic; }
-
-
- Filter
-
-
-
-
-
-
-
-
-
- FilterLineEdit
- QLineEdit
- gui/filterlineedit.h
-
-
-
-
-
diff --git a/src/forms/configwidget.cpp b/src/forms/configwidget.cpp
deleted file mode 100644
index b8833ec..0000000
--- a/src/forms/configwidget.cpp
+++ /dev/null
@@ -1,249 +0,0 @@
-/*
- * QCMA: Cross-platform content manager assistant for the PS Vita
- *
- * Copyright (C) 2013 Codestation
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
-
-#include "configwidget.h"
-#include "ui_configwidget.h"
-
-extern "C" {
-#include
-}
-
-#include
-#include
-
-#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)
-#include
-#else
-#include
-#define QStandardPaths QDesktopServices
-#define writableLocation storageLocation
-#endif
-
-ConfigWidget::ConfigWidget(QWidget *obj_parent) :
- QDialog(obj_parent),
- ui(new Ui::ConfigWidget)
-{
- ui->setupUi(this);
- connectSignals();
- setDefaultData();
-}
-
-void ConfigWidget::connectSignals()
-{
- QSignalMapper *mapper = new QSignalMapper(this);
- mapper->setMapping(ui->photoBtn, BTN_PHOTO);
- mapper->setMapping(ui->musicBtn, BTN_MUSIC);
- mapper->setMapping(ui->videoBtn, BTN_VIDEO);
- mapper->setMapping(ui->appBtn, BTN_APPS);
- mapper->setMapping(ui->urlBtn, BTN_URL);
- mapper->setMapping(ui->pkgBtn, BTN_PKG);
- connect(ui->photoBtn, SIGNAL(clicked()), mapper, SLOT(map()));
- connect(ui->musicBtn, SIGNAL(clicked()), mapper, SLOT(map()));
- connect(ui->videoBtn, SIGNAL(clicked()), mapper, SLOT(map()));
- connect(ui->appBtn, SIGNAL(clicked()), mapper, SLOT(map()));
- connect(ui->urlBtn, SIGNAL(clicked()), mapper, SLOT(map()));
- connect(ui->pkgBtn, SIGNAL(clicked()), mapper, SLOT(map()));
- connect(mapper, SIGNAL(mapped(int)), this, SLOT(browseBtnPressed(int)));
- connect(ui->buttonBox, SIGNAL(accepted()), this, SLOT(accept()));
- connect(ui->buttonBox, SIGNAL(rejected()), this, SLOT(reject()));
-
- connect(ui->protocolModeBox, SIGNAL(currentIndexChanged(int)), this, SLOT(protocolModeChanged(int)));
-}
-
-void ConfigWidget::protocolModeChanged(int index)
-{
- switch(index)
- {
- case 0:
- ui->protocolBox->setEnabled(false);
- ui->protocolEdit->setEnabled(false);
- break;
- case 1:
- ui->protocolBox->setEnabled(true);
- ui->protocolEdit->setEnabled(false);
- break;
- case 2:
- ui->protocolBox->setEnabled(false);
- ui->protocolEdit->setEnabled(true);
- break;
- default:
- ui->protocolBox->setEnabled(false);
- ui->protocolEdit->setEnabled(false);
- break;
- }
-
-}
-
-void ConfigWidget::setDefaultData()
-{
- QString defaultdir;
- QSettings settings;
- defaultdir = QStandardPaths::writableLocation(QStandardPaths::PicturesLocation);
- ui->photoPath->setText(QDir::toNativeSeparators(settings.value("photoPath", defaultdir).toString()));
-
- defaultdir = QStandardPaths::writableLocation(QStandardPaths::MusicLocation);
- ui->musicPath->setText(QDir::toNativeSeparators(settings.value("musicPath", defaultdir).toString()));
-
- defaultdir = QStandardPaths::writableLocation(QStandardPaths::MoviesLocation);
- ui->videoPath->setText(QDir::toNativeSeparators(settings.value("videoPath", defaultdir).toString()));
-
- defaultdir = QStandardPaths::writableLocation(QStandardPaths::HomeLocation);
- defaultdir.append(QDir::separator()).append("PS Vita");
- ui->appPath->setText(QDir::toNativeSeparators(settings.value("appsPath", defaultdir).toString()));
-
- defaultdir = QStandardPaths::writableLocation(QStandardPaths::HomeLocation);
- defaultdir.append(QDir::separator()).append("PSV Updates");
- ui->urlPath->setText(QDir::toNativeSeparators(settings.value("urlPath", defaultdir).toString()));
-
- defaultdir = QStandardPaths::writableLocation(QStandardPaths::HomeLocation);
- defaultdir.append(QDir::separator()).append("PSV Packages");
- ui->pkgPath->setText(QDir::toNativeSeparators(settings.value("pkgPath", defaultdir).toString()));
-
- ui->offlineCheck->setChecked(settings.value("offlineMode", true).toBool());
- ui->metadataCheck->setChecked(settings.value("skipMetadata", false).toBool());
- ui->usbCheck->setChecked(settings.value("disableUSB", false).toBool());
- ui->wifiCheck->setChecked(settings.value("disableWireless", false).toBool());
- ui->databaseSelect->setCurrentIndex(settings.value("useMemoryStorage", true).toBool() ? 0 : 1);
-
- ui->photoSkipCheck->setChecked(settings.value("photoSkip", false).toBool());
- ui->videoSkipCheck->setChecked(settings.value("videoSkip", false).toBool());
- ui->musicSkipCheck->setChecked(settings.value("musicSkip", false).toBool());
-
- QString protocol_mode = settings.value("protocolMode", "automatic").toString();
-
- if(protocol_mode == "manual")
- ui->protocolModeBox->setCurrentIndex(1);
- else if(protocol_mode == "custom")
- ui->protocolModeBox->setCurrentIndex(2);
- else
- ui->protocolModeBox->setCurrentIndex(0);
-
- protocolModeChanged(ui->protocolModeBox->currentIndex());
-
- ui->protocolBox->setCurrentIndex(settings.value("protocolIndex", 0).toInt());
-
- bool ok;
- int protocol_version = settings.value("protocolVersion", VITAMTP_PROTOCOL_MAX_VERSION).toInt(&ok);
-
- if(ok && protocol_version > 0)
- ui->protocolEdit->setText(QString::number(protocol_version));
- else
- ui->protocolEdit->setText(QString::number(VITAMTP_PROTOCOL_MAX_VERSION));
-}
-
-ConfigWidget::~ConfigWidget()
-{
- delete ui;
-}
-
-void ConfigWidget::browseBtnPressed(int btn)
-{
- QString msg;
- QLineEdit *lineedit;
-
- switch(btn) {
- case BTN_PHOTO:
- lineedit = ui->photoPath;
- msg = tr("Select the folder to be used as a photo source");
- break;
-
- case BTN_MUSIC:
- lineedit = ui->musicPath;
- msg = tr("Select the folder to be used as a music source");
- break;
-
- case BTN_VIDEO:
- lineedit = ui->videoPath;
- msg = tr("Select the folder to be used as a video source");
- break;
-
- case BTN_APPS:
- lineedit = ui->appPath;
- msg = tr("Select the folder to be used to save PS Vita games and backups");
- break;
-
- case BTN_URL:
- lineedit = ui->urlPath;
- msg = tr("Select the folder to be used to fetch software updates");
- break;
-
- case BTN_PKG:
- lineedit = ui->pkgPath;
- msg = tr("Select the folder to be used to software packages");
- break;
-
- default:
- return;
- }
-
- QString selected = QFileDialog::getExistingDirectory(this, msg, lineedit->text(), QFileDialog::ShowDirsOnly);
-
- if(!selected.isEmpty()) {
- lineedit->setText(QDir::toNativeSeparators((selected)));
- }
-}
-
-void ConfigWidget::savePath(QSettings &settings, const QLineEdit *edit, const QString &key)
-{
- QString path = edit->text();
- if(path.endsWith(QDir::separator())) {
- path.chop(1);
- }
- settings.setValue(key, QDir::fromNativeSeparators(path));
- QDir(QDir::root()).mkpath(path);
-}
-
-void ConfigWidget::accept()
-{
- QSettings settings;
- savePath(settings, ui->photoPath, "photoPath");
- savePath(settings, ui->musicPath, "musicPath");
- savePath(settings, ui->videoPath, "videoPath");
- savePath(settings, ui->appPath, "appsPath");
- savePath(settings, ui->urlPath, "urlPath");
- savePath(settings, ui->pkgPath, "pkgPath");
- settings.setValue("offlineMode", ui->offlineCheck->isChecked());
- settings.setValue("skipMetadata", ui->metadataCheck->isChecked());
- settings.setValue("disableUSB", ui->usbCheck->isChecked());
- settings.setValue("disableWireless", ui->wifiCheck->isChecked());
- settings.setValue("useMemoryStorage", ui->databaseSelect->currentIndex() == 0);
- settings.setValue("photoSkip", ui->photoSkipCheck->isChecked());
- settings.setValue("videoSkip", ui->videoSkipCheck->isChecked());
- settings.setValue("musicSkip", ui->musicSkipCheck->isChecked());
- settings.setValue("protocolIndex", ui->protocolBox->currentIndex());
-
- if(ui->protocolModeBox->currentIndex() == 0)
- settings.setValue("protocolMode", "automatic");
- else if(ui->protocolModeBox->currentIndex() == 1)
- settings.setValue("protocolMode", "manual");
- else if(ui->protocolModeBox->currentIndex() == 2)
- settings.setValue("protocolMode", "custom");
-
- bool ok;
- int protocol = ui->protocolEdit->text().toInt(&ok);
-
- if(ok && protocol > 0)
- settings.setValue("protocolVersion", protocol);
- else
- settings.setValue("protocolVersion", VITAMTP_PROTOCOL_MAX_VERSION);
-
- settings.sync();
-
- done(Accepted);
-}
diff --git a/src/forms/configwidget.h b/src/forms/configwidget.h
deleted file mode 100644
index 068c044..0000000
--- a/src/forms/configwidget.h
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
- * QCMA: Cross-platform content manager assistant for the PS Vita
- *
- * Copyright (C) 2013 Codestation
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
-
-#ifndef CONFIGWIDGET_H
-#define CONFIGWIDGET_H
-
-#include
-#include
-#include
-#include
-
-namespace Ui {
-class ConfigWidget;
-}
-
-class ConfigWidget : public QDialog
-{
- Q_OBJECT
-
-public:
- explicit ConfigWidget(QWidget *parent = 0);
- ~ConfigWidget();
-
-private:
- enum browse_buttons {BTN_PHOTO, BTN_MUSIC, BTN_VIDEO, BTN_APPS, BTN_URL, BTN_PKG};
-
- void connectSignals();
- void setDefaultData();
- void savePath(QSettings &settings, const QLineEdit *edit, const QString &key);
-
- Ui::ConfigWidget *ui;
-
-private slots:
- void protocolModeChanged(int index);
- void browseBtnPressed(int from);
- void accept();
-};
-
-#endif // CONFIGWIDGET_H
diff --git a/src/forms/configwidget.ui b/src/forms/configwidget.ui
deleted file mode 100644
index 917df70..0000000
--- a/src/forms/configwidget.ui
+++ /dev/null
@@ -1,525 +0,0 @@
-
-
- ConfigWidget
-
-
-
- 0
- 0
- 519
- 525
-
-
-
- QCMA Settings
-
-
-
-
-
-
-
- 0
-
-
-
- Folders
-
-
-
-
-
-
-
-
- 10
-
-
-
- Specify the folders that the PS Vita will access for each content type.
-
-
- true
-
-
-
-
-
-
-
-
- This is the location your Screenshots and Pictures are Saved to/Imported from.
-
-
- Photo Folder
-
-
-
-
-
-
-
-
- This is the location your Screenshots and Pictures are Saved to/Imported from.
-
-
- true
-
-
-
-
-
-
- Browse...
-
-
-
-
-
-
-
-
-
-
-
-
- This is the location your Videos are Saved to/Imported from.
-
-
- Video Folder
-
-
-
-
-
-
-
-
- This is the location your Videos are Saved to/Imported from.
-
-
- true
-
-
-
-
-
-
- Browse...
-
-
-
-
-
-
-
-
-
-
-
-
- This is the location your Music is Saved to/Imported from.
-
-
- Music Folder
-
-
-
-
-
-
-
-
- This is the location your Music is Saved to/Imported from.
-
-
- true
-
-
-
-
-
-
- Browse...
-
-
-
-
-
-
-
-
-
-
-
-
- This is the location your Games, Apps, Savegames, and System Backups are Saved to/Imported from.
-
-
- Applications / Backups
-
-
-
-
-
-
-
-
- This is the location your Games, Apps, Savegames, and System Backups are Saved to/Imported from.
-
-
- true
-
-
-
-
-
-
- Browse...
-
-
-
-
-
-
-
-
-
-
-
-
- This is the location your Software Updates and Browser Data is Saved to/Imported from.
-
-
- Updates / Web content
-
-
-
-
-
-
-
-
- This is the location your PS Vita system will read all the content that it tries to download.
-
-
- true
-
-
-
-
-
-
- Browse...
-
-
-
-
-
-
-
-
-
-
-
-
- Packages
-
-
-
-
-
-
-
-
-
-
-
- Browse...
-
-
-
-
-
-
-
-
- Qt::Vertical
-
-
-
- 20
- 40
-
-
-
-
-
-
-
-
-
-
-
-
- Other
-
-
-
-
-
-
-
- <html><head/><body><p align="center"><span style=" font-size:14pt; font-weight:600;">Advanced settings</span></p></body></html>
-
-
-
-
-
-
- Offline Mode
-
-
- true
-
-
-
-
-
-
- Skip metadata extraction
-
-
-
-
-
-
- Disable USB monitoring
-
-
-
-
-
-
- Disable Wi-Fi monitoring
-
-
-
-
-
-
- false
-
-
- Update database automatically when files on the PC are changed
-
-
-
-
-
-
- QFormLayout::AllNonFixedFieldsGrow
-
-
-
-
- Database backend
-
-
-
-
-
-
- false
-
-
-
- In Memory
-
-
-
-
- SQLite
-
-
-
-
-
-
-
-
-
- Skip photo scanning
-
-
-
-
-
-
- Skip video scanning
-
-
-
-
-
-
- Skip music scanning
-
-
-
-
-
-
-
-
-
- QFormLayout::AllNonFixedFieldsGrow
-
-
-
-
- CMA protocol version
-
-
- Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter
-
-
-
-
-
-
-
- 200
- 0
-
-
-
-
- FW 3.30 - 1900010
-
-
-
-
- FW 3.10 - 1800010
-
-
-
-
- FW 3.00 - 1700010
-
-
-
-
- FW 2.60 - 1600010
-
-
-
-
- FW 2.10 - 1500010
-
-
-
-
- FW 2.00 - 1400010
-
-
-
-
- FW 1.80 - 1300010
-
-
-
-
- FW 1.60 - 1200010
-
-
-
-
- FW 1.50 - 1100010
-
-
-
-
- FW 1.00 - 1000010
-
-
-
-
-
-
-
- 9999999
-
-
-
-
-
-
-
-
-
- CMA protocol selection
-
-
-
-
-
-
-
- Latest
-
-
-
-
- Manual
-
-
-
-
- Custom
-
-
-
-
-
-
-
- CMA custom version
-
-
-
-
-
-
-
-
- Qt::Vertical
-
-
-
- 20
- 40
-
-
-
-
-
-
-
-
-
-
-
-
-
- QDialogButtonBox::Cancel|QDialogButtonBox::Ok
-
-
-
-
-
-
-
-
-
-
diff --git a/src/forms/confirmdialog.cpp b/src/forms/confirmdialog.cpp
deleted file mode 100644
index ef77ed6..0000000
--- a/src/forms/confirmdialog.cpp
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- * QCMA: Cross-platform content manager assistant for the PS Vita
- *
- * Copyright (C) 2013 Codestation
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
-
-#include "confirmdialog.h"
-#include "ui_confirmdialog.h"
-
-const QString ConfirmDialog::messageTemplate = ""
- "
%1
"
- "
%2
"
- "";
-
-ConfirmDialog::ConfirmDialog(QWidget *obj_parent) :
- QDialog(obj_parent),
- ui(new Ui::ConfirmDialog)
-{
- ui->setupUi(this);
- this->layout()->setSizeConstraint(QLayout::SetFixedSize);
-}
-
-void ConfirmDialog::setMessageText(const QString message, const QString game_title)
-{
- ui->confirmText->setText(messageTemplate.arg(message, game_title));
-}
-
-void ConfirmDialog::setMessagePixmap(const QPixmap &pixmap, int dialog_width)
-{
- ui->itemPicture->setPixmap(pixmap);
- ui->itemPicture->setMinimumWidth(dialog_width);
-}
-
-ConfirmDialog::~ConfirmDialog()
-{
- delete ui;
-}
diff --git a/src/forms/confirmdialog.h b/src/forms/confirmdialog.h
deleted file mode 100644
index f9be667..0000000
--- a/src/forms/confirmdialog.h
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
- * QCMA: Cross-platform content manager assistant for the PS Vita
- *
- * Copyright (C) 2013 Codestation
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
-
-#ifndef CONFIRMDIALOG_H
-#define CONFIRMDIALOG_H
-
-#include
-
-namespace Ui {
-class ConfirmDialog;
-}
-
-class ConfirmDialog : public QDialog
-{
- Q_OBJECT
-
-public:
- explicit ConfirmDialog(QWidget *parent = 0);
- ~ConfirmDialog();
-
- void setMessageText(const QString message, const QString game_title);
- void setMessagePixmap(const QPixmap &pixmap, int width);
-
- static const QString messageTemplate;
-
-private:
- Ui::ConfirmDialog *ui;
-};
-
-#endif // CONFIRMDIALOG_H
diff --git a/src/forms/confirmdialog.ui b/src/forms/confirmdialog.ui
deleted file mode 100644
index 7eae756..0000000
--- a/src/forms/confirmdialog.ui
+++ /dev/null
@@ -1,120 +0,0 @@
-
-
- ConfirmDialog
-
-
-
- 0
- 0
- 519
- 106
-
-
-
- Confirmation Message
-
-
- true
-
-
-
-
-
-
-
-
- 48
- 48
-
-
-
-
- 0
- 48
-
-
-
-
-
-
- true
-
-
-
-
-
-
- Qt::Horizontal
-
-
- QSizePolicy::Fixed
-
-
-
- 10
- 0
-
-
-
-
-
-
-
- <html><head/><body><p><span style=" font-size:10pt;">Are you sure to delete the backup of the following game?</span></p><p><span style=" font-size:12pt; font-weight:600;">Game Name</span></p></body></html>
-
-
-
- 0
-
-
-
-
-
-
-
-
- Qt::Horizontal
-
-
- QDialogButtonBox::Cancel|QDialogButtonBox::Ok
-
-
-
-
-
-
-
-
- buttonBox
- accepted()
- ConfirmDialog
- accept()
-
-
- 248
- 254
-
-
- 157
- 274
-
-
-
-
- buttonBox
- rejected()
- ConfirmDialog
- reject()
-
-
- 316
- 260
-
-
- 286
- 274
-
-
-
-
-
diff --git a/src/forms/pinform.cpp b/src/forms/pinform.cpp
deleted file mode 100644
index 85eeb8a..0000000
--- a/src/forms/pinform.cpp
+++ /dev/null
@@ -1,71 +0,0 @@
-/*
- * QCMA: Cross-platform content manager assistant for the PS Vita
- *
- * Copyright (C) 2013 Codestation
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
-
-#include "pinform.h"
-#include "ui_pinform.h"
-
-#include
-#include
-
-const QString PinForm::pinFormat =
- ""
- "
%1
"
- "";
-
-PinForm::PinForm(QWidget *obj_parent) :
- QWidget(obj_parent),
- ui(new Ui::PinForm)
-{
- ui->setupUi(this);
- move(QApplication::desktop()->screen()->rect().center() - rect().center());
- setFixedSize(size());
- setWindowFlags(Qt::CustomizeWindowHint | Qt::WindowTitleHint);
- connect(ui->cancelButton, SIGNAL(clicked()), this, SLOT(hide()));
-}
-
-void PinForm::setPin(QString name, int pin)
-{
- qDebug() << "Got pin from user " << name;
- ui->deviceLabel->setText(tr("Device: %1 (PS Vita)").arg(name));
- ui->pinLabel->setText(pinFormat.arg(QString::number(pin), 8, QChar('0')));
- show();
-}
-
-void PinForm::startCountdown()
-{
- timer.setInterval(1000);
- counter = 300;
- connect(&timer, SIGNAL(timeout()), this, SLOT(decreaseTimer()));
- timer.start();
-}
-
-void PinForm::decreaseTimer()
-{
- counter--;
- if(counter == 0) {
- timer.stop();
- hide();
- }
- ui->timeLabel->setText(tr("Time remaining: %1 seconds").arg(counter));
-}
-
-PinForm::~PinForm()
-{
- delete ui;
-}
diff --git a/src/forms/pinform.h b/src/forms/pinform.h
deleted file mode 100644
index 0b534c9..0000000
--- a/src/forms/pinform.h
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
- * QCMA: Cross-platform content manager assistant for the PS Vita
- *
- * Copyright (C) 2013 Codestation
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
-
-#ifndef PINFORM_H
-#define PINFORM_H
-
-#include
-#include
-
-namespace Ui {
-class PinForm;
-}
-
-class PinForm : public QWidget
-{
- Q_OBJECT
-
-public:
- explicit PinForm(QWidget *parent = 0);
- ~PinForm();
-
-private:
- Ui::PinForm *ui;
-
- // pin timeout
- int counter;
- QTimer timer;
-
- static const QString pinFormat;
-
-public slots:
- void startCountdown();
- void setPin(QString name, int pin);
-
-private slots:
- void decreaseTimer();
-};
-
-#endif // PINFORM_H
diff --git a/src/forms/pinform.ui b/src/forms/pinform.ui
deleted file mode 100644
index c10e74b..0000000
--- a/src/forms/pinform.ui
+++ /dev/null
@@ -1,115 +0,0 @@
-
-
- PinForm
-
-
- Qt::ApplicationModal
-
-
-
- 0
- 0
- 526
- 216
-
-
-
- Device pairing
-
-
-
-
-
-
-
- An unregistered PS Vita system is connecting with QCMA via Wi-Fi
-
-
- Qt::AlignCenter
-
-
-
-
-
-
- Device: PS Vita
-
-
- Qt::AlignCenter
-
-
-
-
-
-
- Input the following number in the PS Vita system to register it with QCMA
-
-
- Qt::AlignCenter
-
-
-
-
-
-
- <html><head/><body><p><span style=" font-size:24pt; font-weight:600;">12345678</span></p></body></html>
-
-
- Qt::AlignCenter
-
-
-
-
-
-
- Time remaining: 300 seconds
-
-
- Qt::AlignCenter
-
-
-
-
-
-
-
-
- Qt::Horizontal
-
-
-
- 40
- 20
-
-
-
-
-
-
-
- Cancel
-
-
-
-
-
-
- Qt::Horizontal
-
-
-
- 40
- 20
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/src/forms/progressform.cpp b/src/forms/progressform.cpp
deleted file mode 100644
index 5ecac28..0000000
--- a/src/forms/progressform.cpp
+++ /dev/null
@@ -1,77 +0,0 @@
-/*
- * QCMA: Cross-platform content manager assistant for the PS Vita
- *
- * Copyright (C) 2013 Codestation
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
-
-#include "progressform.h"
-#include "ui_progressform.h"
-
-#include
-#include
-
-ProgressForm::ProgressForm(QWidget *obj_parent) :
- QWidget(obj_parent),
- ui(new Ui::ProgressForm)
-{
- ui->setupUi(this);
- move(QApplication::desktop()->screen()->rect().center() - rect().center());
- setFixedSize(size());
- setWindowFlags(Qt::CustomizeWindowHint | Qt::WindowTitleHint);
- connect(ui->cancelButton, SIGNAL(clicked()), this, SLOT(cancelConfirm()));
-}
-
-ProgressForm::~ProgressForm()
-{
- delete ui;
-}
-
-void ProgressForm::cancelConfirm()
-{
- QMessageBox box;
- box.setText(tr("Database indexing in progress"));
- box.setInformativeText(tr("Are you sure to cancel the database indexing?"));
- box.setIcon(QMessageBox::Warning);
- box.setStandardButtons(QMessageBox::Ok | QMessageBox::Cancel);
- if(box.exec() == QMessageBox::Ok) {
- emit canceled();
- }
-}
-
-void ProgressForm::setFileName(QString file)
-{
- QString elided = ui->fileLabel->fontMetrics().elidedText(file, Qt::ElideMiddle, ui->fileLabel->width(), 0);
- ui->fileLabel->setText(elided);
-}
-
-void ProgressForm::setDirectoryName(QString dir)
-{
- QString elided = ui->directoryLabel->fontMetrics().elidedText(dir, Qt::ElideMiddle, ui->directoryLabel->width(), 0);
- ui->directoryLabel->setText(elided);
-}
-
-void ProgressForm::showDelayed(int msec)
-{
- timer.setSingleShot(true);
- timer.setInterval(msec);
- connect(&timer, SIGNAL(timeout()), this, SLOT(show()));
- timer.start();
-}
-
-void ProgressForm::interruptShow()
-{
- timer.stop();
-}
diff --git a/src/forms/progressform.h b/src/forms/progressform.h
deleted file mode 100644
index 12fc292..0000000
--- a/src/forms/progressform.h
+++ /dev/null
@@ -1,57 +0,0 @@
-/*
- * QCMA: Cross-platform content manager assistant for the PS Vita
- *
- * Copyright (C) 2013 Codestation
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
-
-#ifndef PROGRESSFORM_H
-#define PROGRESSFORM_H
-
-#include
-#include
-
-namespace Ui {
-class ProgressForm;
-}
-
-class ProgressForm : public QWidget
-{
- Q_OBJECT
-
-public:
- explicit ProgressForm(QWidget *parent = 0);
- ~ProgressForm();
-
- void showDelayed(int msec = 1000);
- void interruptShow();
-
-private:
- Ui::ProgressForm *ui;
-
- QTimer timer;
-
-signals:
- void canceled();
-
-private slots:
- void cancelConfirm();
-
-public slots:
- void setDirectoryName(QString dir);
- void setFileName(QString file);
-};
-
-#endif // PROGRESSFORM_H
diff --git a/src/forms/progressform.ui b/src/forms/progressform.ui
deleted file mode 100644
index 1138f36..0000000
--- a/src/forms/progressform.ui
+++ /dev/null
@@ -1,80 +0,0 @@
-
-
- ProgressForm
-
-
- Qt::ApplicationModal
-
-
-
- 0
- 0
- 602
- 138
-
-
-
- Refreshing database...
-
-
-
-
-
-
-
- <html><head/><body><p><span style=" font-size:11pt; font-weight:600;">Reading directory:</span></p></body></html>
-
-
-
-
-
-
- directory name
-
-
-
-
-
-
- <html><head/><body><p><span style=" font-size:11pt; font-weight:600;">Processing file:</span></p></body></html>
-
-
-
-
-
-
- file name
-
-
-
-
-
-
-
-
- Qt::Horizontal
-
-
-
- 40
- 20
-
-
-
-
-
-
-
- Cancel
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/src/gui/clientmanager.cpp b/src/gui/clientmanager.cpp
deleted file mode 100644
index 4d50aca..0000000
--- a/src/gui/clientmanager.cpp
+++ /dev/null
@@ -1,214 +0,0 @@
-/*
- * QCMA: Cross-platform content manager assistant for the PS Vita
- *
- * Copyright (C) 2013 Codestation
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
-
-#include "clientmanager.h"
-#include "cmaclient.h"
-#include "cmautils.h"
-#include "forms/progressform.h"
-
-#include
-
-#include
-
-#ifdef Q_OS_UNIX
-#include
-#include
-
-int ClientManager::sighup_fd[2];
-int ClientManager::sigterm_fd[2];
-#endif
-
-ClientManager::ClientManager(Database *db, QObject *obj_parent) :
- QObject(obj_parent), m_db(db)
-{
-#ifdef Q_OS_UNIX
- if (::socketpair(AF_UNIX, SOCK_STREAM, 0, sighup_fd))
- qFatal("Couldn't create HUP socketpair");
-
- if (::socketpair(AF_UNIX, SOCK_STREAM, 0, sigterm_fd))
- qFatal("Couldn't create TERM socketpair");
-
- sn_hup = new QSocketNotifier(sighup_fd[1], QSocketNotifier::Read, this);
- connect(sn_hup, SIGNAL(activated(int)), this, SLOT(handleSigHup()));
- sn_term = new QSocketNotifier(sigterm_fd[1], QSocketNotifier::Read, this);
- connect(sn_term, SIGNAL(activated(int)), this, SLOT(handleSigTerm()));
-#endif
-}
-
-ClientManager::~ClientManager()
-{
- VitaMTP_Cleanup();
-}
-
-void ClientManager::databaseUpdated(int count)
-{
- progress.interruptShow();
- progress.hide();
- if(count >= 0) {
- emit messageSent(tr("Added %1 items to the database").arg(count));
- } else {
- emit messageSent(tr("Database indexing aborted by user"));
- }
- emit updated(count);
-}
-
-void ClientManager::showPinDialog(QString name, int pin)
-{
- pinForm.setPin(name, pin);
- pinForm.startCountdown();
-}
-
-void ClientManager::start()
-{
- if(VitaMTP_Init() < 0) {
- emit messageSent(tr("Cannot initialize VitaMTP library"));
- return;
- }
-
- // initializing database for the first use
- refreshDatabase();
-
- connect(m_db, SIGNAL(fileAdded(QString)), &progress, SLOT(setFileName(QString)));
- connect(m_db, SIGNAL(directoryAdded(QString)), &progress, SLOT(setDirectoryName(QString)));
- connect(m_db, SIGNAL(updated(int)), this, SLOT(databaseUpdated(int)));
- connect(&progress, SIGNAL(canceled()), m_db, SLOT(cancelOperation()), Qt::DirectConnection);
-
- thread_count = 0;
- qDebug("Starting cma threads");
- CmaClient *client;
- QSettings settings;
-
- if(!settings.value("disableUSB", false).toBool()) {
-
-#ifdef Q_OS_LINUX
- if(!belongsToGroup("vitamtp"))
- emit messageSent(tr("This user doesn't belong to the vitamtp group, there could be a problem while reading the USB bus."));
-#endif
-
- usb_thread = new QThread();
- client = new CmaClient(m_db);
- usb_thread->setObjectName("usb_thread");
- connect(usb_thread, SIGNAL(started()), client, SLOT(connectUsb()));
- connect(client, SIGNAL(messageSent(QString)), this, SIGNAL(messageSent(QString)));
- connect(client, SIGNAL(finished()), usb_thread, SLOT(quit()), Qt::DirectConnection);
- connect(usb_thread, SIGNAL(finished()), usb_thread, SLOT(deleteLater()));
- connect(usb_thread, SIGNAL(finished()), this, SLOT(threadStopped()));
- connect(usb_thread, SIGNAL(finished()), client, SLOT(deleteLater()));
-
- connect(client, SIGNAL(deviceConnected(QString)), this, SIGNAL(deviceConnected(QString)));
- connect(client, SIGNAL(deviceDisconnected()), this, SIGNAL(deviceDisconnected()));
- connect(client, SIGNAL(refreshDatabase()), this, SLOT(refreshDatabase()));
-
- client->moveToThread(usb_thread);
- usb_thread->start();
- thread_count++;
- }
-
- if(!settings.value("disableWireless", false).toBool()) {
- CmaBroadcast *broadcast = new CmaBroadcast(this);
- wireless_thread = new QThread();
- client = new CmaClient(m_db, broadcast);
- wireless_thread->setObjectName("wireless_thread");
- connect(wireless_thread, SIGNAL(started()), client, SLOT(connectWireless()));
- connect(client, SIGNAL(messageSent(QString)), this, SIGNAL(messageSent(QString)));
- connect(client, SIGNAL(receivedPin(QString,int)), this, SLOT(showPinDialog(QString,int)));
- connect(client, SIGNAL(finished()), wireless_thread, SLOT(quit()), Qt::DirectConnection);
- connect(wireless_thread, SIGNAL(finished()), wireless_thread, SLOT(deleteLater()));
- connect(wireless_thread, SIGNAL(finished()), this, SLOT(threadStopped()));
- connect(wireless_thread, SIGNAL(finished()), client, SLOT(deleteLater()));
-
- connect(client, SIGNAL(pinComplete()), &pinForm, SLOT(hide()));
- connect(client, SIGNAL(deviceConnected(QString)), this, SIGNAL(deviceConnected(QString)));
- connect(client, SIGNAL(deviceDisconnected()), this, SIGNAL(deviceDisconnected()));
- connect(client, SIGNAL(refreshDatabase()), this, SLOT(refreshDatabase()));
-
- client->moveToThread(wireless_thread);
- wireless_thread->start();
- thread_count++;
- }
-
- if(thread_count == 0) {
- emit messageSent(tr("You must enable at least USB or Wireless monitoring"));
- }
-}
-
-void ClientManager::refreshDatabase()
-{
- if(m_db->load()) {
- return;
- }
-
- if(!m_db->rescan()) {
- emit messageSent(tr("No PS Vita system has been registered"));
- } else {
- progress.showDelayed(1000);
- }
-}
-
-void ClientManager::stop()
-{
- if(CmaClient::stop() < 0) {
- emit stopped();
- }
-}
-
-void ClientManager::threadStopped()
-{
- mutex.lock();
- if(--thread_count == 0) {
- emit stopped();
- }
- mutex.unlock();
-}
-
-#ifdef Q_OS_UNIX
-void ClientManager::hupSignalHandler(int)
-{
- char a = 1;
- ::write(sighup_fd[0], &a, sizeof(a));
-}
-
-void ClientManager::termSignalHandler(int)
-{
- char a = 1;
- ::write(sigterm_fd[0], &a, sizeof(a));
-}
-
-void ClientManager::handleSigTerm()
-{
- sn_term->setEnabled(false);
- char tmp;
- ::read(sigterm_fd[1], &tmp, sizeof(tmp));
-
- stop();
-
- sn_term->setEnabled(true);
-}
-
-void ClientManager::handleSigHup()
-{
- sn_hup->setEnabled(false);
- char tmp;
- ::read(sighup_fd[1], &tmp, sizeof(tmp));
-
- refreshDatabase();
-
- sn_hup->setEnabled(true);
-}
-#endif
diff --git a/src/gui/clientmanager.h b/src/gui/clientmanager.h
deleted file mode 100644
index 07acee1..0000000
--- a/src/gui/clientmanager.h
+++ /dev/null
@@ -1,94 +0,0 @@
-/*
- * QCMA: Cross-platform content manager assistant for the PS Vita
- *
- * Copyright (C) 2013 Codestation
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
-
-#ifndef CLIENTMANAGER_H
-#define CLIENTMANAGER_H
-
-#include "database.h"
-#include "forms/pinform.h"
-#include "forms/progressform.h"
-
-#include
-#include
-
-#ifdef Q_OS_UNIX
-#include
-#endif
-
-class ClientManager : public QObject
-{
- Q_OBJECT
-public:
- explicit ClientManager(Database *db, QObject *parent = 0);
- ~ClientManager();
-
- void start();
- void stop();
-
-#ifdef Q_OS_UNIX
- // unix signal handlers
- static void hupSignalHandler(int);
- static void termSignalHandler(int);
-#endif
-
-private:
- int thread_count;
- QMutex mutex;
-
- Database *m_db;
-
- PinForm pinForm;
- ProgressForm progress;
-
- QThread *usb_thread;
- QThread *wireless_thread;
-
-#ifdef Q_OS_UNIX
- // signal handling
- static int sighup_fd[2];
- static int sigterm_fd[2];
-
- QSocketNotifier *sn_hup;
- QSocketNotifier *sn_term;
-#endif
-
-signals:
- void updated(int);
- void stopped();
- void receivedPin(int);
- void deviceDisconnected();
- void messageSent(QString);
- void deviceConnected(QString);
-
-public slots:
- void refreshDatabase();
-
-#ifdef Q_OS_UNIX
- // Qt signal handlers
- void handleSigHup();
- void handleSigTerm();
-#endif
-
-private slots:
- void threadStopped();
- void databaseUpdated(int count);
- void showPinDialog(QString name, int pin);
-};
-
-#endif // CLIENTMANAGER_H
diff --git a/src/gui/filterlineedit.cpp b/src/gui/filterlineedit.cpp
deleted file mode 100644
index a396bab..0000000
--- a/src/gui/filterlineedit.cpp
+++ /dev/null
@@ -1,89 +0,0 @@
-/*
- * QCMA: Cross-platform content manager assistant for the PS Vita
- *
- * Copyright (C) 2013 Xian Nox
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
-
-#include "filterlineedit.h"
-
-#include
-#include
-
-FilterLineEdit::FilterLineEdit(QWidget *obj_parent) :
- QLineEdit(obj_parent)
-{
- int frame_width = frameWidth();
- clearButton = new QToolButton(this);
- QIcon clearIcon(":/main/resources/images/edit-clear-locationbar-rtl.png");
- clearButton->setIcon(clearIcon);
- clearButton->setIconSize(QSize(sizeHint().height() - 4 * frame_width,
- sizeHint().height() - 4 * frame_width));
- clearButton->setCursor(Qt::ArrowCursor);
- clearButton->setStyleSheet("QToolButton { border:none; padding:0px; }");
- clearButton->hide();
- connect(clearButton, SIGNAL(clicked()), this, SLOT(clear()));
- connect(this, SIGNAL(textChanged(const QString&)), this, SLOT(updateCloseButton(const QString&)));
-
- setStyleSheet(QString("LineEdit { color:black; font-style:normal; padding-right:%1px; }").arg(
- clearButton->sizeHint().width() + frame_width + 1));
-
- QSize min_size_hint = minimumSizeHint();
- setMinimumSize(qMax(min_size_hint.width(), clearButton->sizeHint().height() + frame_width),
- qMax(min_size_hint.height(), clearButton->sizeHint().height() + frame_width));
-}
-
-void FilterLineEdit::updateCloseButton(const QString& filter_text)
-{
- if(filter_text.isEmpty() || filter_text == tr("Filter")) {
- clearButton->setVisible(false);
- } else {
- clearButton->setVisible(true);
- }
-}
-
-void FilterLineEdit::focusInEvent(QFocusEvent *e)
-{
- if(this->styleSheet() == "FilterLineEdit { color:gray; font-style:italic; }") {
- this->clear();
- }
-
- setStyleSheet(QString("FilterLineEdit { color:black; font-style:normal; padding-right:%1px; }").arg(clearButton->sizeHint().width() + frameWidth() + 1));
-
- QLineEdit::focusInEvent(e);
-}
-
-void FilterLineEdit::focusOutEvent(QFocusEvent *e)
-{
- if(this->text().isEmpty()) {
- this->setText(tr("Filter"));
- this->setStyleSheet("FilterLineEdit { color:gray; font-style:italic; }");
- }
-
- QLineEdit::focusOutEvent(e);
-}
-
-int FilterLineEdit::frameWidth() const
-{
- return style()->pixelMetric(QStyle::PM_DefaultFrameWidth, 0, this);
-}
-
-void FilterLineEdit::resizeEvent(QResizeEvent *e)
-{
- QSize sz = clearButton->sizeHint();
- clearButton->move(rect().right() - sz.width(), rect().bottom() - sz.height() + frameWidth());
-
- QLineEdit::resizeEvent(e);
-}
diff --git a/src/gui/filterlineedit.h b/src/gui/filterlineedit.h
deleted file mode 100644
index c576829..0000000
--- a/src/gui/filterlineedit.h
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- * QCMA: Cross-platform content manager assistant for the PS Vita
- *
- * Copyright (C) 2013 Xian Nox
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
-
-#ifndef FILTERLINEEDIT_H
-#define FILTERLINEEDIT_H
-
-#include
-#include
-
-class FilterLineEdit : public QLineEdit
-{
- Q_OBJECT
-
-public:
- explicit FilterLineEdit(QWidget *parent = 0);
-
-protected:
- void focusInEvent(QFocusEvent *e);
- void focusOutEvent(QFocusEvent *e);
- void resizeEvent(QResizeEvent *e);
- int frameWidth() const;
-
-private:
- QToolButton *clearButton;
-
-private slots:
- void updateCloseButton(const QString &text);
-
-};
-
-#endif // FILTERLINEEDIT_H
diff --git a/src/gui/main.cpp b/src/gui/main.cpp
deleted file mode 100644
index cf29db4..0000000
--- a/src/gui/main.cpp
+++ /dev/null
@@ -1,152 +0,0 @@
-/*
- * QCMA: Cross-platform content manager assistant for the PS Vita
- *
- * Copyright (C) 2013 Codestation
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
-
-#ifndef Q_OS_WIN32
-#include
-#endif
-
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-
-#include
-
-#include "singleapplication.h"
-#include "mainwidget.h"
-
-#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)
-static void noMessageOutput(QtMsgType type, const QMessageLogContext &, const QString & str)
-{
- const char * msg = str.toStdString().c_str();
-#else
-static void noMessageOutput(QtMsgType type, const char *msg)
-{
-#endif
- Q_UNUSED(type);
- Q_UNUSED(msg);
-}
-
-
-static bool setup_handlers()
-{
- struct sigaction hup, term;
-
- hup.sa_handler = ClientManager::hupSignalHandler;
- sigemptyset(&hup.sa_mask);
- hup.sa_flags = 0;
- hup.sa_flags |= SA_RESTART;
-
- if (sigaction(SIGHUP, &hup, NULL) != 0) {
- qCritical("SIGHUP signal handle failed");
- return false;
- }
-
- term.sa_handler = ClientManager::termSignalHandler;
- sigemptyset(&term.sa_mask);
- term.sa_flags |= SA_RESTART;
-
- if (sigaction(SIGTERM, &term, NULL) != 0) {
- qCritical("SIGTERM signal handle failed");
- return false;
- }
-
- return true;
-}
-
-int main(int argc, char *argv[])
-{
- if(SingleApplication::sendMessage(QObject::tr("An instance of Qcma is already running"))) {
- return 0;
- }
-
- SingleApplication app(argc, argv);
-
-#ifndef Q_OS_WIN32
- // FIXME: libmtp sends SIGPIPE if a socket write fails crashing the whole app
- // the proper fix is to libmtp to handle the cancel properly or ignoring
- // SIGPIPE on the socket
- signal(SIGPIPE, SIG_IGN);
-#endif
-
- setup_handlers();
-
- if(app.arguments().contains("--with-debug")) {
- VitaMTP_Set_Logging(VitaMTP_DEBUG);
- } else if(app.arguments().contains("--verbose")) {
- VitaMTP_Set_Logging(VitaMTP_VERBOSE);
- } else {
- VitaMTP_Set_Logging(VitaMTP_NONE);
-#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)
- qInstallMessageHandler(noMessageOutput);
-#else
- qInstallMsgHandler(noMessageOutput);
-#endif
- }
-
-#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0)
- QTextCodec::setCodecForCStrings(QTextCodec::codecForName("UTF-8"));
-#endif
-
- QTextStream(stdout) << "Starting Qcma " << QCMA_VER << endl;
-
- QTranslator translator;
- QString locale = QLocale().system().name();
- qDebug() << "Current locale:" << locale;
-
- if(app.arguments().contains("--set-locale")) {
- int index = app.arguments().indexOf("--set-locale");
- if(index + 1 < app.arguments().length()) {
- qDebug("Enforcing locale: %s", app.arguments().at(index + 1).toUtf8().data());
- locale = app.arguments().at(index + 1);
- }
- }
-
- if(translator.load("qcma_" + locale, ":/resources/translations")) {
- app.installTranslator(&translator);
- } else {
- qWarning() << "Cannot load translation for locale:" << locale;
- }
-
- QTranslator system_translator;
- system_translator.load("qt_" + locale, QLibraryInfo::location(QLibraryInfo::TranslationsPath));
- app.installTranslator(&system_translator);
-
- qDebug("Starting main thread: 0x%016" PRIxPTR, (uintptr_t)QThread::currentThreadId());
-
- // set the organization/application for QSettings to work properly
- app.setOrganizationName("codestation");
- app.setApplicationName("qcma");
-
- //TODO: check if this is actually needed since we don't have a main window by default
- QApplication::setQuitOnLastWindowClosed(false);
-
- bool showSystray = !app.arguments().contains("--no-systray");
-
- MainWidget widget;
- widget.prepareApplication(showSystray);
-
- // receive the message from another process
- QObject::connect(&app, SIGNAL(messageAvailable(QString)), &widget, SLOT(receiveMessage(QString)));
-
- return app.exec();
-}
diff --git a/src/gui/mainwidget.cpp b/src/gui/mainwidget.cpp
deleted file mode 100644
index efbb3bb..0000000
--- a/src/gui/mainwidget.cpp
+++ /dev/null
@@ -1,275 +0,0 @@
-/*
- * QCMA: Cross-platform content manager assistant for the PS Vita
- *
- * Copyright (C) 2013 Codestation
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
-
-#include "mainwidget.h"
-#include "cmaclient.h"
-#include "cmautils.h"
-
-#include "qlistdb.h"
-#include "sqlitedb.h"
-
-#include "indicator/qtrayicon.h"
-
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-
-const QStringList MainWidget::path_list = QStringList() << "photoPath" << "musicPath" << "videoPath" << "appsPath" << "urlPath";
-
-bool sleptOnce = false;
-
-MainWidget::MainWidget(QWidget *obj_parent) :
- QWidget(obj_parent), db(NULL), configForm(NULL), managerForm(NULL), backupForm(NULL)
-{
- trayIcon = NULL;
-}
-
-void MainWidget::checkSettings()
-{
- QSettings settings;
- // make sure that all the paths are set, else show the config dialog
- foreach(const QString &path, path_list) {
- if(!settings.contains(path)) {
- first_run = true;
- configForm->show();
- return;
- }
- }
- first_run = false;
- managerForm->start();
-}
-
-void MainWidget::dialogResult(int result)
-{
- if(result == QDialog::Accepted) {
- if(first_run) {
- first_run = false;
- managerForm->start();
- }
- } else if(first_run) {
- qApp->quit();
- }
-}
-
-void MainWidget::stopServer()
-{
- setTrayTooltip(tr("Shutting down..."));
- if(CmaClient::isRunning()) {
- receiveMessage(tr("Stopping QCMA (disconnect your PS Vita)"));
- }
- managerForm->stop();
-}
-
-void MainWidget::deviceDisconnect()
-{
-#ifndef Q_OS_WIN32
- trayIcon->setIcon("qcma_off");
-#else
- trayIcon->setIcon("tray/qcma_off_16");
-#endif
- qDebug("Icon changed - disconnected");
- setTrayTooltip(tr("Disconnected"));
- receiveMessage(tr("The device has been disconnected"));
-}
-
-void MainWidget::deviceConnect(QString message)
-{
-#ifndef Q_OS_WIN32
- trayIcon->setIcon("qcma_on");
-#else
- trayIcon->setIcon("tray/qcma_on_16");
-#endif
- qDebug("Icon changed - connected");
- setTrayTooltip(message);
- receiveMessage(message);
-}
-
-void MainWidget::prepareApplication(bool showSystray)
-{
- //TODO: delete database before exit
- if(QSettings().value("useMemoryStorage", true).toBool()) {
- db = new QListDB();
- } else {
- db = new SQLiteDB();
- }
-
- configForm = new ConfigWidget();
- backupForm = new BackupManagerForm(db, this);
- managerForm = new ClientManager(db, this);
- connectSignals();
-
- if(showSystray) {
- createTrayIcon();
- }
-
- checkSettings();
-}
-
-void MainWidget::connectSignals()
-{
- connect(configForm, SIGNAL(finished(int)), this, SLOT(dialogResult(int)));
- connect(managerForm, SIGNAL(stopped()), qApp, SLOT(quit()));
- connect(managerForm, SIGNAL(deviceConnected(QString)), this, SIGNAL(deviceConnected(QString)));
- connect(managerForm, SIGNAL(deviceDisconnected()), this, SIGNAL(deviceDisconnected()));
- connect(managerForm, SIGNAL(messageSent(QString)), this, SIGNAL(messageReceived(QString)));
- connect(managerForm, SIGNAL(updated(int)), this, SIGNAL(databaseUpdated(int)));
-}
-
-void MainWidget::setTrayTooltip(QString message)
-{
- if(trayIcon) {
- trayIcon->setToolTip(message);
- }
-}
-
-void MainWidget::openManager()
-{
- backupForm->loadBackupListing(-1);
- backupForm->show();
-}
-
-void MainWidget::showAboutDialog()
-{
- QMessageBox about;
-
- about.setText(QString("Qcma ") + QCMA_VER);
- about.setWindowTitle(tr("About Qcma"));
-#ifndef QCMA_BUILD_HASH
- about.setInformativeText(tr("Copyright (C) 2015 Codestation") + "\n");
-#else
- about.setInformativeText(tr("Copyright (C) 2015 Codestation\n\nbuild hash: %1\nbuild branch: %2").arg(QCMA_BUILD_HASH).arg(QCMA_BUILD_BRANCH));
-#endif
- about.setStandardButtons(QMessageBox::Ok);
- about.setIconPixmap(QPixmap(":/main/resources/images/qcma.png"));
- about.setDefaultButton(QMessageBox::Ok);
-
- // hack to expand the messagebox minimum size
- QSpacerItem* horizontalSpacer = new QSpacerItem(300, 0, QSizePolicy::Minimum, QSizePolicy::Expanding);
- QGridLayout* widget_layout = (QGridLayout*)about.layout();
- widget_layout->addItem(horizontalSpacer, widget_layout->rowCount(), 0, 1, widget_layout->columnCount());
-
- about.show();
- about.exec();
-}
-
-void MainWidget::showAboutQt()
-{
- QMessageBox::aboutQt(this);
-}
-
-void MainWidget::openConfig()
-{
- configForm->open();
-}
-
-void MainWidget::refreshDatabase()
-{
- managerForm->refreshDatabase();
-}
-
-TrayIndicator *MainWidget::createTrayObject(QWidget *obj_parent)
-{
- TrayFunctionPointer create_tray = NULL;
-
-#ifdef Q_OS_LINUX
- QString desktop = getenv("XDG_CURRENT_DESKTOP");
- qDebug() << "Current desktop: " << desktop;
-
-#ifdef QT_DEBUG
- QString library_path = QApplication::applicationDirPath();
-#else
- QString library_path = "/usr/lib/qcma";
-#endif
-
- if(desktop.toLower() == "kde")
- {
- // KDENotifier
- QLibrary library(library_path + "/libqcma_kdenotifier.so");
- if(library.load())
- create_tray = reinterpret_cast(library.resolve("createTrayIndicator"));
- else
- qWarning() << "Cannot load libqcma_kdenotifier plugin";
- }
- else
- // try to use the appindicator if is available
- // if(desktop.toLower() == "unity")
- {
- // AppIndicator
- QLibrary library(library_path + "/libqcma_appindicator.so");
- if(library.load())
- create_tray = reinterpret_cast(library.resolve("createTrayIndicator"));
- else
- qWarning() << "Cannot load libqcma_appindicator plugin";
- }
-#endif
- // else QSystemTrayIcon
- return (create_tray != NULL) ? create_tray(obj_parent) : createTrayIndicator(obj_parent);
-}
-
-void MainWidget::createTrayIcon()
-{
- trayIcon = createTrayObject(this);
- trayIcon->init();
-
-#ifndef Q_OS_WIN32
- trayIcon->setIcon("qcma_off");
-#else
- trayIcon->setIcon("tray/qcma_off_16");
-#endif
- trayIcon->show();
-
- connect(trayIcon, SIGNAL(openConfig()), this, SLOT(openConfig()));
- connect(trayIcon, SIGNAL(openManager()), this, SLOT(openManager()));
- connect(trayIcon, SIGNAL(refreshDatabase()), this, SLOT(refreshDatabase()));
- connect(trayIcon, SIGNAL(showAboutDialog()), this, SLOT(showAboutDialog()));
- connect(trayIcon, SIGNAL(showAboutQt()), this, SLOT(showAboutQt()));
- connect(trayIcon, SIGNAL(stopServer()), this, SLOT(stopServer()));
-
- connect(managerForm, SIGNAL(deviceConnected(QString)), this, SLOT(deviceConnect(QString)));
- connect(managerForm, SIGNAL(deviceDisconnected()), this, SLOT(deviceDisconnect()));
- connect(managerForm, SIGNAL(messageSent(QString)), this, SLOT(receiveMessage(QString)));
-}
-
-void MainWidget::receiveMessage(QString message)
-{
- // a timeout is added before the popups are displayed to prevent them from
- // appearing in the wrong location
- if(!sleptOnce) {
- Sleeper::sleep(1);
- sleptOnce = true;
- }
-
- if(trayIcon->isVisible())
- trayIcon->showMessage(tr("Information"), message);
-}
-
-MainWidget::~MainWidget()
-{
- if(trayIcon) {
- trayIcon->hide();
- }
- delete db;
-}
diff --git a/src/gui/mainwidget.h b/src/gui/mainwidget.h
deleted file mode 100644
index 4b40775..0000000
--- a/src/gui/mainwidget.h
+++ /dev/null
@@ -1,90 +0,0 @@
-/*
- * QCMA: Cross-platform content manager assistant for the PS Vita
- *
- * Copyright (C) 2013 Codestation
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
-
-#ifndef MAINWIDGET_H
-#define MAINWIDGET_H
-
-#include "cmaclient.h"
-#include "clientmanager.h"
-#include "forms/configwidget.h"
-#include "forms/backupmanagerform.h"
-#include "forms/progressform.h"
-
-#include
-#include
-
-#include
-
-#include
-
-class TrayIndicator;
-
-class MainWidget : public QWidget
-{
- Q_OBJECT
-
-public:
- explicit MainWidget(QWidget *parent = 0);
- ~MainWidget();
-
- void prepareApplication(bool showSystray);
-
-private:
- void connectSignals();
- void createTrayIcon();
- void checkSettings();
- TrayIndicator *createTrayObject(QWidget *parent);
-
- bool first_run;
-
- // database
- Database *db;
-
- // forms
- ConfigWidget *configForm;
- ClientManager *managerForm;
- BackupManagerForm *backupForm;
-
- TrayIndicator *trayIcon;
-
- const static QStringList path_list;
-
-signals:
- void deviceConnected(QString);
- void deviceDisconnected();
- void databaseUpdated(int count);
- void messageReceived(QString message);
-
-public slots:
- void openConfig();
- void openManager();
- void showAboutQt();
- void showAboutDialog();
- void refreshDatabase();
- void stopServer();
-
-private slots:
- void deviceConnect(QString message);
- void deviceDisconnect();
- void dialogResult(int result);
- void receiveMessage(QString message);
- void setTrayTooltip(QString message);
-};
-
-#endif // MAINWIDGET_H
diff --git a/src/gui/singleapplication.cpp b/src/gui/singleapplication.cpp
deleted file mode 100644
index 277a985..0000000
--- a/src/gui/singleapplication.cpp
+++ /dev/null
@@ -1,69 +0,0 @@
-/*
- * QCMA: Cross-platform content manager assistant for the PS Vita
- *
- * Copyright (C) 2013 Codestation
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
-
-#include "singleapplication.h"
-
-#include
-
-const int SingleApplication::timeout = 500;
-const QString SingleApplication::SHARED_KEY = "QCMA_KEY";
-
-SingleApplication::SingleApplication(int &s_argc, char **s_argv) :
- QApplication(s_argc, s_argv)
-{
- server = new QLocalServer(this);
- connect(server, SIGNAL(newConnection()), this, SLOT(receiveMessage()));
- QLocalServer::removeServer(SHARED_KEY);
- server->listen(SHARED_KEY);
-}
-
-void SingleApplication::receiveMessage()
-{
- QLocalSocket *socket = server->nextPendingConnection();
-
- if(!socket->waitForReadyRead(timeout)) {
- qDebug() << socket->errorString();
- return;
- }
-
- QByteArray byteArray = socket->readAll();
- QString message = QString::fromUtf8(byteArray.constData());
- emit messageAvailable(message);
- socket->disconnectFromServer();
-}
-
-bool SingleApplication::sendMessage(const QString &message)
-{
- QLocalSocket socket;
- socket.connectToServer(SHARED_KEY, QIODevice::WriteOnly);
-
- if(!socket.waitForConnected(timeout)) {
- return false;
- }
-
- socket.write(message.toUtf8());
-
- if(!socket.waitForBytesWritten(timeout)) {
- qDebug() << socket.errorString();
- return false;
- }
-
- socket.disconnectFromServer();
- return true;
-}
diff --git a/src/gui/singleapplication.h b/src/gui/singleapplication.h
deleted file mode 100644
index 1fee13a..0000000
--- a/src/gui/singleapplication.h
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- * QCMA: Cross-platform content manager assistant for the PS Vita
- *
- * Copyright (C) 2013 Codestation
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
-
-#ifndef SINGLEAPPLICATION_H
-#define SINGLEAPPLICATION_H
-
-#include
-#include
-#include
-#include
-
-class SingleApplication : public QApplication
-{
- Q_OBJECT
-public:
- explicit SingleApplication(int &argc, char **argv);
-
- static bool sendMessage(const QString &message);
-
-private:
- QLocalServer *server;
-
- static const int timeout;
- static const QString SHARED_KEY;
-
-signals:
- void messageAvailable(QString message);
-
-
-public slots:
- void receiveMessage();
-};
-
-#endif // SINGLEAPPLICATION_H
diff --git a/src/httpdownloader.cpp b/src/httpdownloader.cpp
deleted file mode 100644
index 338b6c8..0000000
--- a/src/httpdownloader.cpp
+++ /dev/null
@@ -1,136 +0,0 @@
-/*
- * QCMA: Cross-platform content manager assistant for the PS Vita
- *
- * Copyright (C) 2014 Codestation
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
-
-#include "httpdownloader.h"
-
-#include
-#include
-
-#include
-
-QNetworkReply *HTTPDownloader::reply = NULL;
-volatile qint64 HTTPDownloader::m_contentLength = -1;
-
-QMutex HTTPDownloader::dataAvailable;
-QMutex HTTPDownloader::dataRead;
-
-QByteArray HTTPDownloader::buffer;
-bool HTTPDownloader::bufferReady = false;
-qint64 HTTPDownloader::downloadLeft = 0;
-
-HTTPDownloader::HTTPDownloader(const QString &url, QObject *obj_parent) :
- QObject(obj_parent), remote_url(url), firstRead(true)
-{
- lengthMutex.lock();
-}
-
-HTTPDownloader::~HTTPDownloader()
-{
- lengthMutex.unlock();
- dataAvailable.unlock();
-}
-
-void HTTPDownloader::downloadFile()
-{
- dataAvailable.lock();
- qDebug("Starting http_thread: 0x%016" PRIxPTR, (uintptr_t)QThread::currentThreadId());
- request = new QNetworkAccessManager(this);
- reply = request->get(QNetworkRequest(QUrl(remote_url)));
- connect(reply, SIGNAL(metaDataChanged()), this, SLOT(metadataChanged()));
- connect(reply, SIGNAL(readyRead()), this, SLOT(readyRead()));
- connect(reply, SIGNAL(error(QNetworkReply::NetworkError)),
- this, SLOT(error(QNetworkReply::NetworkError)));
- connect(reply, SIGNAL(finished()), reply, SLOT(deleteLater()));
- connect(reply, SIGNAL(finished()), request, SLOT(deleteLater()));
-}
-
-void HTTPDownloader::metadataChanged()
-{
- QVariant len = reply->header(QNetworkRequest::ContentLengthHeader);
- if(len.isValid()) {
- m_contentLength = len.toInt();
- buffer.resize(8);
- *(uint64_t *)buffer.data() = m_contentLength;
- downloadLeft = m_contentLength;
- } else {
- m_contentLength = -1;
- }
- lengthMutex.unlock();
-}
-
-qint64 HTTPDownloader::getFileSize()
-{
- lengthMutex.lock();
- return m_contentLength;
-}
-
-void HTTPDownloader::readyRead()
-{
- QMutexLocker locker(&dataRead);
-
- downloadLeft -= reply->bytesAvailable();
-
- buffer.append(reply->readAll());
-
- if(buffer.size() >= 16 * 1024 || downloadLeft == 0) {
- dataAvailable.unlock();
- }
-
- if(downloadLeft == 0)
- qDebug() << "remote download complete";
-}
-
-int HTTPDownloader::readCallback(unsigned char *data, unsigned long wantlen, unsigned long *gotlen)
-{
- if(downloadLeft && !dataAvailable.tryLock(30000)) {
- qWarning("Connection timeout while receiving data from network, aborting");
- return -1;
- }
-
- QMutexLocker locker(&dataRead);
-
- if(buffer.size() == 0)
- return -1;
-
- int read_size = wantlen > (unsigned long)buffer.size() ? buffer.size() : wantlen;
-
- memcpy(data, buffer.data(), read_size);
- buffer.remove(0, read_size);
-
- qDebug() << "sending data: " << read_size << ", left in buffer: " << buffer.size();
-
- *gotlen = read_size;
-
- return PTP_RC_OK;
-}
-
-void HTTPDownloader::error(QNetworkReply::NetworkError errorCode)
-{
- Q_UNUSED(errorCode);
- QString str_error = reply->errorString();
-
- qWarning() << "Network error:" << str_error;
- emit messageSent(tr("Network error: %1").arg(str_error));
-
- lengthMutex.unlock();
-
- // clear the buffer so a read callback can be aborted
- QMutexLocker locker(&dataRead);
- buffer.clear();
-}
diff --git a/src/httpdownloader.h b/src/httpdownloader.h
deleted file mode 100644
index 1d5c404..0000000
--- a/src/httpdownloader.h
+++ /dev/null
@@ -1,66 +0,0 @@
-/*
- * QCMA: Cross-platform content manager assistant for the PS Vita
- *
- * Copyright (C) 2014 Codestation
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
-
-#ifndef HTTPDOWNLOADER_H
-#define HTTPDOWNLOADER_H
-
-#include
-#include
-#include
-#include
-#include
-
-#include
-
-class HTTPDownloader : public QObject
-{
- Q_OBJECT
-public:
- explicit HTTPDownloader(const QString &url, QObject *parent = 0);
- ~HTTPDownloader();
- qint64 getFileSize();
-
-signals:
- void messageSent(QString);
-
-public slots:
- void downloadFile();
- static int readCallback(unsigned char *data, unsigned long wantlen, unsigned long *gotlen);
- void metadataChanged();
- void readyRead();
- void error(QNetworkReply::NetworkError);
-
-private:
- QString remote_url;
- QNetworkAccessManager *request;
- QMutex lengthMutex;
- bool firstRead;
-
- static QMutex dataAvailable;
- static QMutex dataRead;
-
- static QNetworkReply *reply;
- volatile static qint64 m_contentLength;
-
- static QByteArray buffer;
- static bool bufferReady;
- static qint64 downloadLeft;
-};
-
-#endif // HTTPDOWNLOADER_H
diff --git a/src/indicator/kdenotifier.cpp b/src/indicator/kdenotifier.cpp
deleted file mode 100644
index a69fba1..0000000
--- a/src/indicator/kdenotifier.cpp
+++ /dev/null
@@ -1,25 +0,0 @@
-/*
- * QCMA: Cross-platform content manager assistant for the PS Vita
- *
- * Copyright (C) 2014 Codestation
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
-
-#include "kdenotifier.h"
-
-KDENotifier::KDENotifier(const QString ¬ifier_id, QObject *obj_parent) :
- KStatusNotifierItem(notifier_id, obj_parent)
-{
-}
diff --git a/src/indicator/kdenotifier.h b/src/indicator/kdenotifier.h
deleted file mode 100644
index bfec040..0000000
--- a/src/indicator/kdenotifier.h
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * QCMA: Cross-platform content manager assistant for the PS Vita
- *
- * Copyright (C) 2014 Codestation
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
-
-#ifndef KDENOTIFIER_H
-#define KDENOTIFIER_H
-
-#include
-#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0)
-#include
-#endif
-
-class KDENotifier : public KStatusNotifierItem
-{
- Q_OBJECT
-public:
- explicit KDENotifier(const QString &id, QObject *parent = 0);
-
-signals:
-
-public slots:
- // block left click because it shows the default widget
- virtual void activate (const QPoint &pos=QPoint()) {
- Q_UNUSED(pos);
- }
-};
-
-#endif // KDENOTIFIER_H
diff --git a/src/indicator/kdenotifiertray.cpp b/src/indicator/kdenotifiertray.cpp
deleted file mode 100644
index 3fcf0fa..0000000
--- a/src/indicator/kdenotifiertray.cpp
+++ /dev/null
@@ -1,102 +0,0 @@
-/*
- * QCMA: Cross-platform content manager assistant for the PS Vita
- *
- * Copyright (C) 2014 Codestation
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
-
-#include "kdenotifiertray.h"
-#ifndef ENABLE_KNOTIFICATIONS
-#include
-#else
-#include
-#endif
-
-KDENotifierTray::KDENotifierTray(QWidget *obj_parent)
- : TrayIndicator(obj_parent)
-{
-}
-
-void KDENotifierTray::init()
-{
- options = new QAction(tr("Settings"), this);
- reload = new QAction(tr("Refresh database"), this);
- backup = new QAction(tr("Backup Manager"), this);
- about = new QAction(tr("About QCMA"), this);
- about_qt = new QAction(tr("About Qt"), this);
- quit = new QAction(tr("Quit"), this);
-
- connect(options, SIGNAL(triggered()), this, SIGNAL(openConfig()));
- connect(backup, SIGNAL(triggered()), this, SIGNAL(openManager()));
- connect(reload, SIGNAL(triggered()), this, SIGNAL(refreshDatabase()));
- connect(about, SIGNAL(triggered()), this, SIGNAL(showAboutDialog()));
- connect(about_qt, SIGNAL(triggered()), this, SIGNAL(showAboutQt()));
- connect(quit, SIGNAL(triggered()), this, SIGNAL(stopServer()));
-
-#ifndef ENABLE_KNOTIFICATIONS
- KMenu *tray_icon_menu = new KMenu(this);
-#else
- QMenu *tray_icon_menu = new QMenu(this);
-#endif
-
- tray_icon_menu->addAction(options);
- tray_icon_menu->addAction(reload);
- tray_icon_menu->addAction(backup);
- tray_icon_menu->addSeparator();
- tray_icon_menu->addAction(about);
- tray_icon_menu->addAction(about_qt);
- tray_icon_menu->addSeparator();
- tray_icon_menu->addAction(quit);
-
- m_notifier_item = new KDENotifier("QcmaNotifier", this);
- m_notifier_item->setContextMenu(tray_icon_menu);
- m_notifier_item->setTitle("Qcma");
- m_notifier_item->setCategory(KStatusNotifierItem::ApplicationStatus);
- m_notifier_item->setIconByPixmap(QIcon(":/main/resources/images/qcma_off.png"));
- m_notifier_item->setStatus(KStatusNotifierItem::Active);
- m_notifier_item->setToolTipTitle(tr("Qcma status"));
- m_notifier_item->setToolTipIconByPixmap(QIcon(":/main/resources/images/qcma.png"));
- m_notifier_item->setToolTipSubTitle(tr("Disconnected"));
- m_notifier_item->setStandardActionsEnabled(false);
-}
-
-void KDENotifierTray::showMessage(const QString &title, const QString &message)
-{
- m_notifier_item->showMessage(title, message, "dialog-information", 3000);
-}
-
-bool KDENotifierTray::isVisible()
-{
- return true;
-}
-
-void KDENotifierTray::setIcon(const QString &icon)
-{
- m_notifier_item->setIconByPixmap(QIcon(":/main/resources/images/" + icon));
-}
-
-void KDENotifierTray::show()
-{
-}
-
-void KDENotifierTray::hide()
-{
-}
-
-// exported library function
-TrayIndicator *createTrayIndicator(QWidget *parent)
-{
- return new KDENotifierTray(parent);
-}
diff --git a/src/indicator/kdenotifiertray.h b/src/indicator/kdenotifiertray.h
deleted file mode 100644
index 7333466..0000000
--- a/src/indicator/kdenotifiertray.h
+++ /dev/null
@@ -1,56 +0,0 @@
-/*
- * QCMA: Cross-platform content manager assistant for the PS Vita
- *
- * Copyright (C) 2014 Codestation
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
-
-#ifndef KDENOTIFIERTRAY_H
-#define KDENOTIFIERTRAY_H
-
-#include "trayindicator.h"
-#include "kdenotifier.h"
-
-class QAction;
-class QSystemTrayIcon;
-
-class KDENotifierTray : public TrayIndicator
-{
- Q_OBJECT
-public:
- explicit KDENotifierTray(QWidget *parent = 0);
- void init();
- void setIcon(const QString &icon);
- bool isVisible();
- void show();
- void hide();
- void showMessage(const QString &title, const QString &message);
-
-private:
- //system tray
- QAction *quit;
- QAction *reload;
- QAction *options;
- QAction *backup;
- QAction *about;
- QAction *about_qt;
-
- KDENotifier *m_notifier_item;
-
-public slots:
-
-};
-
-#endif // KDENOTIFIERTRAY_H
diff --git a/src/indicator/qtrayicon.cpp b/src/indicator/qtrayicon.cpp
deleted file mode 100644
index ff3036a..0000000
--- a/src/indicator/qtrayicon.cpp
+++ /dev/null
@@ -1,117 +0,0 @@
-/*
- * QCMA: Cross-platform content manager assistant for the PS Vita
- *
- * Copyright (C) 2014 Codestation
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
-
-#include "qtrayicon.h"
-
-#include
-#include
-#include
-
-#ifdef Q_OS_LINUX
-#undef signals
-extern "C" {
-#include
-}
-#define signals public
-#endif
-
-QTrayIcon::QTrayIcon(QWidget *obj_parent)
- : TrayIndicator(obj_parent)
-{
-#ifdef Q_OS_LINUX
- notify_init("qcma");
-#endif
-}
-
-QTrayIcon::~QTrayIcon()
-{
-#ifdef Q_OS_LINUX
- notify_uninit();
-#endif
-}
-
-void QTrayIcon::init()
-{
- options = new QAction(tr("Settings"), this);
- reload = new QAction(tr("Refresh database"), this);
- backup = new QAction(tr("Backup Manager"), this);
- about = new QAction(tr("About QCMA"), this);
- about_qt = new QAction(tr("About Qt"), this);
- quit = new QAction(tr("Quit"), this);
-
- connect(options, SIGNAL(triggered()), this, SIGNAL(openConfig()));
- connect(backup, SIGNAL(triggered()), this, SIGNAL(openManager()));
- connect(reload, SIGNAL(triggered()), this, SIGNAL(refreshDatabase()));
- connect(about, SIGNAL(triggered()), this, SIGNAL(showAboutDialog()));
- connect(about_qt, SIGNAL(triggered()), this, SIGNAL(showAboutQt()));
- connect(quit, SIGNAL(triggered()), this, SIGNAL(stopServer()));
-
- QMenu *tray_icon_menu = new QMenu(this);
-
- tray_icon_menu->addAction(options);
- tray_icon_menu->addAction(reload);
- tray_icon_menu->addAction(backup);
- tray_icon_menu->addSeparator();
- tray_icon_menu->addAction(about);
- tray_icon_menu->addAction(about_qt);
- tray_icon_menu->addSeparator();
- tray_icon_menu->addAction(quit);
-
- m_tray_icon = new QSystemTrayIcon(this);
- m_tray_icon->setContextMenu(tray_icon_menu);
-}
-
-
-void QTrayIcon::showMessage(const QString &title, const QString &message)
-{
-#ifdef Q_OS_LINUX
- NotifyNotification *notif = notify_notification_new(qPrintable(title), qPrintable(message), "dialog-information");
- notify_notification_show(notif, NULL);
- g_object_unref(G_OBJECT(notif));
-#else
- m_tray_icon->showMessage(title, message);
-#endif
-}
-
-bool QTrayIcon::isVisible()
-{
- return m_tray_icon->isVisible();
-}
-
-void QTrayIcon::setIcon(const QString &icon)
-{
- QIcon qicon(":/main/resources/images/" + icon + ".png");
- m_tray_icon->setIcon(qicon);
-}
-
-void QTrayIcon::show()
-{
- m_tray_icon->show();
-}
-
-void QTrayIcon::hide()
-{
- m_tray_icon->hide();
-}
-
-// exported library function
-TrayIndicator *createTrayIndicator(QWidget *parent)
-{
- return new QTrayIcon(parent);
-}
diff --git a/src/indicator/qtrayicon.h b/src/indicator/qtrayicon.h
deleted file mode 100644
index 14392e2..0000000
--- a/src/indicator/qtrayicon.h
+++ /dev/null
@@ -1,53 +0,0 @@
-/*
- * QCMA: Cross-platform content manager assistant for the PS Vita
- *
- * Copyright (C) 2014 Codestation
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
-
-#ifndef QTRAYICON_H
-#define QTRAYICON_H
-
-#include "trayindicator.h"
-
-class QAction;
-class QSystemTrayIcon;
-
-class QTrayIcon : public TrayIndicator
-{
- Q_OBJECT
-public:
- explicit QTrayIcon(QWidget *parent = 0);
- ~QTrayIcon();
- void init();
- void setIcon(const QString &icon);
- bool isVisible();
- void show();
- void hide();
- void showMessage(const QString &title, const QString &message);
-
-private:
- //system tray
- QAction *quit;
- QAction *reload;
- QAction *options;
- QAction *backup;
- QAction *about;
- QAction *about_qt;
-
- QSystemTrayIcon *m_tray_icon;
-};
-
-#endif // QTRAYICON_H
diff --git a/src/indicator/trayindicator.h b/src/indicator/trayindicator.h
deleted file mode 100644
index 1934ee7..0000000
--- a/src/indicator/trayindicator.h
+++ /dev/null
@@ -1,62 +0,0 @@
-/*
- * QCMA: Cross-platform content manager assistant for the PS Vita
- *
- * Copyright (C) 2014 Codestation
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
-
-#ifndef TRAYINDICATOR_H
-#define TRAYINDICATOR_H
-
-#include
-#include
-
-#include "trayindicator_global.h"
-
-#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0)
-// in Qt4 signals are protected
-#undef signals
-#define signals public
-#endif
-
-class TrayIndicator : public QWidget
-{
- Q_OBJECT
-public:
- ~TrayIndicator() {}
- virtual void init() = 0;
- virtual bool isVisible() = 0;
- virtual void setIcon(const QString &icon) = 0;
- virtual void showMessage(const QString &title, const QString &message) = 0;
- virtual void show() = 0;
- virtual void hide() = 0;
-
-protected:
- TrayIndicator(QWidget *obj_parent = 0) : QWidget(obj_parent) {}
-
-signals:
- void openConfig();
- void openManager();
- void refreshDatabase();
- void showAboutDialog();
- void showAboutQt();
- void stopServer();
-
-};
-
-typedef TrayIndicator *(*TrayFunctionPointer)(QWidget *parent);
-extern "C" TRAYINDICATORSHARED_EXPORT TrayIndicator *createTrayIndicator(QWidget *parent = 0);
-
-#endif // TRAYINDICATOR_H
diff --git a/src/indicator/trayindicator_global.h b/src/indicator/trayindicator_global.h
deleted file mode 100644
index 3033fc6..0000000
--- a/src/indicator/trayindicator_global.h
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- * QCMA: Cross-platform content manager assistant for the PS Vita
- *
- * Copyright (C) 2014 Codestation
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
-
-#ifndef TRAYINDICATOR_GLOBAL_H
-#define TRAYINDICATOR_GLOBAL_H
-
-#include
-
-#ifdef Q_OS_LINUX
-#if defined(QCMA_TRAYINDICATOR_LIBRARY)
-# define TRAYINDICATORSHARED_EXPORT Q_DECL_EXPORT
-#else
-# define TRAYINDICATORSHARED_EXPORT Q_DECL_IMPORT
-#endif
-#else
-# define TRAYINDICATORSHARED_EXPORT
-#endif
-
-#endif // TRAYINDICATOR_GLOBAL_H
diff --git a/src/indicator/trayindicator_import.h b/src/indicator/trayindicator_import.h
deleted file mode 120000
index 886a438..0000000
--- a/src/indicator/trayindicator_import.h
+++ /dev/null
@@ -1 +0,0 @@
-trayindicator.h
\ No newline at end of file
diff --git a/src/indicator/unityindicator.cpp b/src/indicator/unityindicator.cpp
deleted file mode 100644
index dc67bcf..0000000
--- a/src/indicator/unityindicator.cpp
+++ /dev/null
@@ -1,201 +0,0 @@
-/*
- * QCMA: Cross-platform content manager assistant for the PS Vita
- *
- * Copyright (C) 2014 Codestation
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
-
-#include "unityindicator.h"
-
-#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)
-#include
-#else
-#include
-#define QStandardPaths QDesktopServices
-#define writableLocation storageLocation
-#endif
-
-#include
-#include
-#include
-
-#undef signals
-
-extern "C" {
-
-#include
-
-void optionsIndicator(GtkMenu *menu, gpointer data);
-void reloadIndicator(GtkMenu *menu, gpointer data);
-void backupIndicator(GtkMenu *menu, gpointer data);
-void aboutIndicator(GtkMenu *menu, gpointer data);
-void aboutQtIndicator(GtkMenu *menu, gpointer data);
-void quitIndicator(GtkMenu *menu, gpointer data);
-}
-
-#define signals public
-
-UnityIndicator::UnityIndicator(QWidget *obj_parent) :
- TrayIndicator(obj_parent)
-{
- notify_init("qcma");
-}
-
-UnityIndicator::~UnityIndicator()
-{
- notify_uninit();
- for(QVector >::iterator it = m_handlers.begin(); it != m_handlers.end(); ++it)
- {
- g_signal_handler_disconnect(it->first, it->second);
- }
-}
-
-void optionsIndicator(GtkMenu *, gpointer data)
-{
- UnityIndicator *m_this = reinterpret_cast(data);
- emit m_this->openConfig();
-}
-
-void reloadIndicator(GtkMenu *, gpointer data)
-{
- UnityIndicator *m_this = reinterpret_cast(data);
- emit m_this->refreshDatabase();
-}
-
-void backupIndicator(GtkMenu *, gpointer data)
-{
- UnityIndicator *m_this = reinterpret_cast(data);
- emit m_this->openManager();
-}
-
-void aboutIndicator(GtkMenu *, gpointer data)
-{
- UnityIndicator *m_this = reinterpret_cast(data);
- emit m_this->showAboutDialog();
-}
-
-void aboutQtIndicator(GtkMenu *, gpointer data)
-{
- UnityIndicator *m_this = reinterpret_cast(data);
- emit m_this->showAboutQt();
-}
-
-void quitIndicator(GtkMenu *, gpointer data)
-{
- UnityIndicator *m_this = reinterpret_cast(data);
- emit m_this->stopServer();
-}
-
-void UnityIndicator::init()
-{
- GtkWidget *menu = gtk_menu_new();
-
- GtkWidget *options = gtk_menu_item_new_with_label(qPrintable(tr("Settings")));
- GtkWidget *reload = gtk_menu_item_new_with_label(qPrintable(tr("Refresh database")));
- GtkWidget *backup = gtk_menu_item_new_with_label(qPrintable(tr("Backup Manager")));
- GtkWidget *separator1 = gtk_separator_menu_item_new();
- GtkWidget *about = gtk_menu_item_new_with_label(qPrintable(tr("About QCMA")));
- GtkWidget *about_qt = gtk_menu_item_new_with_label(qPrintable(tr("About Qt")));
- GtkWidget *separator2 = gtk_separator_menu_item_new();
- GtkWidget *quit = gtk_menu_item_new_with_label(qPrintable(tr("Quit")));
-
- gtk_menu_shell_append(GTK_MENU_SHELL(menu), options);
- gtk_menu_shell_append(GTK_MENU_SHELL(menu), reload);
- gtk_menu_shell_append(GTK_MENU_SHELL(menu), backup);
- gtk_menu_shell_append(GTK_MENU_SHELL(menu), separator1);
- gtk_menu_shell_append(GTK_MENU_SHELL(menu), about);
- gtk_menu_shell_append(GTK_MENU_SHELL(menu), about_qt);
- gtk_menu_shell_append(GTK_MENU_SHELL(menu), separator2);
- gtk_menu_shell_append(GTK_MENU_SHELL(menu), quit);
-
- gulong gobject_handler;
- gobject_handler = g_signal_connect(options, "activate", G_CALLBACK(optionsIndicator), this);
- m_handlers.append(QPair(options, gobject_handler));
- gobject_handler = g_signal_connect(reload, "activate", G_CALLBACK(reloadIndicator), this);
- m_handlers.append(QPair(reload, gobject_handler));
- gobject_handler = g_signal_connect(backup, "activate", G_CALLBACK(backupIndicator), this);
- m_handlers.append(QPair(backup, gobject_handler));
- gobject_handler = g_signal_connect(about, "activate", G_CALLBACK(aboutIndicator), this);
- m_handlers.append(QPair(about, gobject_handler));
- gobject_handler = g_signal_connect(about_qt, "activate", G_CALLBACK(aboutQtIndicator), this);
- m_handlers.append(QPair(about_qt, gobject_handler));
- gobject_handler = g_signal_connect(quit, "activate", G_CALLBACK(quitIndicator), this);
- m_handlers.append(QPair(quit, gobject_handler));
-
- gtk_widget_show(options);
- gtk_widget_show(reload);
- gtk_widget_show(backup);
- gtk_widget_show(separator1);
- gtk_widget_show(about);
- gtk_widget_show(about_qt);
- gtk_widget_show(separator2);
- gtk_widget_show(quit);
-
- m_indicator = app_indicator_new(
- "qcma-appindicator",
- "qcma-messages",
- APP_INDICATOR_CATEGORY_APPLICATION_STATUS
- );
-
- QString icon_path;
- QString icon_name = "share/icons/hicolor/64x64/actions/qcma_on.png";
-
- if(QFile("/usr/" + icon_name).exists())
- icon_path = QFileInfo("/usr/" + icon_name).absolutePath();
- else if(QFile("/usr/local" + icon_name).exists())
- icon_path = QFileInfo("/usr/" + icon_name).absolutePath();
-
- if(!icon_path.isEmpty())
- {
- qDebug() << "Using " << icon_path << " as icon theme path";
- app_indicator_set_icon_theme_path(m_indicator, qPrintable(icon_path));
- }
- else
- qWarning() << "Cannot find qcma icons.";
-
- app_indicator_set_status(m_indicator, APP_INDICATOR_STATUS_ACTIVE);
- app_indicator_set_menu(m_indicator, GTK_MENU(menu));
-}
-
-bool UnityIndicator::isVisible()
-{
- return true;
-}
-
-void UnityIndicator::setIcon(const QString &icon)
-{
- app_indicator_set_icon_full(m_indicator, qPrintable(icon), "icon");
-}
-
-void UnityIndicator::show()
-{
-}
-
-void UnityIndicator::hide()
-{
-}
-
-void UnityIndicator::showMessage(const QString &title, const QString &message)
-{
- NotifyNotification *notif = notify_notification_new(qPrintable(title), qPrintable(message), "dialog-information");
- notify_notification_show(notif, NULL);
- g_object_unref(G_OBJECT(notif));
-}
-
-// exported library function
-TrayIndicator *createTrayIndicator(QWidget *parent)
-{
- return new UnityIndicator(parent);
-}
diff --git a/src/indicator/unityindicator.h b/src/indicator/unityindicator.h
deleted file mode 100644
index 0dc56d3..0000000
--- a/src/indicator/unityindicator.h
+++ /dev/null
@@ -1,54 +0,0 @@
-/*
- * QCMA: Cross-platform content manager assistant for the PS Vita
- *
- * Copyright (C) 2014 Codestation
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
-
-#ifndef UNITYINDICATOR_H
-#define UNITYINDICATOR_H
-
-#include "trayindicator.h"
-
-#include
-
-#undef signals
-
-extern "C" {
-#include
-#include
-}
-
-#define signals public
-
-class UnityIndicator : public TrayIndicator
-{
- Q_OBJECT
-public:
- explicit UnityIndicator(QWidget *parent = 0);
- ~UnityIndicator();
- void init();
- void setIcon(const QString &icon);
- bool isVisible();
- void show();
- void hide();
- void showMessage(const QString &title, const QString &message);
-
-private:
- AppIndicator *m_indicator;
- QVector > m_handlers;
-};
-
-#endif // UNITYINDICATOR_H
diff --git a/src/qlistdb.cpp b/src/qlistdb.cpp
deleted file mode 100644
index 97eec42..0000000
--- a/src/qlistdb.cpp
+++ /dev/null
@@ -1,610 +0,0 @@
-/*
- * QCMA: Cross-platform content manager assistant for the PS Vita
- *
- * Copyright (C) 2013 Codestation
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
-
-#include "cmautils.h"
-#include "qlistdb.h"
-#include "cmaobject.h"
-
-#include
-#include
-#include
-#include
-#include
-#include
-
-QListDB::QListDB(QObject *obj_parent) :
- Database(obj_parent)
-{
- QString uuid = QSettings().value("lastAccountId", "ffffffffffffffff").toString();
- CMARootObject::uuid = uuid;
- thread = new QThread();
- moveToThread(thread);
- timer = new QTimer();
- thread->start();
-
- timer->setInterval(0);
- timer->setSingleShot(true);
- connect(timer, SIGNAL(timeout()), this, SLOT(process()));
-}
-
-QListDB::~QListDB()
-{
- clear();
- timer->stop();
- delete timer;
- thread->quit();
- thread->wait();
- delete thread;
-}
-
-void QListDB::setUUID(const QString &uuid)
-{
- CMARootObject::uuid = uuid;
- QSettings().setValue("lastAccountId", uuid);
-}
-
-bool QListDB::load()
-{
- // not implemented
- return false;
-}
-
-bool QListDB::rescan()
-{
- if(mutex.tryLock(1000)) {
- if(CMARootObject::uuid != "ffffffffffffffff") {
- timer->start();
- return true;
- } else {
- mutex.unlock();
- return false;
- }
- }
- return false;
-}
-
-void QListDB::clear()
-{
- for(map_list::iterator root = object_list.begin(); root != object_list.end(); ++root) {
- CMARootObject *first = static_cast((*root).takeFirst());
- delete first;
- qDeleteAll(*root);
- }
-
- object_list.clear();
-}
-
-int QListDB::create()
-{
- int total_objects = 0;
- //QMutexLocker locker(&mutex);
- const int ohfi_array[] = { VITA_OHFI_MUSIC, VITA_OHFI_PHOTO, VITA_OHFI_VIDEO,
- VITA_OHFI_PACKAGE, VITA_OHFI_BACKUP, VITA_OHFI_VITAAPP,
- VITA_OHFI_PSPAPP, VITA_OHFI_PSPSAVE, VITA_OHFI_PSXAPP,
- VITA_OHFI_PSMAPP
- };
- CMAObject::resetOhfiCounter();
- QSettings settings;
-
- for(int i = 0, max = sizeof(ohfi_array) / sizeof(int); i < max; i++) {
- CMARootObject *obj = new CMARootObject(ohfi_array[i]);
- bool skipCurrent = false;
- int dir_count;
-
- switch(ohfi_array[i]) {
- case VITA_OHFI_MUSIC:
- obj->initObject(settings.value("musicPath").toString());
- skipCurrent = settings.value("musicSkip", false).toBool();
- break;
-
- case VITA_OHFI_PHOTO:
- obj->initObject(settings.value("photoPath").toString());
- skipCurrent = settings.value("photoSkip", false).toBool();
- break;
-
- case VITA_OHFI_VIDEO:
- obj->initObject(settings.value("videoPath").toString());
- skipCurrent = settings.value("videoSkip", false).toBool();
- break;
-
- case VITA_OHFI_BACKUP:
- case VITA_OHFI_VITAAPP:
- case VITA_OHFI_PSPAPP:
- case VITA_OHFI_PSPSAVE:
- case VITA_OHFI_PSXAPP:
- case VITA_OHFI_PSMAPP:
- obj->initObject(settings.value("appsPath").toString());
- break;
-
- case VITA_OHFI_PACKAGE:
- obj->initObject(settings.value("pkgPath").toString());
- }
-
- root_list list;
- list << obj;
- emit directoryAdded(obj->m_path);
-
- if(!skipCurrent) {
- dir_count = recursiveScanRootDirectory(list, obj, ohfi_array[i]);
- } else {
- dir_count = 0;
- }
-
- if(dir_count < 0) {
- return -1;
- }
-
- qDebug("Added objects for OHFI 0x%02X: %i", ohfi_array[i], dir_count);
-
- total_objects += dir_count;
- object_list[ohfi_array[i]] = list;
- }
- return total_objects;
-}
-
-CMAObject *QListDB::getParent(CMAObject *last_dir, const QString ¤t_path)
-{
- while(last_dir && current_path != last_dir->m_path) {
- last_dir = last_dir->parent;
- }
-
- return last_dir;
-}
-
-int QListDB::scanRootDirectory(root_list &list, int ohfi_type)
-{
- int obj_file_type = -1;
- int total_objects = 0;
- CMAObject *last_dir = list.first();
- QDir dir(last_dir->m_path);
- dir.setFilter(QDir::AllEntries | QDir::NoDotAndDotDot);
- QDirIterator it(dir, QDirIterator::Subdirectories);
-
- while(it.hasNext()) {
-
- if(!continueOperation()) {
- return -1;
- }
-
- it.next();
- QFileInfo info = it.fileInfo();
-
- if(info.isFile()) {
- if((obj_file_type = checkFileType(info.absoluteFilePath(), ohfi_type)) < 0) {
- //qDebug("Excluding %s from database", info.absoluteFilePath().toStdString().c_str());
- continue;
- }
- }
-
- CMAObject *obj = new CMAObject(getParent(last_dir, info.path()));
- obj->initObject(info, obj_file_type);
- //qDebug("Added %s to database with OHFI %d", obj->metadata.name, obj->metadata.ohfi);
- list << obj;
-
- if(obj->metadata.dataType & Folder) {
- last_dir = obj;
- } else {
- total_objects++;
- }
- }
- return total_objects;
-}
-
-int QListDB::recursiveScanRootDirectory(root_list &list, CMAObject *obj_parent, int ohfi_type)
-{
- int obj_file_type = -1;
- int total_objects = 0;
-
- QDir dir(obj_parent->m_path);
- dir.setSorting(QDir::Name | QDir::DirsFirst);
- QFileInfoList qsl = dir.entryInfoList(QDir::AllEntries | QDir::NoDotAndDotDot, QDir::Time);
-
- foreach(const QFileInfo &info, qsl) {
-
- if(!continueOperation()) {
- return -1;
- }
-
- if(info.isFile() && (obj_file_type = checkFileType(info.absoluteFilePath(), ohfi_type)) < 0) {
- //qDebug("Excluding %s from database", info.absoluteFilePath().toStdString().c_str());>
- } else {
- CMAObject *obj = new CMAObject(obj_parent);
- obj->initObject(info, obj_file_type);
- emit fileAdded(obj->metadata.name);
- //qDebug("Added %s to database with OHFI %d", obj->metadata.name, obj->metadata.ohfi);
- list << obj;
- if(info.isDir()) {
- emit directoryAdded(obj->m_path);
- total_objects += recursiveScanRootDirectory(list, obj, ohfi_type);
- } else {
- total_objects++;
- }
- }
- }
-
- return total_objects;
-}
-
-bool QListDB::removeInternal(root_list &list, int ohfi)
-{
- bool found = false;
- QList::iterator it = list.begin();
-
- while(it != list.end()) {
- if(!found && (*it)->metadata.ohfi == ohfi) {
- // update the size of the parent objects
- (*it)->updateObjectSize(-(*it)->metadata.size);
- it = list.erase(it);
- found = true;
- } else if(found && (*it)->metadata.ohfiParent == ohfi) {
- it = list.erase(it);
- } else {
- ++it;
- }
- }
-
- return found;
-}
-
-bool QListDB::lessThanComparator(const CMAObject *a, const CMAObject *b)
-{
- return a->metadata.ohfi < b->metadata.ohfi;
-}
-
-bool QListDB::hasFilter(const CMARootObject *object,int ohfi)
-{
- for(int i = 0; i < object->num_filters; i++) {
- if(object->filters[i].ohfi == ohfi) {
- return true;
- }
- }
- return false;
-}
-
-bool QListDB::findInternal(const root_list &list, int ohfi, find_data &data)
-{
- if(hasFilter(static_cast(list.first()), ohfi)) {
- data.it = list.begin();
- } else {
- CMAObject obj;
- obj.setOhfi(ohfi);
- data.it = qBinaryFind(list.begin(), list.end(), &obj, QListDB::lessThanComparator);
- }
- data.end = list.end();
- return data.it != data.end;
-}
-
-bool QListDB::find(int ohfi, QListDB::find_data &data)
-{
- for(map_list::iterator root = object_list.begin(); root != object_list.end(); ++root) {
- if(findInternal(*root, ohfi, data)) {
- return true;
- }
- }
- return false;
-}
-
-CMAObject *QListDB::ohfiToObject(int ohfi)
-{
- find_data data;
- return find(ohfi, data) ? *data.it : NULL;
-}
-
-CMAObject *QListDB::pathToObjectInternal(const root_list &list, const char *path)
-{
- // skip the first element since is the root element
- root_list::const_iterator skipped_first = ++list.begin();
-
- for(root_list::const_iterator obj = skipped_first; obj != list.end(); ++obj) {
- if(strcasecmp(path, (*obj)->metadata.path) == 0) {
- return (*obj);
- }
- }
- return NULL;
-}
-
-int QListDB::acceptFilteredObject(const CMAObject *obj_parent, const CMAObject *current, int type)
-{
- QMutexLocker locker(&mutex);
- int result = 0;
-
- if(MASK_SET(type, VITA_DIR_TYPE_MASK_PHOTO)) {
- result = (current->metadata.dataType & Photo);
- } else if(MASK_SET(type, VITA_DIR_TYPE_MASK_VIDEO)) {
- result = (current->metadata.dataType & Video);
- } else if(MASK_SET(type, VITA_DIR_TYPE_MASK_MUSIC)) {
- result = (current->metadata.dataType & Music);
- }
-
- if(MASK_SET(type, VITA_DIR_TYPE_MASK_ARTISTS)) {
- // unimplemented
- return 0;
- } else if(MASK_SET(type, VITA_DIR_TYPE_MASK_GENRES)) {
- // unimplemented
- return 0;
- } else if(MASK_SET(type, VITA_DIR_TYPE_MASK_PLAYLISTS)) {
- // unimplemented
- return 0;
- } else if(MASK_SET(type, VITA_DIR_TYPE_MASK_MONTH)) {
- // unimplemented
- return 0;
- } else if(type & (VITA_DIR_TYPE_MASK_ALL | VITA_DIR_TYPE_MASK_SONGS)) {
- result = result && (current->metadata.dataType & File);
- } else if(type & (VITA_DIR_TYPE_MASK_REGULAR)) {
- result = (obj_parent->metadata.ohfi == current->metadata.ohfiParent);
- }
-
- // TODO: Support other filter types
- return result;
-}
-
-void QListDB::dumpMetadataList(const metadata_t *p_head)
-{
- QMutexLocker locker(&mutex);
-
- while(p_head) {
- qDebug("Metadata: %s with OHFI %d", p_head->name, p_head->ohfi);
- p_head = p_head->next_metadata;
- }
-}
-
-bool QListDB::getObjectMetadata(int ohfi, metadata_t &metadata)
-{
- QMutexLocker locker(&mutex);
-
- CMAObject *obj = ohfiToObject(ohfi);
- if(obj) {
- //TODO: return the pointer instead of copying the struct
- metadata = obj->metadata;
- return true;
- }
- return false;
-}
-
-int QListDB::childObjectCount(int parent_ohfi)
-{
- return getObjectMetadatas(parent_ohfi, NULL);
-}
-
-bool QListDB::deleteEntry(int ohfi, int root_ohfi)
-{
- QMutexLocker locker(&mutex);
-
- if(root_ohfi) {
- return removeInternal(object_list[root_ohfi], ohfi);
- } else {
- for(map_list::iterator root = object_list.begin(); root != object_list.end(); ++root) {
- if(removeInternal(*root, ohfi)) {
- return true;
- }
- }
- }
- return false;
-}
-
-bool QListDB::getObjectList(int ohfi, metadata_t **metadata)
-{
- find_data iters;
- if(find(ohfi, iters)) {
- CMAObject *object;
- do {
- object = *iters.it;
- *metadata = &object->metadata;
- metadata = &(*metadata)->next_metadata;
- *metadata = NULL;
- object = *++iters.it;
- } while(iters.it != iters.end && object->metadata.ohfiParent >= OHFI_OFFSET);
- return true;
- }
- return false;
-}
-
-
-int QListDB::getObjectMetadatas(int parent_ohfi, metadata_t **metadata, int index, int max_number)
-{
- QMutexLocker locker(&mutex);
-
- CMARootObject *obj_parent = static_cast(ohfiToObject(parent_ohfi));
-
- if(obj_parent == NULL) {
- return 0;
- }
-
- if(obj_parent->metadata.dataType & File) {
- *metadata = &obj_parent->metadata;
- return 1;
- }
-
- int type = obj_parent->metadata.type;
-
- if(obj_parent->metadata.ohfi < OHFI_OFFSET && obj_parent->filters) { // if we have filters
- if(parent_ohfi == obj_parent->metadata.ohfi) { // if we are looking at root
- return obj_parent->getFilters(metadata);
- } else { // we are looking at a filter
- for(int j = 0; j < obj_parent->num_filters; j++) {
- if(obj_parent->filters[j].ohfi == parent_ohfi) {
- type = obj_parent->filters[j].type;
- break;
- }
- }
- }
- }
-
- int offset = 0;
- int numObjects = 0;
- metadata_t temp = metadata_t();
- metadata_t *tail = &temp;
-
- for(map_list::iterator root = object_list.begin(); root != object_list.end(); ++root) {
- for(root_list::iterator object = (*root).begin(); object != (*root).end(); ++object) {
- if(acceptFilteredObject(obj_parent, *object, type)) {
- if(offset++ >= index) {
- tail->next_metadata = &(*object)->metadata;
- tail = tail->next_metadata;
- numObjects++;
- }
-
- if(max_number > 0 && numObjects >= max_number) {
- break;
- }
- }
- }
-
- if(numObjects > 0) {
- break;
- }
- }
-
- tail->next_metadata = NULL;
-
- if(metadata != NULL) {
- *metadata = temp.next_metadata;
- }
-
- return numObjects;
-}
-
-qint64 QListDB::getObjectSize(int ohfi)
-{
- QMutexLocker locker(&mutex);
-
- CMAObject *obj = ohfiToObject(ohfi);
- return obj ? obj->metadata.size : -1;
-}
-
-int QListDB::getPathId(const char *name, int ohfi)
-{
- QMutexLocker locker(&mutex);
-
- for(map_list::iterator root = object_list.begin(); root != object_list.end(); ++root) {
-
- if(ohfi && (*root).first()->metadata.ohfi != ohfi) {
- continue;
- }
- CMAObject *obj = pathToObjectInternal(*root, name);
-
- if(obj) {
- return obj->metadata.ohfi;
- }
- }
- return 0;
-}
-
-int QListDB::insertObjectEntry(const QString &path, const QString &name, int parent_ohfi)
-{
- QMutexLocker locker(&mutex);
-
- CMAObject *parent_obj = ohfiToObject(parent_ohfi);
-
- for(map_list::iterator root = object_list.begin(); root != object_list.end(); ++root) {
- root_list *cat_list = &(*root);
- root_list::const_iterator it = qBinaryFind(cat_list->begin(), cat_list->end(), parent_obj, QListDB::lessThanComparator);
-
- if(it != cat_list->end()) {
- CMAObject *newobj = new CMAObject(parent_obj);
-
- // get the root object
- while(parent_obj->parent) {
- parent_obj = parent_obj->parent;
- }
-
- QFileInfo info(path, name);
- newobj->initObject(info, parent_obj->metadata.dataType);
- cat_list->append(newobj);
- return newobj->metadata.ohfi;
- }
- }
-
- return 0;
-}
-
-QString QListDB::getAbsolutePath(int ohfi)
-{
- QMutexLocker locker(&mutex);
- CMAObject *obj = ohfiToObject(ohfi);
- return obj ? obj->m_path : NULL;
-}
-
-QString QListDB::getRelativePath(int ohfi)
-{
- QMutexLocker locker(&mutex);
- CMAObject *obj = ohfiToObject(ohfi);
- return obj ? obj->metadata.path : NULL;
-}
-
-bool QListDB::renameObject(int ohfi, const QString &name)
-{
- QMutexLocker locker(&mutex);
-
- CMAObject *root = ohfiToObject(ohfi);
-
- if(!root) {
- return false;
- }
-
- //rename the current object
- root->rename(name);
- QListDB::find_data iters;
- find(root->metadata.ohfi, iters);
-
- // rename the rest of the list only if has the renamed parent in some part of the chain
- while(iters.it != iters.end) {
- CMAObject *obj = *iters.it++;
-
- if(obj->hasParent(root)) {
- obj->refreshPath();
- }
- }
-
- return true;
-}
-
-void QListDB::setObjectSize(int ohfi, qint64 size)
-{
- QMutexLocker locker(&mutex);
- CMAObject *obj = ohfiToObject(ohfi);
-
- if(obj) {
- obj->updateObjectSize(size);
- }
-}
-
-int QListDB::getRootId(int ohfi)
-{
- QMutexLocker locker(&mutex);
- CMAObject *obj = ohfiToObject(ohfi);
-
- if(!obj) {
- return 0;
- }
-
- while(obj->parent) {
- obj = obj->parent;
- }
-
- return obj->metadata.ohfi;
-}
-
-int QListDB::getParentId(int ohfi)
-{
- QMutexLocker locker(&mutex);
- CMAObject *obj = ohfiToObject(ohfi);
-
- return obj ? obj->metadata.ohfiParent : 0;
-}
diff --git a/src/qlistdb.h b/src/qlistdb.h
deleted file mode 100644
index 2d9d357..0000000
--- a/src/qlistdb.h
+++ /dev/null
@@ -1,95 +0,0 @@
-/*
- * QCMA: Cross-platform content manager assistant for the PS Vita
- *
- * Copyright (C) 2013 Codestation
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
-
-#ifndef QLISTDB_H
-#define QLISTDB_H
-
-#include "database.h"
-#include "cmarootobject.h"
-
-#include
-#include
-#include
-#include
-#include
-
-#include
-
-class QListDB : public Database
-{
- Q_OBJECT
-public:
- explicit QListDB(QObject *parent = 0);
- ~QListDB();
-
- bool load();
- bool rescan();
- void close();
- void clear();
-
- bool reload(bool &prepared);
- void setUUID(const QString &uuid);
-
- int childObjectCount(int parent_ohfi);
- bool deleteEntry(int ohfi, int root_ohfi = 0);
- QString getAbsolutePath(int ohfi);
- bool getObjectList(int ohfi, metadata_t **metadata);
- bool getObjectMetadata(int ohfi, metadata_t &metadata);
- int getObjectMetadatas(int parent_ohfi, metadata_t **metadata, int index = 0, int max_number = 0);
- qint64 getObjectSize(int ohfi);
- int getParentId(int ohfi);
- int getPathId(const char *name, int ohfi);
- QString getRelativePath(int ohfi);
- int getRootId(int ohfi);
- int insertObjectEntry(const QString &path, const QString &name, int parent_ohfi);
- bool renameObject(int ohfi, const QString &name);
- void setObjectSize(int ohfi, qint64 size);
- void freeMetadata(metadata_t *metadata) {
- Q_UNUSED(metadata);
- }
-
-private:
- typedef struct {
- QList::const_iterator it;
- QList