diff --git a/app/CMakeLists.txt b/app/CMakeLists.txt index 3fab685..2ff5b94 100644 --- a/app/CMakeLists.txt +++ b/app/CMakeLists.txt @@ -16,7 +16,6 @@ set(plaYUver_App_SRCS GridManager.cpp Settings.cpp PlaYUVerAppAdaptor.cpp - RunningInstanceInfo.cpp # Dialogs AboutDialog.cpp ConfigureFormatDialog.cpp diff --git a/app/RunningInstanceInfo.cpp b/app/RunningInstanceInfo.cpp deleted file mode 100644 index c4c4098..0000000 --- a/app/RunningInstanceInfo.cpp +++ /dev/null @@ -1,83 +0,0 @@ -/* This file is a part of plaYUVer project - * Copyright (C) 2014 by Luis Lucas (luisfrlucas@gmail.com) - * Joao Carreira (jfmcarreira@gmail.com) - * - * 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 2 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, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -/** - * \file RunningInstanceInfo.cpp - * \brief Control running instances - */ - -#include "RunningInstanceInfo.h" -#include -#include -#include -#include -#include - -namespace plaYUVer -{ - -int RunningInstanceInfo::dummy_session = 0; - -bool fillinRunningAppInstances(RunningInstanceInfoMap *map) -{ - QDBusConnectionInterface *i = QDBusConnection::sessionBus().interface(); - - // look up all running kate instances and there sessions - QDBusReply servicesReply = i->registeredServiceNames(); - QStringList services; - if (servicesReply.isValid()) { - services = servicesReply.value(); - } - - QString serviceName; - - QString my_pid = QString::number(QCoreApplication::applicationPid()); - - foreach(const QString & s, services) { - if (s.startsWith(QStringLiteral("org.pixlra.PlaYUVer"))) { - if (s.contains(my_pid)) { - continue; - } - qDebug() << s ; - RunningInstanceInfo *rii = new RunningInstanceInfo(s); - if (rii->valid) { - if (map->contains(rii->sessionName)) { - return false; //ERROR no two instances may have the same session name - } - map->insert(rii->sessionName, rii); - //std::cerr<sessionName.toUtf8().data()<constBegin(); it != map->constEnd(); ++it) { - delete it.value(); - } - map->clear(); -} - -} // NAMESPACE - - diff --git a/app/RunningInstanceInfo.h b/app/RunningInstanceInfo.h deleted file mode 100644 index 26ae16d..0000000 --- a/app/RunningInstanceInfo.h +++ /dev/null @@ -1,100 +0,0 @@ -/* This file is a part of plaYUVer project - * Copyright (C) 2014 by Luis Lucas (luisfrlucas@gmail.com) - * Joao Carreira (jfmcarreira@gmail.com) - * - * 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 2 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, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -/** - * \file RunningInstanceInfo.h - * \brief Control running instances - */ - -#ifndef _PLAYUVER_RUNNING_INSTANCE_INFO_ -#define _PLAYUVER_RUNNING_INSTANCE_INFO_ - -#include -#include -#include -#include -#include -#include "lib/PlaYUVerDefs.h" -#include "PlaYUVerAppAdaptor.h" - -namespace plaYUVer -{ - -class RunningInstanceInfo: public QObject -{ -Q_OBJECT - -public: - RunningInstanceInfo( const QString &serviceName_ ) : - QObject(), - valid( false ), - serviceName( serviceName_ ), - dbus_if( new QDBusInterface( serviceName_, QStringLiteral( PLAYUVER_DBUS_PATH ), QString(), //I don't know why it does not work if I specify org.pixlra.PlaYUVer.application here - QDBusConnection::sessionBus(), this ) ) - { - if( !dbus_if->isValid() ) - { - std::cerr << qPrintable( QDBusConnection::sessionBus().lastError().message() ) - << std::endl; - } -// QVariant a_s = dbus_if->property( "activeSession" ); -// std::cerr< RunningInstanceInfoMap; - -Q_DECL_EXPORT bool fillinRunningAppInstances( RunningInstanceInfoMap *map ); -Q_DECL_EXPORT void cleanupRunningAppInstanceMap( RunningInstanceInfoMap *map ); - -} // NAMESPACE - -#endif // _PLAYUVER_RUNNING_INSTANCE_INFO_ - diff --git a/app/main.cpp b/app/main.cpp index 6f0d5df..ebe080b 100644 --- a/app/main.cpp +++ b/app/main.cpp @@ -30,7 +30,6 @@ #include #include #include "PlaYUVerAppAdaptor.h" -#include "RunningInstanceInfo.h" #include "plaYUVerApp.h" #include "SubWindowHandle.h" #ifdef USE_FERVOR @@ -61,42 +60,9 @@ int main( int argc, char *argv[] ) QDBusConnectionInterface * const sessionBusInterface = QDBusConnection::sessionBus().interface(); if( sessionBusInterface ) { - RunningInstanceInfoMap mapSessionRii; - if( !fillinRunningAppInstances( &mapSessionRii ) ) - { - return 1; - } - QStringList playuverServices; - for( RunningInstanceInfoMap::const_iterator it = mapSessionRii.constBegin(); it != mapSessionRii.constEnd(); ++it ) - { - playuverServices << ( *it )->serviceName; - } - QString serviceName; - //const QStringList urls = parser.positionalArguments(); Bool force_new = false; - - //cleanup map - cleanupRunningAppInstanceMap( &mapSessionRii ); - - //if no new instance is forced and no already opened session is requested, - //check if a pid is given, which should be reused. - // two possibilities: pid given or not... -// if( ( !force_new ) && serviceName.isEmpty() ) -// { -// if( /*( parser.isSet( usePidOption ) )*/|| ( !qgetenv( "PLAYUVER_PID" ).isEmpty() ) ) -// { -// QString usePid = ( parser.isSet( usePidOption ) ) ? parser.value( usePidOption ) : QString::fromLocal8Bit( qgetenv( "KATE_PID" ) ); -// -// serviceName = QStringLiteral("org.kde.kate-")+ usePid; -// if( !playuverServices.contains( serviceName ) ) -// { -// serviceName.clear(); -// } -// } -// } - QStringList filenameList; for( Int i = 1; i < argc; i++ ) { @@ -107,26 +73,18 @@ int main( int argc, char *argv[] ) force_new = true; } - if( ( !force_new ) && ( serviceName.isEmpty() ) ) - { - if( playuverServices.count() > 0 ) - { - serviceName = playuverServices[0]; - } - } - //check again if service is still running bool foundRunningService = false; - if( !serviceName.isEmpty() ) + if( !force_new ) { - QDBusReply there = sessionBusInterface->isServiceRegistered( serviceName ); + QDBusReply there = sessionBusInterface->isServiceRegistered( PLAYUVER_DBUS_SESSION_NAME ); foundRunningService = there.isValid() && there.value(); } if( foundRunningService ) { // open given session - QDBusMessage m = QDBusMessage::createMethodCall( serviceName, QStringLiteral( PLAYUVER_DBUS_PATH ), QStringLiteral( PLAYUVER_DBUS_SESSION_NAME ), + QDBusMessage m = QDBusMessage::createMethodCall( PLAYUVER_DBUS_SESSION_NAME, QStringLiteral( PLAYUVER_DBUS_PATH ), QStringLiteral( PLAYUVER_DBUS_SESSION_NAME ), QStringLiteral( "activate" ) ); QDBusConnection::sessionBus().call( m ); @@ -138,13 +96,11 @@ int main( int argc, char *argv[] ) // open given files... foreach(const QString & file, filenameList){ - QDBusMessage m = QDBusMessage::createMethodCall(serviceName, + QDBusMessage m = QDBusMessage::createMethodCall(PLAYUVER_DBUS_SESSION_NAME, QStringLiteral(PLAYUVER_DBUS_PATH), QStringLiteral(PLAYUVER_DBUS_SESSION_NAME), QStringLiteral("loadFile")); QList dbusargs; - dbusargs.append( file ); - m.setArguments(dbusargs); QDBusMessage res = QDBusConnection::sessionBus().call(m);