From 80f19e5d2343f5310877a5f3a617aa7ca62ef2d0 Mon Sep 17 00:00:00 2001 From: codestation Date: Fri, 28 Mar 2014 10:07:13 -0430 Subject: [PATCH 01/22] New qcma headless app. Updated changelog. Bumped version to 0.3.0. --- ChangeLog | 11 ++ qcma.pro | 181 ++-------------------------- qcma_cli.pro | 28 +++++ qcma_common.pri | 121 +++++++++++++++++++ qcma_gui.pro | 69 +++++++++++ src/cli/headlessmanager.cpp | 135 +++++++++++++++++++++ src/cli/headlessmanager.h | 62 ++++++++++ src/cli/main_cli.cpp | 115 ++++++++++++++++++ src/cli/singlecoreapplication.cpp | 69 +++++++++++ src/cli/singlecoreapplication.h | 50 ++++++++ src/cmaclient.cpp | 1 - src/cmaevent.cpp | 1 + src/forms/backupmanagerform.cpp | 4 +- src/forms/backupmanagerform.ui | 2 +- src/{ => gui}/clientmanager.cpp | 0 src/{ => gui}/clientmanager.h | 2 +- src/{ => gui}/filterlineedit.cpp | 0 src/{ => gui}/filterlineedit.h | 0 src/{ => gui}/kdenotifier.cpp | 0 src/{ => gui}/kdenotifier.h | 0 src/{ => gui}/main.cpp | 0 src/{ => gui}/mainwidget.cpp | 0 src/{ => gui}/mainwidget.h | 0 src/{ => gui}/singleapplication.cpp | 0 src/{ => gui}/singleapplication.h | 0 src/httpdownloader.cpp | 7 +- src/sqlitedb.cpp | 54 +++++---- 27 files changed, 712 insertions(+), 200 deletions(-) create mode 100644 qcma_cli.pro create mode 100644 qcma_common.pri create mode 100644 qcma_gui.pro create mode 100644 src/cli/headlessmanager.cpp create mode 100644 src/cli/headlessmanager.h create mode 100644 src/cli/main_cli.cpp create mode 100644 src/cli/singlecoreapplication.cpp create mode 100644 src/cli/singlecoreapplication.h rename src/{ => gui}/clientmanager.cpp (100%) rename src/{ => gui}/clientmanager.h (98%) rename src/{ => gui}/filterlineedit.cpp (100%) rename src/{ => gui}/filterlineedit.h (100%) rename src/{ => gui}/kdenotifier.cpp (100%) rename src/{ => gui}/kdenotifier.h (100%) rename src/{ => gui}/main.cpp (100%) rename src/{ => gui}/mainwidget.cpp (100%) rename src/{ => gui}/mainwidget.h (100%) rename src/{ => gui}/singleapplication.cpp (100%) rename src/{ => gui}/singleapplication.h (100%) diff --git a/ChangeLog b/ChangeLog index 5169916..988e997 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,14 @@ +qcma (0.3.0) unstable; urgency=low + + * Set the default video codec to h264 is metadata skip is enabled. + * Delay the progress dialog by one second so it doesn't show on quick scans. + * Do not show the disconnect message if no connection is established. + * Show correct directory separators on Windows. + * Show if savedata, updates or dlc are present on backup manager. + * New database backend. Disabled for now. + + -- codestation Thu, 28 Mar 2014 00:00:00 -0000 + qcma (0.2.8) unstable; urgency=low * Fixed bug where USB transfers couldn't be cancelled. diff --git a/qcma.pro b/qcma.pro index 4adebd9..724186a 100644 --- a/qcma.pro +++ b/qcma.pro @@ -1,176 +1,13 @@ -#------------------------------------------------- -# -# Project created by QtCreator 2013-07-23T15:34:17 -# -#------------------------------------------------- +-#------------------------------------------------- +-# +-# Project created by QtCreator 2013-07-23T15:34:17 +-# +-#------------------------------------------------- -QT += core \ - gui \ - widgets \ - network \ - sql +TEMPLATE = subdirs +SUBDIRS = qcma_gui.pro -TARGET = qcma - -VERSION = 0.2.9 - -TEMPLATE = app - -SOURCES += src/main.cpp \ - src/capability.cpp \ - src/cmaobject.cpp \ - src/cmarootobject.cpp \ - src/cmautils.cpp \ - src/mainwidget.cpp \ - src/singleapplication.cpp \ - src/sforeader.cpp \ - src/cmaclient.cpp \ - src/cmabroadcast.cpp \ - src/avdecoder.cpp \ - src/cmaevent.cpp \ - src/clientmanager.cpp \ - src/filterlineedit.cpp \ - src/dds.cpp \ - src/sqlitedb.cpp \ - src/httpdownloader.cpp \ - src/qlistdb.cpp \ - src/database.cpp \ -# forms - src/forms/backupitem.cpp \ - src/forms/backupmanagerform.cpp \ - src/forms/configwidget.cpp \ - src/forms/confirmdialog.cpp \ - src/forms/pinform.cpp \ - src/forms/progressform.cpp - -HEADERS += \ - src/capability.h \ - src/cmaobject.h \ - src/cmarootobject.h \ - src/cmautils.h \ - src/mainwidget.h \ - src/singleapplication.h \ - src/sforeader.h \ - src/cmaclient.h \ - src/cmabroadcast.h \ - src/avdecoder.h \ - src/cmaevent.h \ - src/clientmanager.h \ - src/filterlineedit.h \ - src/dds.h \ - src/sqlitedb.h \ - src/httpdownloader.h \ - src/qlistdb.h \ - src/database.h \ -# forms - src/forms/backupitem.h \ - src/forms/backupmanagerform.h \ - src/forms/configwidget.h \ - src/forms/confirmdialog.h \ - src/forms/pinform.h \ - src/forms/progressform.h - -FORMS += \ - src/forms/configwidget.ui \ - src/forms/backupmanagerform.ui \ - src/forms/backupitem.ui \ - src/forms/confirmdialog.ui \ - src/forms/progressform.ui \ - src/forms/pinform.ui - -TRANSLATIONS += \ - resources/translations/qcma_es.ts \ - resources/translations/qcma_ja.ts - -OTHER_FILES += \ - resources/xml/psp2-updatelist.xml \ - resources/images/psv_icon.png \ - resources/images/psv_icon_16.png \ - resources/images/qcma.png \ - resources/qcma.desktop \ - qcma.rc - -INCLUDEPATH += src/ - -RESOURCES += qcmares.qrc translations.qrc - -# find packages using pkg-config -CONFIG += link_pkgconfig -PKGCONFIG += libvitamtp libavformat libavcodec libavutil libswscale - -# custom CXXFLAGS -QMAKE_CXXFLAGS += -Wno-write-strings -Wall -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS - -#Linux-only config +# Compile the headless binary only on Linux because it depends on dbus unix:!macx { - # largefile support - DEFINES += _FILE_OFFSET_BITS=64 _LARGEFILE_SOURCE - - # installation prefix - isEmpty(PREFIX) { - PREFIX = /usr/local - } - - BINDIR = $$PREFIX/bin - DATADIR = $$PREFIX/share - - # config for desktop file and icon - desktop.path = $$DATADIR/applications/$${TARGET} - desktop.files += resources/$${TARGET}.desktop - - icon64.path = $$DATADIR/icons/hicolor/64x64/apps - icon64.files += resources/images/$${TARGET}.png - - target.path = $$BINDIR - INSTALLS += target desktop icon64 - - # KDE support - ENABLE_KDE { - greaterThan(QT_MAJOR_VERSION, 4) { - error("ENABLE_KDE can only be used with Qt4") - } - LIBS += -lkdeui - DEFINES += ENABLE_KDE_NOTIFIER=1 - SOURCES += src/kdenotifier.cpp - HEADERS += src/kdenotifier.h - } -} - -# Windows config -win32 { - # Windows icon - RC_FILE = qcma.rc - # avoid alignment issues with newer mingw compiler - QMAKE_CXXFLAGS += -mno-ms-bitfields -} - -# OS X config -macx { - # OS X icon - ICON = resources/images/$${TARGET}.icns - # re-enable pkg-config on OS X (brew installs pkg-config files) - QT_CONFIG -= no-pkg-config -} - - -# try to get the current git version + hash -QCMA_GIT_VERSION=$$system(git describe --tags) - -#use the generic version if the above command fails (no git executable or metadata) -isEmpty(QCMA_GIT_VERSION) { - DEFINES += QCMA_VER=\\\"$$VERSION\\\" -} else { - DEFINES += QCMA_VER=\\\"$$QCMA_GIT_VERSION\\\" -} - -GET_HASHES { - # try to get the current git commit and branch - QCMA_GIT_HASH=$$system(git rev-parse --short HEAD) - QCMA_GIT_BRANCH=$$system(git rev-parse --abbrev-ref HEAD) - - # pass the current git commit hash - !isEmpty(QCMA_GIT_HASH):!isEmpty(QCMA_GIT_BRANCH) { - DEFINES += QCMA_BUILD_HASH=\\\"$$QCMA_GIT_HASH\\\" - DEFINES += QCMA_BUILD_BRANCH=\\\"$$QCMA_GIT_BRANCH\\\" - } + SUBDIRS += qcma_cli.pro } diff --git a/qcma_cli.pro b/qcma_cli.pro new file mode 100644 index 0000000..bd138b1 --- /dev/null +++ b/qcma_cli.pro @@ -0,0 +1,28 @@ +include(qcma_common.pri) + +QT += dbus + +TARGET = qcma_cli + +SOURCES += \ + src/cli/main_cli.cpp \ + src/cli/singlecoreapplication.cpp \ + src/cli/headlessmanager.cpp + +HEADERS += \ + src/cli/singlecoreapplication.h \ + src/cli/headlessmanager.h + +# Linux-only config +unix:!macx { + target.path = $$BINDIR + + INSTALLS += target +} + +# Create the introspection XML +system(qdbuscpp2xml -M -s src/cli/headlessmanager.h -o org.qcma.HeadlessManager.xml) + +# Create the helper class +DBUS_ADAPTORS = org.qcma.HeadlessManager.xml + diff --git a/qcma_common.pri b/qcma_common.pri new file mode 100644 index 0000000..567e478 --- /dev/null +++ b/qcma_common.pri @@ -0,0 +1,121 @@ +#------------------------------------------------- +# +# Project created by QtCreator 2013-07-23T15:34:17 +# +#------------------------------------------------- + +QT += core \ + network \ + sql + +VERSION = 0.3.0 + +TEMPLATE = app + +SOURCES += \ + src/capability.cpp \ + src/cmaobject.cpp \ + src/cmarootobject.cpp \ + src/cmautils.cpp \ + src/sforeader.cpp \ + src/cmaclient.cpp \ + src/cmabroadcast.cpp \ + src/avdecoder.cpp \ + src/cmaevent.cpp \ + src/dds.cpp \ + src/sqlitedb.cpp \ + src/httpdownloader.cpp \ + src/qlistdb.cpp \ + src/database.cpp \ + +HEADERS += \ + src/capability.h \ + src/cmaobject.h \ + src/cmarootobject.h \ + src/cmautils.h \ + src/sforeader.h \ + src/cmaclient.h \ + src/cmabroadcast.h \ + src/avdecoder.h \ + src/cmaevent.h \ + src/dds.h \ + src/sqlitedb.h \ + src/httpdownloader.h \ + src/qlistdb.h \ + src/database.h \ + +TRANSLATIONS += \ + resources/translations/qcma_es.ts \ + resources/translations/qcma_ja.ts + +OTHER_FILES += \ + resources/xml/psp2-updatelist.xml \ + resources/images/psv_icon.png \ + resources/images/psv_icon_16.png \ + resources/images/qcma.png \ + resources/qcma.desktop \ + qcma.rc + +INCLUDEPATH += src/ + +RESOURCES += qcmares.qrc translations.qrc + +# find packages using pkg-config +CONFIG += link_pkgconfig +PKGCONFIG += libvitamtp libavformat libavcodec libavutil libswscale + +# custom CXXFLAGS +QMAKE_CXXFLAGS += -Wno-write-strings -Wall -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS + +#Linux-only config +unix:!macx { + # largefile support + DEFINES += _FILE_OFFSET_BITS=64 _LARGEFILE_SOURCE + + # installation prefix + isEmpty(PREFIX) { + PREFIX = /usr/local + } + + BINDIR = $$PREFIX/bin + DATADIR = $$PREFIX/share +} + +# Windows config +win32 { + # Windows icon + RC_FILE = qcma.rc + # avoid alignment issues with newer mingw compiler + QMAKE_CXXFLAGS += -mno-ms-bitfields +} + +# OS X config +macx { + # OS X icon + ICON = resources/images/$${TARGET}.icns + # re-enable pkg-config on OS X (brew installs pkg-config files) + QT_CONFIG -= no-pkg-config +} + + +# try to get the current git version + hash +QCMA_GIT_VERSION=$$system(git describe --tags) + +#use the generic version if the above command fails (no git executable or metadata) +isEmpty(QCMA_GIT_VERSION) { + DEFINES += QCMA_VER=\\\"$$VERSION\\\" +} else { + DEFINES += QCMA_VER=\\\"$$QCMA_GIT_VERSION\\\" +} + +GET_HASHES { + # try to get the current git commit and branch + QCMA_GIT_HASH=$$system(git rev-parse --short HEAD) + QCMA_GIT_BRANCH=$$system(git rev-parse --abbrev-ref HEAD) + + # pass the current git commit hash + !isEmpty(QCMA_GIT_HASH):!isEmpty(QCMA_GIT_BRANCH) { + DEFINES += QCMA_BUILD_HASH=\\\"$$QCMA_GIT_HASH\\\" + DEFINES += QCMA_BUILD_BRANCH=\\\"$$QCMA_GIT_BRANCH\\\" + } +} diff --git a/qcma_gui.pro b/qcma_gui.pro new file mode 100644 index 0000000..c86ff89 --- /dev/null +++ b/qcma_gui.pro @@ -0,0 +1,69 @@ +include(qcma_common.pri) + +TARGET = qcma + +QT += \ + gui \ + widgets + +SOURCES += \ + src/gui/main.cpp \ + src/gui/mainwidget.cpp \ + src/gui/singleapplication.cpp \ + src/gui/clientmanager.cpp \ + src/gui/filterlineedit.cpp \ +# forms + src/forms/backupitem.cpp \ + src/forms/backupmanagerform.cpp \ + src/forms/configwidget.cpp \ + src/forms/confirmdialog.cpp \ + src/forms/pinform.cpp \ + src/forms/progressform.cpp + +HEADERS += \ + src/gui/mainwidget.h \ + src/gui/singleapplication.h \ + src/gui/clientmanager.h \ + src/gui/filterlineedit.h \ +# forms + src/forms/backupitem.h \ + src/forms/backupmanagerform.h \ + src/forms/configwidget.h \ + src/forms/confirmdialog.h \ + src/forms/pinform.h \ + src/forms/progressform.h + +FORMS += \ + src/forms/configwidget.ui \ + src/forms/backupmanagerform.ui \ + src/forms/backupitem.ui \ + src/forms/confirmdialog.ui \ + src/forms/progressform.ui \ + src/forms/pinform.ui + +#Linux-only config +unix:!macx { + DATADIR = $$PREFIX/share + + # config for desktop file and icon + desktop.path = $$DATADIR/applications/$${TARGET} + desktop.files += resources/$${TARGET}.desktop + + icon64.path = $$DATADIR/icons/hicolor/64x64/apps + icon64.files += resources/images/$${TARGET}.png + + target.path = $$BINDIR + + INSTALLS += target desktop icon64 + + # KDE support + ENABLE_KDE { + greaterThan(QT_MAJOR_VERSION, 4) { + error("ENABLE_KDE can only be used with Qt4") + } + LIBS += -lkdeui + DEFINES += ENABLE_KDE_NOTIFIER=1 + SOURCES += src/kdenotifier.cpp + HEADERS += src/kdenotifier.h + } +} diff --git a/src/cli/headlessmanager.cpp b/src/cli/headlessmanager.cpp new file mode 100644 index 0000000..38334db --- /dev/null +++ b/src/cli/headlessmanager.cpp @@ -0,0 +1,135 @@ +/* + * 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 "cmaclient.h" +#include "cmautils.h" +#include "sqlitedb.h" +#include "qlistdb.h" +#include "headlessmanager.h" +#include "headlessmanager_adaptor.h" + +#include +#include +#include + +HeadlessManager::HeadlessManager(QObject *parent) : + QObject(parent), dbus_conn(QDBusConnection::sessionBus()) +{ + new HeadlessManagerAdaptor(this); + QDBusConnection dbus = QDBusConnection::sessionBus(); + // expose qcma over dbus so the database update can be triggered + dbus.registerObject("/HeadlessManager", this); + dbus.registerService("org.qcma.HeadlessManager"); +} + +HeadlessManager::~HeadlessManager() +{ + VitaMTP_Cleanup(); + delete m_db; +} + +void HeadlessManager::refreshDatabase() +{ + if(m_db->load()) { + return; + } + + if(!m_db->rescan()) { + qDebug("No PS Vita system has been registered"); + } +} + +void HeadlessManager::start() +{ + if(VitaMTP_Init() < 0) { + qDebug("Cannot initialize VitaMTP library"); + return; + } + + if(QSettings().value("useMemoryStorage", true).toBool()) { + m_db = new QListDB(); + } else { + m_db = new SQLiteDB(); + } + + // initializing database for the first use + refreshDatabase(); + + // send a signal over dbus of the connected peers knows when the update is finished + connect(m_db, SIGNAL(updated(int)), this, SIGNAL(databaseUpdated(int))); + + thread_count = 0; + qDebug("Starting cma threads"); + CmaClient *client; + QSettings settings; + + if(!settings.value("disableUSB", false).toBool()) { + 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(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(refreshDatabase()), this, SLOT(refreshDatabase())); + + client->moveToThread(usb_thread); + usb_thread->start(); + thread_count++; + } + + if(!settings.value("disableWireless", false).toBool()) { + wireless_thread = new QThread(); + client = new CmaClient(m_db); + wireless_thread->setObjectName("wireless_thread"); + connect(wireless_thread, SIGNAL(started()), client, SLOT(connectWireless())); + 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(refreshDatabase()), this, SLOT(refreshDatabase())); + + client->moveToThread(wireless_thread); + wireless_thread->start(); + thread_count++; + } + + if(thread_count == 0) { + qDebug("You must enable at least USB or Wireless monitoring"); + } +} + +void HeadlessManager::stop() +{ + if(CmaClient::stop() < 0) { + QCoreApplication::quit(); + } +} + +void HeadlessManager::threadStopped() +{ + mutex.lock(); + if(--thread_count == 0) { + QCoreApplication::quit(); + } + mutex.unlock(); +} diff --git a/src/cli/headlessmanager.h b/src/cli/headlessmanager.h new file mode 100644 index 0000000..44c3733 --- /dev/null +++ b/src/cli/headlessmanager.h @@ -0,0 +1,62 @@ +/* + * 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 HEADLESSMANAGER_H +#define HEADLESSMANAGER_H + +#include "database.h" + +#include +#include +#include + +class HeadlessManager : public QObject +{ + Q_OBJECT + Q_CLASSINFO("D-Bus Interface", "org.qcma.HeadlessManager") + +public: + explicit HeadlessManager(QObject *parent = 0); + ~HeadlessManager(); + + void start(); + +private: + int thread_count; + QMutex mutex; + + Database *m_db; + + QThread *usb_thread; + QThread *wireless_thread; + QDBusConnection dbus_conn; + +signals: + void stopped(); + Q_SCRIPTABLE void databaseUpdated(int count); + +public slots: + void refreshDatabase(); + void stop(); + +private slots: + void threadStopped(); +}; + +#endif // HEADLESSMANAGER_H diff --git a/src/cli/main_cli.cpp b/src/cli/main_cli.cpp new file mode 100644 index 0000000..beee358 --- /dev/null +++ b/src/cli/main_cli.cpp @@ -0,0 +1,115 @@ +/* + * 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 "singlecoreapplication.h" +#include "headlessmanager.h" + +#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0) +void noMessageOutput(QtMsgType type, const QMessageLogContext &, const QString & str) +{ + const char * msg = str.toStdString().c_str(); +#else +void noMessageOutput(QtMsgType type, const char *msg) +{ +#endif + Q_UNUSED(type); + Q_UNUSED(msg); +} + +int main(int argc, char *argv[]) +{ + if(SingleCoreApplication::sendMessage(QObject::tr("A instance of QCMA is already running"))) { + return 0; + } + + SingleCoreApplication 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 + + 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 + + qDebug("Starting QCMA %s", QCMA_VER); + + 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 { + qDebug() << "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("qcma"); + app.setApplicationName("qcma"); + + HeadlessManager manager; + manager.start(); + + return app.exec(); +} diff --git a/src/cli/singlecoreapplication.cpp b/src/cli/singlecoreapplication.cpp new file mode 100644 index 0000000..8b37a58 --- /dev/null +++ b/src/cli/singlecoreapplication.cpp @@ -0,0 +1,69 @@ +/* + * 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 "singlecoreapplication.h" + +#include + +const int SingleCoreApplication::timeout = 500; +const QString SingleCoreApplication::SHARED_KEY = "QCMA_KEY"; + +SingleCoreApplication::SingleCoreApplication(int &argc, char **argv) : + QCoreApplication(argc, argv) +{ + server = new QLocalServer(this); + connect(server, SIGNAL(newConnection()), this, SLOT(receiveMessage())); + QLocalServer::removeServer(SHARED_KEY); + server->listen(SHARED_KEY); +} + +void SingleCoreApplication::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 SingleCoreApplication::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/cli/singlecoreapplication.h b/src/cli/singlecoreapplication.h new file mode 100644 index 0000000..4b6a154 --- /dev/null +++ b/src/cli/singlecoreapplication.h @@ -0,0 +1,50 @@ +/* + * 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 SINGLECOREAPPLICATION_H +#define SINGLECOREAPPLICATION_H + +#include +#include +#include +#include + +class SingleCoreApplication : public QCoreApplication +{ + Q_OBJECT +public: + explicit SingleCoreApplication(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 // SINGLECOREAPPLICATION_H diff --git a/src/cmaclient.cpp b/src/cmaclient.cpp index b843230..ce1d6c6 100644 --- a/src/cmaclient.cpp +++ b/src/cmaclient.cpp @@ -23,7 +23,6 @@ #include "cmaevent.h" #include "cmautils.h" -#include #include #include #include diff --git a/src/cmaevent.cpp b/src/cmaevent.cpp index d504b67..ac88139 100644 --- a/src/cmaevent.cpp +++ b/src/cmaevent.cpp @@ -504,6 +504,7 @@ void CmaEvent::vitaEventSendHttpObjectFromURL(vita_event_t *event, int eventId) data = res.readAll(); } else if(!offlineMode) { + qDebug("URL: %s", url); HTTPDownloader downloader(url); QThread *http_thread = new QThread(); http_thread->setObjectName("http_thread"); diff --git a/src/forms/backupmanagerform.cpp b/src/forms/backupmanagerform.cpp index 3f83244..230fd4d 100644 --- a/src/forms/backupmanagerform.cpp +++ b/src/forms/backupmanagerform.cpp @@ -23,7 +23,7 @@ #include "sforeader.h" #include "confirmdialog.h" #include "cmautils.h" -#include "filterlineedit.h" +#include "gui/filterlineedit.h" #include #include @@ -143,7 +143,7 @@ void BackupManagerForm::loadBackupListing(int index) m_db->mutex.lock(); - // get the item list + // get the item list metadata_t *meta = NULL; int row_count = m_db->getObjectMetadatas(ohfi, &meta); ui->tableWidget->setRowCount(row_count); diff --git a/src/forms/backupmanagerform.ui b/src/forms/backupmanagerform.ui index c8b4505..e66d749 100644 --- a/src/forms/backupmanagerform.ui +++ b/src/forms/backupmanagerform.ui @@ -131,7 +131,7 @@ FilterLineEdit QLineEdit -
filterlineedit.h
+
gui/filterlineedit.h
diff --git a/src/clientmanager.cpp b/src/gui/clientmanager.cpp similarity index 100% rename from src/clientmanager.cpp rename to src/gui/clientmanager.cpp diff --git a/src/clientmanager.h b/src/gui/clientmanager.h similarity index 98% rename from src/clientmanager.h rename to src/gui/clientmanager.h index 40fa562..57b41df 100644 --- a/src/clientmanager.h +++ b/src/gui/clientmanager.h @@ -20,7 +20,7 @@ #ifndef CLIENTMANAGER_H #define CLIENTMANAGER_H -#include "qlistdb.h" +#include "database.h" #include "forms/pinform.h" #include "forms/progressform.h" diff --git a/src/filterlineedit.cpp b/src/gui/filterlineedit.cpp similarity index 100% rename from src/filterlineedit.cpp rename to src/gui/filterlineedit.cpp diff --git a/src/filterlineedit.h b/src/gui/filterlineedit.h similarity index 100% rename from src/filterlineedit.h rename to src/gui/filterlineedit.h diff --git a/src/kdenotifier.cpp b/src/gui/kdenotifier.cpp similarity index 100% rename from src/kdenotifier.cpp rename to src/gui/kdenotifier.cpp diff --git a/src/kdenotifier.h b/src/gui/kdenotifier.h similarity index 100% rename from src/kdenotifier.h rename to src/gui/kdenotifier.h diff --git a/src/main.cpp b/src/gui/main.cpp similarity index 100% rename from src/main.cpp rename to src/gui/main.cpp diff --git a/src/mainwidget.cpp b/src/gui/mainwidget.cpp similarity index 100% rename from src/mainwidget.cpp rename to src/gui/mainwidget.cpp diff --git a/src/mainwidget.h b/src/gui/mainwidget.h similarity index 100% rename from src/mainwidget.h rename to src/gui/mainwidget.h diff --git a/src/singleapplication.cpp b/src/gui/singleapplication.cpp similarity index 100% rename from src/singleapplication.cpp rename to src/gui/singleapplication.cpp diff --git a/src/singleapplication.h b/src/gui/singleapplication.h similarity index 100% rename from src/singleapplication.h rename to src/gui/singleapplication.h diff --git a/src/httpdownloader.cpp b/src/httpdownloader.cpp index 41c2510..0fe0a4c 100644 --- a/src/httpdownloader.cpp +++ b/src/httpdownloader.cpp @@ -42,6 +42,7 @@ HTTPDownloader::HTTPDownloader(const QString &url, QObject *parent) : HTTPDownloader::~HTTPDownloader() { lengthMutex.unlock(); + dataAvailable.unlock(); free(buffer); } @@ -105,6 +106,8 @@ void HTTPDownloader::readyRead() downloadLeft -= bufferSize; + //qDebug("bufferSize: %li, downloadLeft: %li", bufferSize, downloadLeft); + if(bufferSize > 16384 || downloadLeft == 0) { dataAvailable.unlock(); } @@ -149,8 +152,10 @@ int HTTPDownloader::readCallback(unsigned char *data, unsigned long wantlen, uns void HTTPDownloader::error(QNetworkReply::NetworkError errorCode) { Q_UNUSED(errorCode); + QString error = reply->errorString(); - emit messageSent(tr("Network error: %1").arg(reply->errorString())); + qWarning() << "Network error:" << error; + emit messageSent(tr("Network error: %1").arg(error)); // set buffer to zero so a read callback can be aborted dataRead.lock(); diff --git a/src/sqlitedb.cpp b/src/sqlitedb.cpp index 039c248..064f42b 100644 --- a/src/sqlitedb.cpp +++ b/src/sqlitedb.cpp @@ -77,8 +77,8 @@ static const char create_apps[] = "CREATE TABLE IF NOT EXISTS application (" "app_type INTEGER)"; static const char create_virtual[] = "CREATE TABLE IF NOT EXISTS virtual_nodes (" - "object_id INTEGER PRIMARY KEY REFERENCES object_node(object_id) ON DELETE CASCADE," - "app_type INTEGER)"; + "object_id INTEGER PRIMARY KEY REFERENCES object_node(object_id) ON DELETE CASCADE," + "app_type INTEGER)"; static const char create_photos[] = "CREATE TABLE IF NOT EXISTS photos (" "object_id INTEGER PRIMARY KEY REFERENCES object_node(object_id) ON DELETE CASCADE," @@ -1246,55 +1246,65 @@ bool SQLiteDB::insertVirtualEntries() { int ohfi; - if((ohfi = insertNodeEntry("Folders", VITA_DIR_TYPE_MASK_REGULAR, Video)) > 0) + if((ohfi = insertNodeEntry("Folders", VITA_DIR_TYPE_MASK_REGULAR, Video)) > 0) { insertVirtualEntry(ohfi); - else + } else { return false; + } - if((ohfi = insertNodeEntry("All", VITA_DIR_TYPE_MASK_ALL, Video)) > 0) + if((ohfi = insertNodeEntry("All", VITA_DIR_TYPE_MASK_ALL, Video)) > 0) { insertVirtualEntry(ohfi); - else + } else { return false; + } - if((ohfi = insertNodeEntry("Folders", VITA_DIR_TYPE_MASK_REGULAR, Photo)) > 0) + if((ohfi = insertNodeEntry("Folders", VITA_DIR_TYPE_MASK_REGULAR, Photo)) > 0) { insertVirtualEntry(ohfi); - else + } else { return false; + } - if((ohfi = insertNodeEntry("Month", VITA_DIR_TYPE_MASK_MONTH, Photo)) > 0) + if((ohfi = insertNodeEntry("Month", VITA_DIR_TYPE_MASK_MONTH, Photo)) > 0) { insertVirtualEntry(ohfi); - else + } else { return false; + } - if((ohfi = insertNodeEntry("All", VITA_DIR_TYPE_MASK_ALL, Photo)) > 0) + if((ohfi = insertNodeEntry("All", VITA_DIR_TYPE_MASK_ALL, Photo)) > 0) { insertVirtualEntry(ohfi); - else + } else { return false; + } - if((ohfi = insertNodeEntry("Artists", VITA_DIR_TYPE_MASK_ARTISTS, Music)) > 0) + if((ohfi = insertNodeEntry("Artists", VITA_DIR_TYPE_MASK_ARTISTS, Music)) > 0) { insertVirtualEntry(ohfi); - else + } else { return false; + } - if((ohfi = insertNodeEntry("Albums", VITA_DIR_TYPE_MASK_ALBUMS, Music)) > 0) + if((ohfi = insertNodeEntry("Albums", VITA_DIR_TYPE_MASK_ALBUMS, Music)) > 0) { insertVirtualEntry(ohfi); - else + } else { return false; + } - if((ohfi = insertNodeEntry("Songs", VITA_DIR_TYPE_MASK_SONGS, Music)) > 0) + if((ohfi = insertNodeEntry("Songs", VITA_DIR_TYPE_MASK_SONGS, Music)) > 0) { insertVirtualEntry(ohfi); - else + } else { return false; + } - if((ohfi = insertNodeEntry("Genres", VITA_DIR_TYPE_MASK_GENRES, Music)) > 0) + if((ohfi = insertNodeEntry("Genres", VITA_DIR_TYPE_MASK_GENRES, Music)) > 0) { insertVirtualEntry(ohfi); - else + } else { return false; + } - if((ohfi = insertNodeEntry("Playlists", VITA_DIR_TYPE_MASK_PLAYLISTS, Music)) > 0) + if((ohfi = insertNodeEntry("Playlists", VITA_DIR_TYPE_MASK_PLAYLISTS, Music)) > 0) { insertVirtualEntry(ohfi); - else + } else { return false; + } return true; } From 538b62bdb365bf7def5978ce7d95be45d661f84b Mon Sep 17 00:00:00 2001 From: codestation Date: Fri, 28 Mar 2014 10:15:35 -0430 Subject: [PATCH 02/22] Updated readme --- README.md | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 1a3e314..175ef93 100644 --- a/README.md +++ b/README.md @@ -10,7 +10,7 @@ meant to be compatible with Linux, Windows and MAC OS X. The aim of this project is to provide an implementation that is on par with the official CMA and also offer some features missing in the original one. -#### Implemented features missing in OpenCMA (Yifan Lu CLI application) +#### Implemented features. * Metadata for PSP savedatas. * Basic metadata for single songs (album, artist, title, cover art). * Basic metadata for videos (duration, dimensions, thumbnail). @@ -24,14 +24,12 @@ official CMA and also offer some features missing in the original one. * SQLite backend for database. #### Planned features -* **UPNP bridge**: connect an existing UPNP server to interface with the Vita -using the wireless streaming feature. +* **Android version**: port of Qcma to Android. ## Dependencies * [Qt 4.x or 5.x](http://qt-project.org/) -* [VitaMTP](https://github.com/yifanlu/VitaMTP). Use my -[fork](https://github.com/codestation/VitaMTP) until the patches are merged upstream. +* [VitaMTP fork](https://github.com/codestation/VitaMTP) * [FFmpeg](hhttp://www.ffmpeg.org/) @@ -46,6 +44,8 @@ Contact me on [GitHub](https://github.com/codestation/) [Yifan Lu](https://github.com/yifanlu/vitamtp/) - for the vitamtp library and the reference implementation of OpenCMA. +[Xian Nox] (https://github.com/xiannox) - for the Wiki and various contributions. + #### License GPL v3: since some parts of QCMA are based on the reference implementation of OpenCMA. From f035b460d0bd5466a7d4ac57616fdc185dffba1c Mon Sep 17 00:00:00 2001 From: codestation Date: Fri, 28 Mar 2014 13:40:02 -0430 Subject: [PATCH 03/22] Moved TRANSLATIONS to main pro file so lrelease can find them. --- qcma.pro | 4 ++++ qcma_common.pri | 4 ---- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/qcma.pro b/qcma.pro index 724186a..73643c8 100644 --- a/qcma.pro +++ b/qcma.pro @@ -11,3 +11,7 @@ SUBDIRS = qcma_gui.pro unix:!macx { SUBDIRS += qcma_cli.pro } + +TRANSLATIONS += \ + resources/translations/qcma_es.ts \ + resources/translations/qcma_ja.ts diff --git a/qcma_common.pri b/qcma_common.pri index 567e478..9ccb8f6 100644 --- a/qcma_common.pri +++ b/qcma_common.pri @@ -44,10 +44,6 @@ HEADERS += \ src/qlistdb.h \ src/database.h \ -TRANSLATIONS += \ - resources/translations/qcma_es.ts \ - resources/translations/qcma_ja.ts - OTHER_FILES += \ resources/xml/psp2-updatelist.xml \ resources/images/psv_icon.png \ From 20cd8f80a0224d3cac556037250469f254080e4a Mon Sep 17 00:00:00 2001 From: codestation Date: Thu, 3 Apr 2014 14:45:10 -0430 Subject: [PATCH 04/22] Fix compilation of sqlite backend under Qt4. Fix .pro file. Add entry in debian rules to headless package. --- debian/control | 4 ++++ qcma.pro | 10 +++++----- src/sqlitedb.cpp | 14 +++++++------- 3 files changed, 16 insertions(+), 12 deletions(-) diff --git a/debian/control b/debian/control index 6e53455..02eed63 100644 --- a/debian/control +++ b/debian/control @@ -12,3 +12,7 @@ Architecture: any Depends: ${shlibs:Depends}, ${misc:Depends} Description: Content Manager Assistant for the PS Vita +Package: qcma-headless +Architecture: any +Depends: ${shlibs:Depends}, ${misc:Depends} +Description: Content Manager Assistant for the PS Vita (headless version) diff --git a/qcma.pro b/qcma.pro index 73643c8..6c0c47c 100644 --- a/qcma.pro +++ b/qcma.pro @@ -1,8 +1,8 @@ --#------------------------------------------------- --# --# Project created by QtCreator 2013-07-23T15:34:17 --# --#------------------------------------------------- +#------------------------------------------------- +# +# Project created by QtCreator 2013-07-23T15:34:17 +# +#------------------------------------------------- TEMPLATE = subdirs SUBDIRS = qcma_gui.pro diff --git a/src/sqlitedb.cpp b/src/sqlitedb.cpp index 064f42b..d1a582f 100644 --- a/src/sqlitedb.cpp +++ b/src/sqlitedb.cpp @@ -880,14 +880,14 @@ bool SQLiteDB::deleteEntry(int ohfi, int root_ohfi) void SQLiteDB::fillMetadata(const QSqlQuery &query, metadata_t &metadata) { - metadata.ohfi = query.value("ohfi").toInt(); - metadata.ohfiParent = query.value("parent").toInt(); - metadata.name = strdup(query.value("name").toByteArray().constData()); - metadata.path = strdup(query.value("path").toByteArray().constData()); + metadata.ohfi = query.value(0).toInt(); // ohfi + metadata.ohfiParent = query.value(1).toInt(); // parent + metadata.path = strdup(query.value(2).toByteArray().constData()); // path + metadata.name = strdup(query.value(3).toByteArray().constData()); // name metadata.type = VITA_DIR_TYPE_MASK_REGULAR; - metadata.dataType = (DataType)query.value("data_type").toInt(); - metadata.size = query.value("size").toULongLong(); - metadata.dateTimeCreated = query.value("date_created").toInt(); + metadata.dataType = (DataType)query.value(5).toInt(); // data_type + metadata.size = query.value(6).toULongLong(); // size + metadata.dateTimeCreated = query.value(7).toInt(); // date_created metadata.next_metadata = NULL; //TODO: fill the rest of the metadata } From 06363de75bd0fc71d29f9048c6d1d1f4ee930f7b Mon Sep 17 00:00:00 2001 From: codestation Date: Thu, 3 Apr 2014 15:22:19 -0430 Subject: [PATCH 05/22] Update httpdownloader class. --- src/httpdownloader.cpp | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/httpdownloader.cpp b/src/httpdownloader.cpp index 0fe0a4c..c0f468d 100644 --- a/src/httpdownloader.cpp +++ b/src/httpdownloader.cpp @@ -83,32 +83,32 @@ void HTTPDownloader::readyRead() dataRead.lock(); int currOffset = bufferSize; + if(bufferSize == 0) { bufferSize = reply->bytesAvailable(); + if(firstRead) { bufferSize += 8; currOffset += 8; - } - // start with a 16KiB buffer - buffer = (char *)malloc(16384 + 2048); - if(firstRead) { + + // start with a 16KiB buffer + buffer = (char *)malloc(16384); *(uint64_t *)buffer = m_contentLength; firstRead = false; } } else { bufferSize += reply->bytesAvailable(); - if(bufferSize > 16384 + 2048) { + + if(bufferSize > 16384) { buffer = (char *)realloc(buffer, bufferSize); } } - reply->read(buffer + currOffset, reply->bytesAvailable()); + reply->read(buffer + currOffset, reply->bytesAvailable()); downloadLeft -= bufferSize; - //qDebug("bufferSize: %li, downloadLeft: %li", bufferSize, downloadLeft); - - if(bufferSize > 16384 || downloadLeft == 0) { + if(bufferSize >= 16384 || downloadLeft == 0) { dataAvailable.unlock(); } dataRead.unlock(); From c88c2d34e947c4dcab5e23639fff02db9245d972 Mon Sep 17 00:00:00 2001 From: codestation Date: Thu, 3 Apr 2014 15:24:06 -0430 Subject: [PATCH 06/22] Fix missing headers under Qt4. --- src/cli/main_cli.cpp | 1 + src/httpdownloader.cpp | 1 + 2 files changed, 2 insertions(+) diff --git a/src/cli/main_cli.cpp b/src/cli/main_cli.cpp index beee358..1a28760 100644 --- a/src/cli/main_cli.cpp +++ b/src/cli/main_cli.cpp @@ -24,6 +24,7 @@ #include #include #include +#include #include #include #include diff --git a/src/httpdownloader.cpp b/src/httpdownloader.cpp index c0f468d..ddf4b68 100644 --- a/src/httpdownloader.cpp +++ b/src/httpdownloader.cpp @@ -19,6 +19,7 @@ #include "httpdownloader.h" +#include #include #include From 00f1c0eee247daefa596c5f15435bfacf911f843 Mon Sep 17 00:00:00 2001 From: codestation Date: Fri, 4 Apr 2014 11:45:53 -0430 Subject: [PATCH 07/22] Readd QImage includes. Do not remove gui lib for headless binary as it needs it to use Qimage. Rename headless package to qcma-cli. --- debian/control | 2 +- qcma_common.pri | 4 +--- qcma_gui.pro | 6 ++---- src/avdecoder.cpp | 1 + src/avdecoder.h | 1 - src/database.cpp | 1 + src/sqlitedb.cpp | 1 + 7 files changed, 7 insertions(+), 9 deletions(-) diff --git a/debian/control b/debian/control index 02eed63..25215aa 100644 --- a/debian/control +++ b/debian/control @@ -12,7 +12,7 @@ Architecture: any Depends: ${shlibs:Depends}, ${misc:Depends} Description: Content Manager Assistant for the PS Vita -Package: qcma-headless +Package: qcma-cli Architecture: any Depends: ${shlibs:Depends}, ${misc:Depends} Description: Content Manager Assistant for the PS Vita (headless version) diff --git a/qcma_common.pri b/qcma_common.pri index 9ccb8f6..29f0a42 100644 --- a/qcma_common.pri +++ b/qcma_common.pri @@ -4,9 +4,7 @@ # #------------------------------------------------- -QT += core \ - network \ - sql +QT += core network sql VERSION = 0.3.0 diff --git a/qcma_gui.pro b/qcma_gui.pro index c86ff89..984d645 100644 --- a/qcma_gui.pro +++ b/qcma_gui.pro @@ -1,10 +1,8 @@ include(qcma_common.pri) -TARGET = qcma +QT += gui widgets -QT += \ - gui \ - widgets +TARGET = qcma SOURCES += \ src/gui/main.cpp \ diff --git a/src/avdecoder.cpp b/src/avdecoder.cpp index c5b0142..f707a22 100644 --- a/src/avdecoder.cpp +++ b/src/avdecoder.cpp @@ -24,6 +24,7 @@ #include #include #include +#include #include AVDecoder::AvInit init; diff --git a/src/avdecoder.h b/src/avdecoder.h index 2797c2b..586dc98 100644 --- a/src/avdecoder.h +++ b/src/avdecoder.h @@ -20,7 +20,6 @@ #ifndef AVDECODER_H #define AVDECODER_H -#include #include extern "C" { diff --git a/src/database.cpp b/src/database.cpp index ec6a33a..4743638 100644 --- a/src/database.cpp +++ b/src/database.cpp @@ -1,6 +1,7 @@ #include "database.h" #include "avdecoder.h" +#include #include #include diff --git a/src/sqlitedb.cpp b/src/sqlitedb.cpp index d1a582f..56c2b34 100644 --- a/src/sqlitedb.cpp +++ b/src/sqlitedb.cpp @@ -26,6 +26,7 @@ #include #include #include +#include #if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0) #include From 1495154b353db6793eb1bfecf2bcc01e9dea29ff Mon Sep 17 00:00:00 2001 From: codestation Date: Fri, 4 Apr 2014 12:30:46 -0430 Subject: [PATCH 08/22] Updated readme and changelog. --- ChangeLog | 1 + README.md | 23 +++++++++++++++++++++++ 2 files changed, 24 insertions(+) diff --git a/ChangeLog b/ChangeLog index 988e997..f2ded89 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,6 @@ qcma (0.3.0) unstable; urgency=low + * Headless qcma version. * Set the default video codec to h264 is metadata skip is enabled. * Delay the progress dialog by one second so it doesn't show on quick scans. * Do not show the disconnect message if no connection is established. diff --git a/README.md b/README.md index 175ef93..f239865 100644 --- a/README.md +++ b/README.md @@ -26,6 +26,29 @@ official CMA and also offer some features missing in the original one. #### Planned features * **Android version**: port of Qcma to Android. +## Headless version + +There is a qcma_cli binary that doesn't need a X session running (useful for servers). +The daemon provides minimal interaction via dbus. Here are some usage examples: + +#### Send a signal to refresh the database + +``` +dbus-send --session --type=method_call --dest=org.qcma.HeadlessManager /HeadlessManager org.qcma.HeadlessManager.refreshDatabase +``` + +#### Send a signal to stop the daemon + +``` +dbus-send --session --type=method_call --dest=org.qcma.HeadlessManager /HeadlessManager org.qcma.HeadlessManager.stop +``` + +#### Receive confirmation when the database finished updating + +``` +dbus-monitor "type='signal',sender='org.qcma.HeadlessManager',member='databaseUpdated'" +``` + ## Dependencies * [Qt 4.x or 5.x](http://qt-project.org/) From 11e10f45cc7a3f0e635c768a87d4a417fcbbb1c8 Mon Sep 17 00:00:00 2001 From: codestation Date: Fri, 4 Apr 2014 13:58:48 -0430 Subject: [PATCH 09/22] Add debian install rules. --- debian/qcma-cli.install | 1 + debian/qcma.install | 3 +++ 2 files changed, 4 insertions(+) create mode 100644 debian/qcma-cli.install create mode 100644 debian/qcma.install diff --git a/debian/qcma-cli.install b/debian/qcma-cli.install new file mode 100644 index 0000000..4ed578d --- /dev/null +++ b/debian/qcma-cli.install @@ -0,0 +1 @@ +usr/bin/qcma_cli diff --git a/debian/qcma.install b/debian/qcma.install new file mode 100644 index 0000000..1aabfc8 --- /dev/null +++ b/debian/qcma.install @@ -0,0 +1,3 @@ +usr/bin/qcma +resources/qcma.desktop usr/share/applications/qcma +resources/images/qcma.png usr/share/icons/hicolor/64x64/apps From 00b76f308c33e666f9f597e7a10169765f4ea316 Mon Sep 17 00:00:00 2001 From: codestation Date: Sat, 19 Apr 2014 15:48:50 -0430 Subject: [PATCH 10/22] Changed read timestamps timezones to UTC. Fix QListDB::getObjectMetadatas not returning metadata when a single object was requested. Show size in GiB for backups. --- ChangeLog | 2 +- org.qcma.HeadlessManager.xml | 12 ++++++++++++ src/cmaobject.cpp | 8 ++++---- src/forms/backupmanagerform.cpp | 5 ++++- src/qlistdb.cpp | 6 ++++++ src/sqlitedb.cpp | 8 ++++---- 6 files changed, 31 insertions(+), 10 deletions(-) create mode 100644 org.qcma.HeadlessManager.xml diff --git a/ChangeLog b/ChangeLog index f2ded89..9591a22 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,7 +1,7 @@ qcma (0.3.0) unstable; urgency=low * Headless qcma version. - * Set the default video codec to h264 is metadata skip is enabled. + * Set the default video codec to h264 if metadata skip is enabled. * Delay the progress dialog by one second so it doesn't show on quick scans. * Do not show the disconnect message if no connection is established. * Show correct directory separators on Windows. diff --git a/org.qcma.HeadlessManager.xml b/org.qcma.HeadlessManager.xml new file mode 100644 index 0000000..73381aa --- /dev/null +++ b/org.qcma.HeadlessManager.xml @@ -0,0 +1,12 @@ + + + + + + + + + + + + diff --git a/src/cmaobject.cpp b/src/cmaobject.cpp index 6e0a3fc..0fe18a3 100644 --- a/src/cmaobject.cpp +++ b/src/cmaobject.cpp @@ -100,7 +100,7 @@ void CMAObject::loadSfoMetadata(const QString &path) title.chop(1); } metadata.data.saveData.savedataTitle = strdup(title.toStdString().c_str()); - metadata.data.saveData.dateTimeUpdated = QFileInfo(sfo).created().toTime_t(); + metadata.data.saveData.dateTimeUpdated = QFileInfo(sfo).created().toUTC().toTime_t(); } else { metadata.data.saveData.title = strdup(metadata.name); metadata.data.saveData.detail = strdup(""); @@ -116,7 +116,7 @@ void CMAObject::initObject(const QFileInfo &file, int file_type) metadata.ohfi = ohfi_count++; metadata.type = VITA_DIR_TYPE_MASK_REGULAR; // ignored for files - metadata.dateTimeCreated = file.created().toTime_t(); + metadata.dateTimeCreated = file.created().toUTC().toTime_t(); metadata.size = 0; DataType type = file.isFile() ? File : Folder; metadata.dataType = (DataType)(type | (parent->metadata.dataType & ~Folder)); @@ -143,7 +143,7 @@ void CMAObject::initObject(const QFileInfo &file, int file_type) Database::loadMusicMetadata(file.absoluteFilePath(), metadata); } else if(MASK_SET(metadata.dataType, Video | File)) { metadata.data.video.fileName = strdup(metadata.name); - metadata.data.video.dateTimeUpdated = file.created().toTime_t(); + metadata.data.video.dateTimeUpdated = file.created().toUTC().toTime_t(); metadata.data.video.statusType = 1; metadata.data.video.fileFormatType = FILE_FORMAT_MP4; metadata.data.video.parentalLevel = 0; @@ -161,7 +161,7 @@ void CMAObject::initObject(const QFileInfo &file, int file_type) metadata.data.photo.fileName = strdup(metadata.name); metadata.data.photo.fileFormatType = photo_list[file_type].file_format; metadata.data.photo.statusType = 1; - metadata.data.photo.dateTimeOriginal = file.created().toTime_t(); + metadata.data.photo.dateTimeOriginal = file.created().toUTC().toTime_t(); metadata.data.photo.numTracks = 1; metadata.data.photo.tracks = new media_track(); metadata.data.photo.tracks->type = VITA_TRACK_TYPE_PHOTO; diff --git a/src/forms/backupmanagerform.cpp b/src/forms/backupmanagerform.cpp index 230fd4d..6c0417a 100644 --- a/src/forms/backupmanagerform.cpp +++ b/src/forms/backupmanagerform.cpp @@ -188,7 +188,10 @@ void BackupManagerForm::loadBackupListing(int index) item->title = game_name; connect(item, SIGNAL(deleteEntry(BackupItem*)), this, SLOT(removeEntry(BackupItem*))); - QString size = readable_size(meta->size); + + // show better size info for multi GiB backups + bool use_gb = ohfi == VITA_OHFI_BACKUP && meta->size > 1024*1024*1024; + QString size = readable_size(meta->size, use_gb); QString info; diff --git a/src/qlistdb.cpp b/src/qlistdb.cpp index ed5f13a..538354a 100644 --- a/src/qlistdb.cpp +++ b/src/qlistdb.cpp @@ -383,12 +383,18 @@ bool QListDB::deleteEntry(int ohfi, int root_ohfi) int QListDB::getObjectMetadatas(int parent_ohfi, metadata_t **metadata, int index, int max_number) { QMutexLocker locker(&mutex); + CMARootObject *parent = static_cast(ohfiToObject(parent_ohfi)); if(parent == NULL) { return 0; } + if(parent->metadata.dataType & File) { + *metadata = &parent->metadata; + return 1; + } + int type = parent->metadata.type; if(parent->metadata.ohfi < OHFI_OFFSET && parent->filters) { // if we have filters diff --git a/src/sqlitedb.cpp b/src/sqlitedb.cpp index 56c2b34..6557717 100644 --- a/src/sqlitedb.cpp +++ b/src/sqlitedb.cpp @@ -527,13 +527,13 @@ bool SQLiteDB::insertSourceEntry(uint object_id, const QString &path, const QStr QFileInfo info(path, name); if(info.isFile()) { size = QVariant(info.size()); - date_created = QVariant(info.created().toTime_t()); + date_created = QVariant(info.created().toUTC().toTime_t()); } else { size = QVariant(QVariant::LongLong); date_created = QVariant(QVariant::UInt); } - date_modified = QVariant(info.lastModified().toTime_t()); + date_modified = QVariant(info.lastModified().toUTC().toTime_t()); QSqlQuery query; query.prepare("REPLACE INTO sources (object_id, path, size, date_created, date_modified)" @@ -756,7 +756,7 @@ uint SQLiteDB::insertPhotoEntry(const QString &path, const QString &name, int pa } QDateTime date = QFileInfo(path + "/" + name).created(); - date_created = date.toTime_t(); + date_created = date.toUTC().toTime_t(); QString month_created = date.toString("yyyy/MM"); width = img.width(); @@ -806,7 +806,7 @@ uint SQLiteDB::insertSavedataEntry(const QString &path, const QString &name, int title = reader.value("TITLE", utf8name.constData()); savedata_detail = reader.value("SAVEDATA_DETAIL", ""); savedata_directory = reader.value("SAVEDATA_DIRECTORY", utf8name.constData()); - date_updated = QFileInfo(path + "/" + name).lastModified().toTime_t(); + date_updated = QFileInfo(path + "/" + name).lastModified().toUTC().toTime_t(); } if((ohfi = insertDefaultEntry(path, name, title, parent, type)) == 0) { From 24af4d428edd03655ac9ebefc7334473d10a5003 Mon Sep 17 00:00:00 2001 From: codestation Date: Sat, 19 Apr 2014 15:51:39 -0430 Subject: [PATCH 11/22] Removed autogenerated xml file. --- .gitignore | 3 ++- org.qcma.HeadlessManager.xml | 12 ------------ 2 files changed, 2 insertions(+), 13 deletions(-) delete mode 100644 org.qcma.HeadlessManager.xml diff --git a/.gitignore b/.gitignore index 596c592..222fba6 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ qcma.pro.user* -*.qm \ No newline at end of file +*.qm +org.qcma.*.xml diff --git a/org.qcma.HeadlessManager.xml b/org.qcma.HeadlessManager.xml deleted file mode 100644 index 73381aa..0000000 --- a/org.qcma.HeadlessManager.xml +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - - - - - - - From a4c2301cabc02ddb6074ef123f7b1238ea79022e Mon Sep 17 00:00:00 2001 From: codestation Date: Sat, 19 Apr 2014 23:05:20 -0430 Subject: [PATCH 12/22] Added dbus interface for regular qcma. Added option to disable the systray: --no-systray. --- ChangeLog | 1 + qcma_cli.pro | 1 - qcma_gui.pro | 11 ++++++ src/gui/clientmanager.cpp | 1 + src/gui/clientmanager.h | 5 ++- src/gui/main.cpp | 4 ++- src/gui/mainwidget.cpp | 75 ++++++++++++++++++++++++++++++++------- src/gui/mainwidget.h | 28 ++++++++++++--- src/sqlitedb.cpp | 2 +- 9 files changed, 107 insertions(+), 21 deletions(-) diff --git a/ChangeLog b/ChangeLog index 9591a22..53355c9 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,6 +1,7 @@ qcma (0.3.0) unstable; urgency=low * Headless qcma version. + * Added dbus controls to qcma (Linux only) * Set the default video codec to h264 if metadata skip is enabled. * Delay the progress dialog by one second so it doesn't show on quick scans. * Do not show the disconnect message if no connection is established. diff --git a/qcma_cli.pro b/qcma_cli.pro index bd138b1..3d35592 100644 --- a/qcma_cli.pro +++ b/qcma_cli.pro @@ -25,4 +25,3 @@ system(qdbuscpp2xml -M -s src/cli/headlessmanager.h -o org.qcma.HeadlessManager. # Create the helper class DBUS_ADAPTORS = org.qcma.HeadlessManager.xml - diff --git a/qcma_gui.pro b/qcma_gui.pro index 984d645..a7bb793 100644 --- a/qcma_gui.pro +++ b/qcma_gui.pro @@ -65,3 +65,14 @@ unix:!macx { HEADERS += src/kdenotifier.h } } + +unix:!macx { + +QT += dbus + +# Create the introspection XML +system(qdbuscpp2xml -M -s src/gui/mainwidget.h -o org.qcma.ClientManager.xml) + +# Create the helper class +DBUS_ADAPTORS = org.qcma.ClientManager.xml +} diff --git a/src/gui/clientmanager.cpp b/src/gui/clientmanager.cpp index 7cce9d9..af0960e 100644 --- a/src/gui/clientmanager.cpp +++ b/src/gui/clientmanager.cpp @@ -45,6 +45,7 @@ void ClientManager::databaseUpdated(int count) } else { emit messageSent(tr("Database indexing aborted by user")); } + emit updated(count); } void ClientManager::showPinDialog(QString name, int pin) diff --git a/src/gui/clientmanager.h b/src/gui/clientmanager.h index 57b41df..a6af841 100644 --- a/src/gui/clientmanager.h +++ b/src/gui/clientmanager.h @@ -50,15 +50,18 @@ private: QThread *wireless_thread; signals: + void updated(int); void stopped(); void receivedPin(int); void deviceDisconnected(); void messageSent(QString); void deviceConnected(QString); +public slots: + void refreshDatabase(); + private slots: void threadStopped(); - void refreshDatabase(); void databaseUpdated(int count); void showPinDialog(QString name, int pin); }; diff --git a/src/gui/main.cpp b/src/gui/main.cpp index 1ebebe5..ac77830 100644 --- a/src/gui/main.cpp +++ b/src/gui/main.cpp @@ -110,8 +110,10 @@ int main(int argc, char *argv[]) //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(); + widget.prepareApplication(showSystray); // receive the message from another process QObject::connect(&app, SIGNAL(messageAvailable(QString)), &widget, SLOT(receiveMessage(QString))); diff --git a/src/gui/mainwidget.cpp b/src/gui/mainwidget.cpp index e6c178e..55e19f6 100644 --- a/src/gui/mainwidget.cpp +++ b/src/gui/mainwidget.cpp @@ -21,6 +21,10 @@ #include "cmaclient.h" #include "cmautils.h" +#ifdef Q_OS_LINUX +#include "clientmanager_adaptor.h" +#endif + #include "qlistdb.h" #include "sqlitedb.h" @@ -44,10 +48,32 @@ const QStringList MainWidget::path_list = QStringList() << "photoPath" << "music bool sleptOnce = false; +#ifdef Q_OS_LINUX +MainWidget::MainWidget(QWidget *parent) : + QWidget(parent), db(NULL), configForm(NULL), managerForm(NULL), backupForm(NULL), dbus_conn(QDBusConnection::sessionBus()) +{ + new ClientManagerAdaptor(this); + QDBusConnection dbus = QDBusConnection::sessionBus(); + // expose qcma over dbus so the database update can be triggered + dbus.registerObject("/ClientManager", this); + dbus.registerService("org.qcma.ClientManager"); +#ifndef ENABLE_KDE_NOTIFIER + trayIcon = NULL; +#else + notifierItem = NULL; +#endif +} +#else MainWidget::MainWidget(QWidget *parent) : QWidget(parent), db(NULL), configForm(NULL), managerForm(NULL), backupForm(NULL) { +#ifndef ENABLE_KDE_NOTIFIER + trayIcon = NULL; +#else + notifierItem = NULL; +#endif } +#endif void MainWidget::checkSettings() { @@ -101,7 +127,7 @@ void MainWidget::deviceDisconnect() receiveMessage(tr("The device has been disconnected")); } -void MainWidget::deviceConnected(QString message) +void MainWidget::deviceConnect(QString message) { #ifndef ENABLE_KDE_NOTIFIER #ifndef Q_OS_WIN32 @@ -117,7 +143,7 @@ void MainWidget::deviceConnected(QString message) receiveMessage(message); } -void MainWidget::prepareApplication() +void MainWidget::prepareApplication(bool showSystray) { //TODO: delete database before exit if(QSettings().value("useMemoryStorage", true).toBool()) { @@ -130,7 +156,11 @@ void MainWidget::prepareApplication() backupForm = new BackupManagerForm(db, this); managerForm = new ClientManager(db, this); connectSignals(); - createTrayIcon(); + + if(showSystray) { + createTrayIcon(); + } + checkSettings(); } @@ -138,19 +168,22 @@ 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, SLOT(deviceConnected(QString))); - connect(managerForm, SIGNAL(deviceDisconnected()), this, SLOT(deviceDisconnect())); - connect(managerForm, SIGNAL(messageSent(QString)), this, SLOT(receiveMessage(QString))); - - //backupForm.db = managerForm.db; + 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) { #ifndef ENABLE_KDE_NOTIFIER - trayIcon->setToolTip(message); + if(trayIcon) { + trayIcon->setToolTip(message); + } #else - notifierItem->setToolTipSubTitle(message); + if(notifierItem) { + notifierItem->setToolTipSubTitle(message); + } #endif } @@ -189,6 +222,16 @@ void MainWidget::showAboutQt() QMessageBox::aboutQt(this); } +void MainWidget::openConfig() +{ + configForm->open(); +} + +void MainWidget::refreshDatabase() +{ + managerForm->refreshDatabase(); +} + void MainWidget::createTrayIcon() { options = new QAction(tr("&Settings"), this); @@ -198,9 +241,9 @@ void MainWidget::createTrayIcon() about_qt = new QAction(tr("Abou&t Qt"), this); quit = new QAction(tr("&Quit"), this); - connect(options, SIGNAL(triggered()), configForm, SLOT(open())); + connect(options, SIGNAL(triggered()), this, SLOT(openConfig())); connect(backup, SIGNAL(triggered()), this, SLOT(openManager())); - connect(reload, SIGNAL(triggered()), managerForm, SLOT(refreshDatabase())); + connect(reload, SIGNAL(triggered()), this, SLOT(refreshDatabase())); connect(about, SIGNAL(triggered()), this, SLOT(showAboutDialog())); connect(about_qt, SIGNAL(triggered()), this, SLOT(showAboutQt())); connect(quit, SIGNAL(triggered()), this, SLOT(stopServer())); @@ -241,6 +284,10 @@ void MainWidget::createTrayIcon() notifierItem->setToolTipSubTitle(tr("Disconnected")); notifierItem->setStandardActionsEnabled(false); #endif + + 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) @@ -265,7 +312,9 @@ void MainWidget::receiveMessage(QString message) MainWidget::~MainWidget() { #ifndef ENABLE_KDE_NOTIFIER - trayIcon->hide(); + if(trayIcon) { + trayIcon->hide(); + } #endif delete db; } diff --git a/src/gui/mainwidget.h b/src/gui/mainwidget.h index ac80db3..a0be5b9 100644 --- a/src/gui/mainwidget.h +++ b/src/gui/mainwidget.h @@ -34,16 +34,22 @@ #include "kdenotifier.h" #endif +#ifdef Q_OS_LINUX +#include +#endif + #include class MainWidget : public QWidget { Q_OBJECT + Q_CLASSINFO("D-Bus Interface", "org.qcma.ClientManager") + public: explicit MainWidget(QWidget *parent = 0); ~MainWidget(); - void prepareApplication(); + void prepareApplication(bool showSystray); private: void connectSignals(); @@ -68,6 +74,10 @@ private: QAction *about; QAction *about_qt; +#ifdef Q_OS_LINUX + QDBusConnection dbus_conn; +#endif + #ifndef ENABLE_KDE_NOTIFIER QSystemTrayIcon *trayIcon; #else @@ -76,12 +86,22 @@ private: const static QStringList path_list; -private slots: - void stopServer(); +signals: + Q_SCRIPTABLE void deviceConnected(QString); + Q_SCRIPTABLE void deviceDisconnected(); + Q_SCRIPTABLE void databaseUpdated(int count); + Q_SCRIPTABLE void messageReceived(QString message); + +public slots: + void openConfig(); void openManager(); void showAboutQt(); void showAboutDialog(); - void deviceConnected(QString message); + void refreshDatabase(); + void stopServer(); + +private slots: + void deviceConnect(QString message); void deviceDisconnect(); void dialogResult(int result); void receiveMessage(QString message); diff --git a/src/sqlitedb.cpp b/src/sqlitedb.cpp index 6557717..2ae99c0 100644 --- a/src/sqlitedb.cpp +++ b/src/sqlitedb.cpp @@ -386,7 +386,7 @@ int SQLiteDB::insertObjectEntry(const QString &path, const QString &name, int pa int SQLiteDB::insertObjectEntryInternal(const QString &path, const QString &name, int parent_ohfi, int root_ohfi) { - int ohfi; + int ohfi = 0; QFileInfo info(path, name); if(info.isDir()) { From dc0b30bba144e56eceb60b4615466a254f587fd3 Mon Sep 17 00:00:00 2001 From: codestation Date: Sat, 19 Apr 2014 23:41:51 -0430 Subject: [PATCH 13/22] Enable systray by default. --- src/gui/main.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gui/main.cpp b/src/gui/main.cpp index ac77830..568512f 100644 --- a/src/gui/main.cpp +++ b/src/gui/main.cpp @@ -110,7 +110,7 @@ int main(int argc, char *argv[]) //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"); + bool showSystray = !app.arguments().contains("--no-systray"); MainWidget widget; widget.prepareApplication(showSystray); From 0b031f28a8d632f5b363b33551b13bc921d3fbc7 Mon Sep 17 00:00:00 2001 From: codestation Date: Wed, 23 Apr 2014 19:48:14 -0430 Subject: [PATCH 14/22] Drop qt4 from debian/rules. Update copyright. --- debian/rules | 2 +- src/gui/mainwidget.cpp | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/debian/rules b/debian/rules index 2fd44ff..201ca8f 100755 --- a/debian/rules +++ b/debian/rules @@ -6,4 +6,4 @@ include /usr/share/cdbs/1/class/qmake.mk DEB_QMAKE_ARGS += PREFIX=/usr pre-build:: - lrelease-qt4 resources/translations/*.ts + lrelease resources/translations/*.ts diff --git a/src/gui/mainwidget.cpp b/src/gui/mainwidget.cpp index 55e19f6..88ff23f 100644 --- a/src/gui/mainwidget.cpp +++ b/src/gui/mainwidget.cpp @@ -200,9 +200,9 @@ void MainWidget::showAboutDialog() about.setText(QString("QCMA ") + QCMA_VER); about.setWindowTitle(tr("About QCMA")); #ifndef QCMA_BUILD_HASH - about.setInformativeText(tr("Copyright (C) 2013 Codestation") + "\n"); + about.setInformativeText(tr("Copyright (C) 2014 Codestation") + "\n"); #else - about.setInformativeText(tr("Copyright (C) 2013 Codestation\n\nbuild hash: %1\nbuild branch: %2").arg(QCMA_BUILD_HASH).arg(QCMA_BUILD_BRANCH)); + about.setInformativeText(tr("Copyright (C) 2014 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")); From 26f6c78cf764c04b87083f72b20c6734b28f0e46 Mon Sep 17 00:00:00 2001 From: codestation Date: Thu, 24 Apr 2014 10:34:37 -0430 Subject: [PATCH 15/22] Bump specfiles version. --- rpmbuild/qcma-fedora.spec | 2 +- rpmbuild/qcma-openSUSE.spec | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/rpmbuild/qcma-fedora.spec b/rpmbuild/qcma-fedora.spec index b5d658d..5aeb14d 100644 --- a/rpmbuild/qcma-fedora.spec +++ b/rpmbuild/qcma-fedora.spec @@ -6,7 +6,7 @@ Name: qcma Summary: PSVita Content Manager Assistant License: GPL-3.0 Release: 1 -Version: 0.2.9 +Version: 0.3.0 URL: https://github.com/codestation/qcma Source: https://github.com/codestation/qcma.git Group: Productivity/File utilities diff --git a/rpmbuild/qcma-openSUSE.spec b/rpmbuild/qcma-openSUSE.spec index a79e0b6..e710300 100644 --- a/rpmbuild/qcma-openSUSE.spec +++ b/rpmbuild/qcma-openSUSE.spec @@ -6,7 +6,7 @@ Name: qcma Summary: PSVita Content Manager Assistant License: GPL-3.0 Release: 1 -Version: 0.2.9 +Version: 0.3.0 URL: https://github.com/codestation/qcma Source: https://github.com/codestation/qcma.git Group: Productivity/File utilities From 61720a910af28f79d568af175c6ce73d5bf993e1 Mon Sep 17 00:00:00 2001 From: codestation Date: Thu, 24 Apr 2014 11:35:07 -0430 Subject: [PATCH 16/22] Allow to use an external git repo in specfiles. --- rpmbuild/VitaMTP-fedora.spec | 2 +- rpmbuild/VitaMTP-openSUSE.spec | 2 +- rpmbuild/qcma-fedora.spec | 2 +- rpmbuild/qcma-openSUSE.spec | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/rpmbuild/VitaMTP-fedora.spec b/rpmbuild/VitaMTP-fedora.spec index 4473983..3156249 100644 --- a/rpmbuild/VitaMTP-fedora.spec +++ b/rpmbuild/VitaMTP-fedora.spec @@ -47,7 +47,7 @@ This package contains only the files necessary for development. %prep rm -rf $RPM_SOURCE_DIR/%{name}%{sonum} -git clone https://github.com/codestation/VitaMTP.git $RPM_SOURCE_DIR/%{name}%{sonum} +git clone "${VITAMTP_REPO:=https://github.com/codestation/VitaMTP.git}" $RPM_SOURCE_DIR/%{name}%{sonum} cp -r $RPM_SOURCE_DIR/%{name}%{sonum} $RPM_BUILD_DIR/%{name}%{sonum} %setup -n %{name}%{sonum} -DT diff --git a/rpmbuild/VitaMTP-openSUSE.spec b/rpmbuild/VitaMTP-openSUSE.spec index cc969ec..2fed7eb 100644 --- a/rpmbuild/VitaMTP-openSUSE.spec +++ b/rpmbuild/VitaMTP-openSUSE.spec @@ -47,7 +47,7 @@ This package contains only the files necessary for development. %prep rm -rf $RPM_SOURCE_DIR/%{name}%{sonum} -git clone https://github.com/codestation/VitaMTP.git $RPM_SOURCE_DIR/%{name}%{sonum} +git clone "${VITAMTP_REPO:=https://github.com/codestation/VitaMTP.git}" $RPM_SOURCE_DIR/%{name}%{sonum} cp -r $RPM_SOURCE_DIR/%{name}%{sonum} $RPM_BUILD_DIR/%{name}%{sonum} %setup -n %{name}%{sonum} -DT diff --git a/rpmbuild/qcma-fedora.spec b/rpmbuild/qcma-fedora.spec index 5aeb14d..e4b677d 100644 --- a/rpmbuild/qcma-fedora.spec +++ b/rpmbuild/qcma-fedora.spec @@ -26,7 +26,7 @@ is meant to be compatible with Linux, Windows and MAC OS X. %prep rm -rf $RPM_SOURCE_DIR/%{name}-%{version} -git clone https://github.com/codestation/qcma.git $RPM_SOURCE_DIR/%{name}-%{version} +git clone "${QCMA_REPO:=https://github.com/codestation/qcma.git}" $RPM_SOURCE_DIR/%{name}-%{version} cp -r $RPM_SOURCE_DIR/%{name}-%{version} $RPM_BUILD_DIR/%{name}-%{version} %setup -n %{name}-%{version} -DT diff --git a/rpmbuild/qcma-openSUSE.spec b/rpmbuild/qcma-openSUSE.spec index e710300..2590688 100644 --- a/rpmbuild/qcma-openSUSE.spec +++ b/rpmbuild/qcma-openSUSE.spec @@ -26,7 +26,7 @@ is meant to be compatible with Linux, Windows and MAC OS X. %prep rm -rf $RPM_SOURCE_DIR/%{name}-%{version} -git clone https://github.com/codestation/qcma.git $RPM_SOURCE_DIR/%{name}-%{version} +git clone "${QCMA_REPO:=https://github.com/codestation/qcma.git}" $RPM_SOURCE_DIR/%{name}-%{version} cp -r $RPM_SOURCE_DIR/%{name}-%{version} $RPM_BUILD_DIR/%{name}-%{version} %setup -n %{name}-%{version} -DT From 89a8e3bb36b1c32874a047526e3b929f34515be9 Mon Sep 17 00:00:00 2001 From: codestation Date: Thu, 24 Apr 2014 11:55:55 -0430 Subject: [PATCH 17/22] Fix variable expansion in specfiles. --- rpmbuild/VitaMTP-fedora.spec | 3 ++- rpmbuild/VitaMTP-openSUSE.spec | 3 ++- rpmbuild/qcma-fedora.spec | 3 ++- rpmbuild/qcma-openSUSE.spec | 3 ++- 4 files changed, 8 insertions(+), 4 deletions(-) diff --git a/rpmbuild/VitaMTP-fedora.spec b/rpmbuild/VitaMTP-fedora.spec index 3156249..f7c5473 100644 --- a/rpmbuild/VitaMTP-fedora.spec +++ b/rpmbuild/VitaMTP-fedora.spec @@ -47,7 +47,8 @@ This package contains only the files necessary for development. %prep rm -rf $RPM_SOURCE_DIR/%{name}%{sonum} -git clone "${VITAMTP_REPO:=https://github.com/codestation/VitaMTP.git}" $RPM_SOURCE_DIR/%{name}%{sonum} +%{!?_vitamtp_repo:%define _vitamtp_repo https://github.com/codestation/VitaMTP.git} +git clone "%{_vitamtp_repo}" $RPM_SOURCE_DIR/%{name}%{sonum} cp -r $RPM_SOURCE_DIR/%{name}%{sonum} $RPM_BUILD_DIR/%{name}%{sonum} %setup -n %{name}%{sonum} -DT diff --git a/rpmbuild/VitaMTP-openSUSE.spec b/rpmbuild/VitaMTP-openSUSE.spec index 2fed7eb..7a0bdb8 100644 --- a/rpmbuild/VitaMTP-openSUSE.spec +++ b/rpmbuild/VitaMTP-openSUSE.spec @@ -47,7 +47,8 @@ This package contains only the files necessary for development. %prep rm -rf $RPM_SOURCE_DIR/%{name}%{sonum} -git clone "${VITAMTP_REPO:=https://github.com/codestation/VitaMTP.git}" $RPM_SOURCE_DIR/%{name}%{sonum} +%{!?_vitamtp_repo:%define _vitamtp_repo https://github.com/codestation/VitaMTP.git} +git clone "${_vitamtp_repo}" $RPM_SOURCE_DIR/%{name}%{sonum} cp -r $RPM_SOURCE_DIR/%{name}%{sonum} $RPM_BUILD_DIR/%{name}%{sonum} %setup -n %{name}%{sonum} -DT diff --git a/rpmbuild/qcma-fedora.spec b/rpmbuild/qcma-fedora.spec index e4b677d..25af46f 100644 --- a/rpmbuild/qcma-fedora.spec +++ b/rpmbuild/qcma-fedora.spec @@ -26,7 +26,8 @@ is meant to be compatible with Linux, Windows and MAC OS X. %prep rm -rf $RPM_SOURCE_DIR/%{name}-%{version} -git clone "${QCMA_REPO:=https://github.com/codestation/qcma.git}" $RPM_SOURCE_DIR/%{name}-%{version} +%{!?_qcma_repo:%define _qcma_repo https://github.com/codestation/qcma.git} +git clone "%{_qcma_repo}" $RPM_SOURCE_DIR/%{name}-%{version} cp -r $RPM_SOURCE_DIR/%{name}-%{version} $RPM_BUILD_DIR/%{name}-%{version} %setup -n %{name}-%{version} -DT diff --git a/rpmbuild/qcma-openSUSE.spec b/rpmbuild/qcma-openSUSE.spec index 2590688..b38a0ad 100644 --- a/rpmbuild/qcma-openSUSE.spec +++ b/rpmbuild/qcma-openSUSE.spec @@ -26,7 +26,8 @@ is meant to be compatible with Linux, Windows and MAC OS X. %prep rm -rf $RPM_SOURCE_DIR/%{name}-%{version} -git clone "${QCMA_REPO:=https://github.com/codestation/qcma.git}" $RPM_SOURCE_DIR/%{name}-%{version} +%{!?_qcma_repo:%define _qcma_repo https://github.com/codestation/qcma.git} +git clone "%{_qcma_repo}" $RPM_SOURCE_DIR/%{name}-%{version} cp -r $RPM_SOURCE_DIR/%{name}-%{version} $RPM_BUILD_DIR/%{name}-%{version} %setup -n %{name}-%{version} -DT From 5c6286747cd2664ed6344cc4080840aa2bdc4bf6 Mon Sep 17 00:00:00 2001 From: codestation Date: Thu, 24 Apr 2014 12:21:58 -0430 Subject: [PATCH 18/22] Fixed typo in specfile. --- rpmbuild/VitaMTP-openSUSE.spec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rpmbuild/VitaMTP-openSUSE.spec b/rpmbuild/VitaMTP-openSUSE.spec index 7a0bdb8..fd401be 100644 --- a/rpmbuild/VitaMTP-openSUSE.spec +++ b/rpmbuild/VitaMTP-openSUSE.spec @@ -48,7 +48,7 @@ This package contains only the files necessary for development. %prep rm -rf $RPM_SOURCE_DIR/%{name}%{sonum} %{!?_vitamtp_repo:%define _vitamtp_repo https://github.com/codestation/VitaMTP.git} -git clone "${_vitamtp_repo}" $RPM_SOURCE_DIR/%{name}%{sonum} +git clone "%{_vitamtp_repo}" $RPM_SOURCE_DIR/%{name}%{sonum} cp -r $RPM_SOURCE_DIR/%{name}%{sonum} $RPM_BUILD_DIR/%{name}%{sonum} %setup -n %{name}%{sonum} -DT From ffbad2ad191b9a87fba01a4343c1e4c5f08ff013 Mon Sep 17 00:00:00 2001 From: codestation Date: Thu, 24 Apr 2014 13:12:43 -0430 Subject: [PATCH 19/22] Pick sonum from spec file. --- rpmbuild/VitaMTP-fedora.spec | 2 +- rpmbuild/VitaMTP-openSUSE.spec | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/rpmbuild/VitaMTP-fedora.spec b/rpmbuild/VitaMTP-fedora.spec index f7c5473..a4224df 100644 --- a/rpmbuild/VitaMTP-fedora.spec +++ b/rpmbuild/VitaMTP-fedora.spec @@ -62,7 +62,7 @@ make %{?_smp_mflags} %makeinstall rm -rf %{buildroot}/%{_libdir}/*.la mkdir -p %{buildroot}/usr/lib/udev/rules.d -cp debian/vitamtp1.udev %{buildroot}/usr/lib/udev/rules.d/80-psvita.rules +cp debian/vitamtp%{sonum}.udev %{buildroot}/usr/lib/udev/rules.d/80-psvita.rules %post -n %{name}%{sonum} -p /sbin/ldconfig %postun -n %{name}%{sonum} -p /sbin/ldconfig diff --git a/rpmbuild/VitaMTP-openSUSE.spec b/rpmbuild/VitaMTP-openSUSE.spec index fd401be..5a37f9c 100644 --- a/rpmbuild/VitaMTP-openSUSE.spec +++ b/rpmbuild/VitaMTP-openSUSE.spec @@ -62,7 +62,7 @@ make %{?_smp_mflags} %makeinstall rm -rf %{buildroot}/%{_libdir}/*.la mkdir -p %{buildroot}/usr/lib/udev/rules.d -cp debian/vitamtp1.udev %{buildroot}/usr/lib/udev/rules.d/80-psvita.rules +cp debian/vitamtp%{sonum}.udev %{buildroot}/usr/lib/udev/rules.d/80-psvita.rules %post -n %{name}%{sonum} -p /sbin/ldconfig %postun -n %{name}%{sonum} -p /sbin/ldconfig From a42ce8e719c0d89d18e59191cd94e10c5da09197 Mon Sep 17 00:00:00 2001 From: codestation Date: Thu, 24 Apr 2014 13:30:03 -0430 Subject: [PATCH 20/22] Specify qmake target file --- rpmbuild/qcma-fedora.spec | 2 +- rpmbuild/qcma-openSUSE.spec | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/rpmbuild/qcma-fedora.spec b/rpmbuild/qcma-fedora.spec index 25af46f..4516593 100644 --- a/rpmbuild/qcma-fedora.spec +++ b/rpmbuild/qcma-fedora.spec @@ -34,7 +34,7 @@ cp -r $RPM_SOURCE_DIR/%{name}-%{version} $RPM_BUILD_DIR/%{name}-%{version} %build lrelease-qt5 resources/translations/*.ts -qmake-qt5 PREFIX=/usr +qmake-qt5 PREFIX=/usr qcma.pro make %{?_smp_mflags} %install diff --git a/rpmbuild/qcma-openSUSE.spec b/rpmbuild/qcma-openSUSE.spec index b38a0ad..ea9ab5f 100644 --- a/rpmbuild/qcma-openSUSE.spec +++ b/rpmbuild/qcma-openSUSE.spec @@ -34,7 +34,7 @@ cp -r $RPM_SOURCE_DIR/%{name}-%{version} $RPM_BUILD_DIR/%{name}-%{version} %build lrelease-qt5 resources/translations/*.ts -qmake-qt5 PREFIX=/usr +qmake-qt5 PREFIX=/usr qcma.pro make %{?_smp_mflags} %install From 8de29eb70323a46552769660b8bce035b3e8a933 Mon Sep 17 00:00:00 2001 From: codestation Date: Thu, 24 Apr 2014 14:43:35 -0430 Subject: [PATCH 21/22] Add qt5 suffix for distros that doesn't symlink tools to non-qt5 names --- qcma_cli.pro | 6 +++++- qcma_gui.pro | 6 +++++- rpmbuild/qcma-fedora.spec | 2 +- rpmbuild/qcma-openSUSE.spec | 2 +- 4 files changed, 12 insertions(+), 4 deletions(-) diff --git a/qcma_cli.pro b/qcma_cli.pro index 3d35592..fae77d5 100644 --- a/qcma_cli.pro +++ b/qcma_cli.pro @@ -21,7 +21,11 @@ unix:!macx { } # Create the introspection XML -system(qdbuscpp2xml -M -s src/cli/headlessmanager.h -o org.qcma.HeadlessManager.xml) +QT5_SUFFIX { + system(qdbuscpp2xml-qt5 -M -s src/cli/headlessmanager.h -o org.qcma.HeadlessManager.xml) +} else { + system(qdbuscpp2xml -M -s src/cli/headlessmanager.h -o org.qcma.HeadlessManager.xml) +} # Create the helper class DBUS_ADAPTORS = org.qcma.HeadlessManager.xml diff --git a/qcma_gui.pro b/qcma_gui.pro index a7bb793..222364f 100644 --- a/qcma_gui.pro +++ b/qcma_gui.pro @@ -71,7 +71,11 @@ unix:!macx { QT += dbus # Create the introspection XML -system(qdbuscpp2xml -M -s src/gui/mainwidget.h -o org.qcma.ClientManager.xml) +QT5_SUFFIX { + system(qdbuscpp2xml-qt5 -M -s src/gui/mainwidget.h -o org.qcma.ClientManager.xml) +} else { + system(qdbuscpp2xml -M -s src/gui/mainwidget.h -o org.qcma.ClientManager.xml) +} # Create the helper class DBUS_ADAPTORS = org.qcma.ClientManager.xml diff --git a/rpmbuild/qcma-fedora.spec b/rpmbuild/qcma-fedora.spec index 4516593..c1a0aba 100644 --- a/rpmbuild/qcma-fedora.spec +++ b/rpmbuild/qcma-fedora.spec @@ -34,7 +34,7 @@ cp -r $RPM_SOURCE_DIR/%{name}-%{version} $RPM_BUILD_DIR/%{name}-%{version} %build lrelease-qt5 resources/translations/*.ts -qmake-qt5 PREFIX=/usr qcma.pro +qmake-qt5 PREFIX=/usr qcma.pro CONFIG+=QT5_SUFFIX make %{?_smp_mflags} %install diff --git a/rpmbuild/qcma-openSUSE.spec b/rpmbuild/qcma-openSUSE.spec index ea9ab5f..0a154ca 100644 --- a/rpmbuild/qcma-openSUSE.spec +++ b/rpmbuild/qcma-openSUSE.spec @@ -34,7 +34,7 @@ cp -r $RPM_SOURCE_DIR/%{name}-%{version} $RPM_BUILD_DIR/%{name}-%{version} %build lrelease-qt5 resources/translations/*.ts -qmake-qt5 PREFIX=/usr qcma.pro +qmake-qt5 PREFIX=/usr qcma.pro CONFIG+=QT5_SUFFIX make %{?_smp_mflags} %install From adf065c51ad887685c4413b877fbc50bbe08af95 Mon Sep 17 00:00:00 2001 From: codestation Date: Thu, 24 Apr 2014 14:48:58 -0430 Subject: [PATCH 22/22] Add qcma_cli to rpm package --- rpmbuild/qcma-fedora.spec | 1 + rpmbuild/qcma-openSUSE.spec | 1 + 2 files changed, 2 insertions(+) diff --git a/rpmbuild/qcma-fedora.spec b/rpmbuild/qcma-fedora.spec index c1a0aba..c05719c 100644 --- a/rpmbuild/qcma-fedora.spec +++ b/rpmbuild/qcma-fedora.spec @@ -43,6 +43,7 @@ make install INSTALL_ROOT=%{buildroot} %files %defattr(-,root,root) %{_bindir}/qcma +%{_bindir}/qcma_cli %{_prefix}/share/applications/qcma/qcma.desktop %{_prefix}/share/icons/hicolor/64x64/apps/qcma.png diff --git a/rpmbuild/qcma-openSUSE.spec b/rpmbuild/qcma-openSUSE.spec index 0a154ca..b9d4dae 100644 --- a/rpmbuild/qcma-openSUSE.spec +++ b/rpmbuild/qcma-openSUSE.spec @@ -43,6 +43,7 @@ make install INSTALL_ROOT=%{buildroot} %files %defattr(-,root,root) %{_bindir}/qcma +%{_bindir}/qcma_cli %{_prefix}/share/applications/qcma/qcma.desktop %{_prefix}/share/icons/hicolor/64x64/apps/qcma.png