summaryrefslogtreecommitdiff
path: root/plugins-alternative/Listener/dbus
diff options
context:
space:
mode:
authorThomas Preud'homme <robotux@celest.fr>2018-02-23 23:49:48 +0000
committerThomas Preud'homme <robotux@celest.fr>2018-02-23 23:49:48 +0000
commitbd56579c7d9de94c17287adefa118290e6b7ba33 (patch)
tree666d7d0b6945b442573b7a3145969f66a53aa460 /plugins-alternative/Listener/dbus
parentb3c8bdcc0d1e4b2ab298847a7902b6d60410a5bc (diff)
New upstream version 1.4.0.3
Diffstat (limited to 'plugins-alternative/Listener/dbus')
-rw-r--r--plugins-alternative/Listener/dbus/Catchcopy.cpp17
-rw-r--r--plugins-alternative/Listener/dbus/Catchcopy.h20
-rw-r--r--plugins-alternative/Listener/dbus/DebugEngineMacro.h28
-rw-r--r--plugins-alternative/Listener/dbus/Environment.h10
-rw-r--r--plugins-alternative/Listener/dbus/StructEnumDefinition.h1
-rw-r--r--plugins-alternative/Listener/dbus/Variable.h15
-rw-r--r--plugins-alternative/Listener/dbus/documentation.dox36
-rw-r--r--plugins-alternative/Listener/dbus/informations.xml26
-rw-r--r--plugins-alternative/Listener/dbus/listener.cpp85
-rw-r--r--plugins-alternative/Listener/dbus/listener.h49
-rw-r--r--plugins-alternative/Listener/dbus/listener.pro19
-rw-r--r--plugins-alternative/Listener/dbus/plugin.json1
12 files changed, 307 insertions, 0 deletions
diff --git a/plugins-alternative/Listener/dbus/Catchcopy.cpp b/plugins-alternative/Listener/dbus/Catchcopy.cpp
new file mode 100644
index 0000000..6c46af2
--- /dev/null
+++ b/plugins-alternative/Listener/dbus/Catchcopy.cpp
@@ -0,0 +1,17 @@
+#include "Catchcopy.h"
+
+#include <QCoreApplication>
+
+Catchcopy::Catchcopy()
+{
+}
+
+void Catchcopy::copy(const QStringList &sources,const QString &destination)
+{
+ emit newCopy(0,sources,destination);
+}
+
+void Catchcopy::move(const QStringList &sources,const QString &destination)
+{
+ emit newMove(0,sources,destination);
+}
diff --git a/plugins-alternative/Listener/dbus/Catchcopy.h b/plugins-alternative/Listener/dbus/Catchcopy.h
new file mode 100644
index 0000000..d28a253
--- /dev/null
+++ b/plugins-alternative/Listener/dbus/Catchcopy.h
@@ -0,0 +1,20 @@
+#ifndef CATCHCOPY_H
+#define CATCHCOPY_H
+
+#include <QObject>
+#include <QStringList>
+
+class Catchcopy : public QObject
+{
+ Q_OBJECT
+public:
+ explicit Catchcopy();
+signals:
+ void newCopy(const quint32 &id,const QStringList &sources,const QString &destination);
+ void newMove(const quint32 &id,const QStringList &sources,const QString &destination);
+public slots:
+ Q_SCRIPTABLE void copy(const QStringList &sources,const QString &destination);
+ Q_SCRIPTABLE void move(const QStringList &sources,const QString &destination);
+};
+
+#endif // CATCHCOPY_H
diff --git a/plugins-alternative/Listener/dbus/DebugEngineMacro.h b/plugins-alternative/Listener/dbus/DebugEngineMacro.h
new file mode 100644
index 0000000..4582010
--- /dev/null
+++ b/plugins-alternative/Listener/dbus/DebugEngineMacro.h
@@ -0,0 +1,28 @@
+/** \file DebugEngineMacro.h
+\brief Define the macro for the debug
+\author alpha_one_x86
+\licence GPL3, see the file COPYING */
+
+#ifndef DEBUGENGINEMACRO_H
+#define DEBUGENGINEMACRO_H
+
+#ifdef WIN32
+# define __func__ __FUNCTION__
+#endif
+
+/// \brief Macro for the debug log
+#ifdef ULTRACOPIER_PLUGIN_DEBUG
+ #if defined (__FILE__) && defined (__LINE__)
+ #define ULTRACOPIER_DEBUGCONSOLE(a,b) emit debugInformation(a,__func__,b,__FILE__,__LINE__)
+ #else
+ #define ULTRACOPIER_DEBUGCONSOLE(a,b) emit debugInformation(a,__func__,b)
+ #endif
+#else // ULTRACOPIER_DEBUG
+ #define ULTRACOPIER_DEBUGCONSOLE(a,b) void()
+#endif // ULTRACOPIER_DEBUG
+
+#endif // DEBUGENGINEMACRO_H
+
+
+
+
diff --git a/plugins-alternative/Listener/dbus/Environment.h b/plugins-alternative/Listener/dbus/Environment.h
new file mode 100644
index 0000000..265a5a6
--- /dev/null
+++ b/plugins-alternative/Listener/dbus/Environment.h
@@ -0,0 +1,10 @@
+/** \file Environment.h
+\brief Define the environment variable and global function
+\author alpha_one_x86
+\licence GPL3, see the file COPYING */
+
+#include "Variable.h"
+/// \brief The global include
+#include "StructEnumDefinition.h"
+#include "DebugEngineMacro.h"
+
diff --git a/plugins-alternative/Listener/dbus/StructEnumDefinition.h b/plugins-alternative/Listener/dbus/StructEnumDefinition.h
new file mode 100644
index 0000000..c1758f4
--- /dev/null
+++ b/plugins-alternative/Listener/dbus/StructEnumDefinition.h
@@ -0,0 +1 @@
+#include "../../../StructEnumDefinition.h"
diff --git a/plugins-alternative/Listener/dbus/Variable.h b/plugins-alternative/Listener/dbus/Variable.h
new file mode 100644
index 0000000..963d0c8
--- /dev/null
+++ b/plugins-alternative/Listener/dbus/Variable.h
@@ -0,0 +1,15 @@
+/** \file Variable.h
+\brief Define the environment variable
+\author alpha_one_x86
+\licence GPL3, see the file COPYING */
+
+#ifndef VARIABLE_H
+#define VARIABLE_H
+
+//Un-comment this next line to put ultracopier plugin in debug mode
+#define ULTRACOPIER_PLUGIN_DEBUG
+
+#endif // VARIABLE_H
+
+
+
diff --git a/plugins-alternative/Listener/dbus/documentation.dox b/plugins-alternative/Listener/dbus/documentation.dox
new file mode 100644
index 0000000..2eb3c87
--- /dev/null
+++ b/plugins-alternative/Listener/dbus/documentation.dox
@@ -0,0 +1,36 @@
+/* -*- mode: C++ ; c-file-style: "stroustrup" -*- **/
+
+/*
+ This file contains NO source code, just some documentation for doxygen to
+ parse.
+*/
+
+/*!
+ \mainpage dbus
+
+ \section mainpage_overview Overview
+
+ It's alternative listener for linux, it's very more simpler. You send just your copy/move, no more. No return.\n
+ More informations on <a href="http://ultracopier-wiki.first-world.info/">the wiki of ultracopier</a>.
+
+ \section mainpage_platforms Platforms
+
+ Ultracopier might be usable in all environments where you find Qt 5.\n
+ Ultracopier requires Qt 5.0 or newer. Tested on Qt 5.0.
+
+ \section mainpage_downloads Downloads
+
+ You can find the link on <a href="http://ultracopier.first-world.info/">Ultracopier</a> project page, via git, snapshot sources, ...
+
+ \section mainpage_algorithm Dbus method
+
+ you have this method exported to dbus:
+ <ul>
+ <li>void copy(const QStringList &sources,const QString &destination)</li>
+ <li>void move(const QStringList &sources,const QString &destination)</li>
+ </ul>
+
+ \section license GPL Version 3
+ The code source is under GPL3. The image is extacted from Oxygen icon pack of KDE4.
+
+*/
diff --git a/plugins-alternative/Listener/dbus/informations.xml b/plugins-alternative/Listener/dbus/informations.xml
new file mode 100644
index 0000000..77cba57
--- /dev/null
+++ b/plugins-alternative/Listener/dbus/informations.xml
@@ -0,0 +1,26 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<package>
+ <title xml:lang="en"><![CDATA[Listener for catchcopy in dbus]]></title><!-- english is required -->
+ <title xml:lang="fr"><![CDATA[Écouteur pour catchcopy en dbus]]></title>
+ <!-- What kind of plugin this is -->
+ <category>Listener</category>
+ <!-- Who wrote this plugin -->
+ <author><![CDATA[BRULE Herman, alpha_one_x86 (alpha_one_x86@first-world.info)]]></author>
+ <!-- URL of page or site for this plugin (may provide additional information, bug reports, feature requests). -->
+ <website xml:lang="en"><![CDATA[http://ultracopier.first-world.info/]]></website><!-- not required -->
+ <website xml:lang="fr"><![CDATA[http://ultracopier-fr.first-world.info/]]></website><!-- not required -->
+ <!-- the date-time format should be in timestamps format -->
+ <pubDate>1287496800</pubDate>
+ <!-- the architecture code of this plugin, found PlatformMacro.h into ultracopier source -->
+ <architecture>windows-x86</architecture>
+ <!-- Detailed description -->
+ <description xml:lang="en"><![CDATA[Listener for catchcopy in dbus. Allow to receive copy list from plugin/explorer compatible with catchcopy.]]></description>
+ <description xml:lang="fr"><![CDATA[Écouteur pour catchcopy en dbus. Permet de recevoir un liste de copie venant d'un plugin/explorateur avec catchcopy.]]></description>
+ <!-- Version of this release of this plugin, need be like that's: A.B.C.D, where A, B, C and D is number -->
+ <version>1.4.0.3</version>
+ <!-- This internal name should never change, because it is used to detect when a particular plugin is updated. It must comprise only lower case ASCII characters (a-z), numerical digits (0-9), "-", "." or "_", and it must be be unique within the category. And have size lower than 64 char. -->
+ <name>dbus</name>
+ <!-- Dependency checking. This is used to check when a plugin may not be compatible with an updated version of either Ultracopier or another plugin. This example only checks Ultracopier. -->
+ <dependencies><![CDATA[
+ ]]></dependencies>
+</package> \ No newline at end of file
diff --git a/plugins-alternative/Listener/dbus/listener.cpp b/plugins-alternative/Listener/dbus/listener.cpp
new file mode 100644
index 0000000..50ed196
--- /dev/null
+++ b/plugins-alternative/Listener/dbus/listener.cpp
@@ -0,0 +1,85 @@
+#include "listener.h"
+
+Listener::Listener()
+{
+ connect(&catchcopy,&Catchcopy::newCopy, this,&Listener::newCopy);
+ connect(&catchcopy,&Catchcopy::newMove, this,&Listener::newMove);
+}
+
+void Listener::listen()
+{
+ ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Notice,"start");
+ if (!QDBusConnection::sessionBus().isConnected())
+ {
+ ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Notice,"start");
+ emit newState(Ultracopier::NotListening);
+ return;
+ }
+ if (!QDBusConnection::sessionBus().registerService("info.first-world.catchcopy"))
+ {
+ ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Notice,QDBusConnection::sessionBus().lastError().message());
+ emit newState(Ultracopier::NotListening);
+ return;
+ }
+ if(!QDBusConnection::sessionBus().registerObject("/", &catchcopy, QDBusConnection::ExportAllSlots))
+ {
+ ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Notice,QDBusConnection::sessionBus().lastError().message());
+ emit newState(Ultracopier::NotListening);
+ return;
+ }
+ emit newState(Ultracopier::FullListening);
+}
+
+void Listener::close()
+{
+ ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Notice,"start");
+ QDBusConnection::sessionBus().unregisterObject("/");
+ QDBusConnection::sessionBus().unregisterService("info.first-world.catchcopy");
+ emit newState(Ultracopier::NotListening);
+}
+
+const QString Listener::errorString() const
+{
+ return "Unknow error";
+}
+
+void Listener::setResources(OptionInterface * options,const QString &writePath,const QString &pluginPath,const bool &portableVersion)
+{
+ Q_UNUSED(options);
+ Q_UNUSED(writePath);
+ Q_UNUSED(pluginPath);
+ Q_UNUSED(portableVersion);
+}
+
+/// \brief to get the options widget, NULL if not have
+QWidget * Listener::options()
+{
+ return NULL;
+}
+
+void Listener::transferFinished(const quint32 &orderId,const bool &withError)
+{
+ ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Notice,"start, orderId: "+QString::number(orderId)+", withError: "+QString::number(withError));
+}
+
+void Listener::transferCanceled(const quint32 &orderId)
+{
+ ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Notice,"start, orderId: "+QString::number(orderId));
+}
+
+/// \brief to reload the translation, because the new language have been loaded
+void Listener::newLanguageLoaded()
+{
+}
+
+void Listener::error(QString error)
+{
+ Q_UNUSED(error);
+}
+
+void Listener::clientName(quint32 client,QString name)
+{
+ Q_UNUSED(client);
+ Q_UNUSED(name);
+ ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Information,QStringLiteral("clientName: %1, for the id: %2").arg(name).arg(client));
+}
diff --git a/plugins-alternative/Listener/dbus/listener.h b/plugins-alternative/Listener/dbus/listener.h
new file mode 100644
index 0000000..fcb95cd
--- /dev/null
+++ b/plugins-alternative/Listener/dbus/listener.h
@@ -0,0 +1,49 @@
+/** \file listener.h
+\brief Define the server compatible with Ultracopier interface
+\author alpha_one_x86
+\licence GPL3, see the file COPYING */
+
+#ifndef SERVER_H
+#define SERVER_H
+
+#include <QObject>
+#include <QtDBus/QtDBus>
+#include <QtDBus/QDBusConnection>
+
+#include "Catchcopy.h"
+#include "Environment.h"
+#include "../../../interface/PluginInterface_Listener.h"
+
+/// \brief Define the server compatible with Ultracopier interface
+class Listener : public PluginInterface_Listener
+{
+ Q_OBJECT
+ Q_PLUGIN_METADATA(IID "first-world.info.ultracopier.PluginInterface.Listener/1.0.0.0" FILE "plugin.json")
+ Q_INTERFACES(PluginInterface_Listener)
+public:
+ Listener();
+ /// \brief try listen the copy/move
+ void listen();
+ /// \brief stop listen to copy/move
+ void close();
+ /// \brief return the error strong
+ const QString errorString() const;
+ /// \brief set resources for this plugins
+ void setResources(OptionInterface * options,const QString &writePath,const QString &pluginPath,const bool &portableVersion);
+ /// \brief to get the options widget, NULL if not have
+ QWidget * options();
+public slots:
+ /// \brief say to the client that's the copy/move is finished
+ void transferFinished(const quint32 &orderId,const bool &withError);
+ /// \brief say to the client that's the copy/move is finished
+ void transferCanceled(const quint32 &orderId);
+ /// \brief to reload the translation, because the new language have been loaded
+ void newLanguageLoaded();
+private:
+ Catchcopy catchcopy;
+private slots:
+ void error(QString error);
+ void clientName(quint32 client,QString name);
+};
+
+#endif // SERVER_H
diff --git a/plugins-alternative/Listener/dbus/listener.pro b/plugins-alternative/Listener/dbus/listener.pro
new file mode 100644
index 0000000..16cd3d3
--- /dev/null
+++ b/plugins-alternative/Listener/dbus/listener.pro
@@ -0,0 +1,19 @@
+CONFIG += c++11
+QMAKE_CXXFLAGS+="-std=c++0x -Wall -Wextra"
+mac:QMAKE_CXXFLAGS+="-stdlib=libc++"
+
+TEMPLATE = lib
+CONFIG += plugin
+QT += network dbus
+HEADERS = \
+ $$PWD/listener.h \
+ $$PWD/Environment.h \
+ $$PWD/Variable.h \
+ $$PWD/DebugEngineMacro.h \
+ $$PWD/StructEnumDefinition.h \
+ $$PWD/../../../interface/PluginInterface_Listener.h \
+ $$PWD/Catchcopy.h
+SOURCES = \
+ $$PWD/listener.cpp \
+ $$PWD/Catchcopy.cpp
+TARGET = $$qtLibraryTarget(listener)
diff --git a/plugins-alternative/Listener/dbus/plugin.json b/plugins-alternative/Listener/dbus/plugin.json
new file mode 100644
index 0000000..9e26dfe
--- /dev/null
+++ b/plugins-alternative/Listener/dbus/plugin.json
@@ -0,0 +1 @@
+{} \ No newline at end of file