summaryrefslogtreecommitdiff
path: root/plugins/SessionLoader
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/SessionLoader')
-rw-r--r--plugins/SessionLoader/Windows/DebugEngineMacro.h28
-rw-r--r--plugins/SessionLoader/Windows/Environment.h10
-rw-r--r--plugins/SessionLoader/Windows/StructEnumDefinition.h1
-rw-r--r--plugins/SessionLoader/Windows/Variable.h15
-rw-r--r--plugins/SessionLoader/Windows/documentation.dox32
-rw-r--r--plugins/SessionLoader/Windows/informations.xml26
-rw-r--r--plugins/SessionLoader/Windows/plugin.json1
-rw-r--r--plugins/SessionLoader/Windows/sessionLoader.cpp80
-rw-r--r--plugins/SessionLoader/Windows/sessionLoader.h33
-rw-r--r--plugins/SessionLoader/Windows/sessionLoader.pro16
10 files changed, 242 insertions, 0 deletions
diff --git a/plugins/SessionLoader/Windows/DebugEngineMacro.h b/plugins/SessionLoader/Windows/DebugEngineMacro.h
new file mode 100644
index 0000000..4582010
--- /dev/null
+++ b/plugins/SessionLoader/Windows/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/SessionLoader/Windows/Environment.h b/plugins/SessionLoader/Windows/Environment.h
new file mode 100644
index 0000000..265a5a6
--- /dev/null
+++ b/plugins/SessionLoader/Windows/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/SessionLoader/Windows/StructEnumDefinition.h b/plugins/SessionLoader/Windows/StructEnumDefinition.h
new file mode 100644
index 0000000..c1758f4
--- /dev/null
+++ b/plugins/SessionLoader/Windows/StructEnumDefinition.h
@@ -0,0 +1 @@
+#include "../../../StructEnumDefinition.h"
diff --git a/plugins/SessionLoader/Windows/Variable.h b/plugins/SessionLoader/Windows/Variable.h
new file mode 100644
index 0000000..963d0c8
--- /dev/null
+++ b/plugins/SessionLoader/Windows/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/SessionLoader/Windows/documentation.dox b/plugins/SessionLoader/Windows/documentation.dox
new file mode 100644
index 0000000..bfe77f3
--- /dev/null
+++ b/plugins/SessionLoader/Windows/documentation.dox
@@ -0,0 +1,32 @@
+/* -*- mode: C++ ; c-file-style: "stroustrup" -*- **/
+
+/*
+ This file contains NO source code, just some documentation for doxygen to
+ parse.
+*/
+
+/*!
+ \mainpage Windows
+
+ \section mainpage_overview Overview
+
+ It control if it loaded with the session. Use HKEY_CURRENT_USER/Software/Microsoft/Windows/CurrentVersion/Run. \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 Method
+
+ It pass by the registry key to set/get it.
+
+ \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/SessionLoader/Windows/informations.xml b/plugins/SessionLoader/Windows/informations.xml
new file mode 100644
index 0000000..4bfbab1
--- /dev/null
+++ b/plugins/SessionLoader/Windows/informations.xml
@@ -0,0 +1,26 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<package>
+ <title xml:lang="en"><![CDATA[Session loader for windows]]></title><!-- english is required -->
+ <title xml:lang="fr"><![CDATA[Chargeur de session pour windows]]></title>
+ <!-- What kind of plugin this is -->
+ <category>SessionLoader</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[This plugin allow Ultracopier to be loaded at the session opening under windows]]></description>
+ <description xml:lang="fr"><![CDATA[Ce plugin permet de charger Ultracopier à l'ouverture de la sessions sous windows]]></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.4</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>Windows</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/SessionLoader/Windows/plugin.json b/plugins/SessionLoader/Windows/plugin.json
new file mode 100644
index 0000000..9e26dfe
--- /dev/null
+++ b/plugins/SessionLoader/Windows/plugin.json
@@ -0,0 +1 @@
+{} \ No newline at end of file
diff --git a/plugins/SessionLoader/Windows/sessionLoader.cpp b/plugins/SessionLoader/Windows/sessionLoader.cpp
new file mode 100644
index 0000000..121bae0
--- /dev/null
+++ b/plugins/SessionLoader/Windows/sessionLoader.cpp
@@ -0,0 +1,80 @@
+/** \file session-loader.cpp
+\brief Define the session plugin loader test
+\author alpha_one_x86 */
+
+#include "sessionLoader.h"
+
+#include <QCoreApplication>
+
+#ifdef Q_OS_WIN32
+ #ifndef NOMINMAX
+ #define NOMINMAX
+ #endif
+ #include <windows.h>
+#else
+ #error "This plugin will only work under Windows"
+#endif
+
+void WindowsSessionLoader::setEnabled(const bool &newValue)
+{
+ ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Notice,"start, newValue: "+std::to_string(newValue));
+ //set value into the variable
+ HKEY ultracopier_regkey;
+ //for autostart
+ QString runStringApp = "\"" + QCoreApplication::applicationFilePath() + "\"";
+ runStringApp.replace( "/", "\\" );
+ wchar_t windowsString[255];
+ runStringApp.toWCharArray(windowsString);
+ if(RegCreateKeyEx(HKEY_CURRENT_USER, TEXT("Software\\Microsoft\\Windows\\CurrentVersion\\Run"), 0, 0, REG_OPTION_NON_VOLATILE,KEY_ALL_ACCESS, 0, &ultracopier_regkey, 0)==ERROR_SUCCESS)
+ {
+ if(newValue)
+ {
+ if(RegSetValueEx(ultracopier_regkey, TEXT("ultracopier"), 0, REG_SZ, (BYTE*)windowsString, runStringApp.length()*2)!=ERROR_SUCCESS)
+ ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Notice,"newValue: "+std::to_string(newValue)+" failed");
+ }
+ else
+ {
+ if(RegDeleteValue(ultracopier_regkey, TEXT("ultracopier"))!=ERROR_SUCCESS)
+ ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Notice,"newValue: "+std::to_string(newValue)+" failed");
+ }
+ RegCloseKey(ultracopier_regkey);
+ }
+ else
+ ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Notice,"RegCreateKeyEx: Software\\Microsoft\\Windows\\CurrentVersion\\Run failed");
+}
+
+bool WindowsSessionLoader::getEnabled() const
+{
+ //return the value into the variable
+ HKEY ultracopier_regkey;
+ bool temp=false;
+ if(RegCreateKeyEx(HKEY_CURRENT_USER, TEXT("Software\\Microsoft\\Windows\\CurrentVersion\\Run"), 0, 0, REG_OPTION_NON_VOLATILE,KEY_ALL_ACCESS, 0, &ultracopier_regkey, 0)==ERROR_SUCCESS)
+ {
+ DWORD kSize=254;
+ if(RegQueryValueEx(ultracopier_regkey,TEXT("ultracopier"),NULL,NULL,(LPBYTE)0,&kSize) == ERROR_SUCCESS)
+ temp=true;
+ RegCloseKey(ultracopier_regkey);
+ }
+ else
+ ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Notice,"RegCreateKeyEx: Software\\Microsoft\\Windows\\CurrentVersion\\Run failed");
+ return temp;
+}
+
+void WindowsSessionLoader::setResources(OptionInterface * options,const std::string &writePath,const std::string &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 * WindowsSessionLoader::options()
+{
+ return NULL;
+}
+
+/// \brief to reload the translation, because the new language have been loaded
+void WindowsSessionLoader::newLanguageLoaded()
+{
+}
diff --git a/plugins/SessionLoader/Windows/sessionLoader.h b/plugins/SessionLoader/Windows/sessionLoader.h
new file mode 100644
index 0000000..b064e50
--- /dev/null
+++ b/plugins/SessionLoader/Windows/sessionLoader.h
@@ -0,0 +1,33 @@
+/** \file sessionLoader.h
+\brief Define the session loader
+\author alpha_one_x86
+\licence GPL3, see the file COPYING */
+
+#ifndef SESSION_LOADER_H
+#define SESSION_LOADER_H
+
+#include <QObject>
+#include "Environment.h"
+#include "../../../interface/PluginInterface_SessionLoader.h"
+
+/// \brief Define the session loader
+class WindowsSessionLoader : public PluginInterface_SessionLoader
+{
+ Q_OBJECT
+ Q_PLUGIN_METADATA(IID "first-world.info.ultracopier.PluginInterface.SessionLoader/1.0.0.0" FILE "plugin.json")
+ Q_INTERFACES(PluginInterface_SessionLoader)
+public:
+ /// \brief to set if it's enabled or not
+ void setEnabled(const bool &newValue);
+ /// \brief to get if is enabled
+ bool getEnabled() const;
+ /// \brief set the resources for the plugins
+ void setResources(OptionInterface * options,const std::string &writePath,const std::string &pluginPath,const bool &portableVersion);
+ /// \brief to get the options widget, NULL if not have
+ QWidget * options();
+public slots:
+ /// \brief to reload the translation, because the new language have been loaded
+ void newLanguageLoaded();
+};
+
+#endif // SESSION_LOADER_H
diff --git a/plugins/SessionLoader/Windows/sessionLoader.pro b/plugins/SessionLoader/Windows/sessionLoader.pro
new file mode 100644
index 0000000..1059692
--- /dev/null
+++ b/plugins/SessionLoader/Windows/sessionLoader.pro
@@ -0,0 +1,16 @@
+CONFIG += c++11
+QMAKE_CXXFLAGS+="-std=c++0x -Wall -Wextra"
+mac:QMAKE_CXXFLAGS+="-stdlib=libc++"
+
+TEMPLATE = lib
+CONFIG += plugin
+LIBS += -ladvapi32
+HEADERS = \
+ $$PWD/sessionLoader.h \
+ $$PWD/StructEnumDefinition.h \
+ $$PWD/Variable.h \
+ $$PWD/Environment.h \
+ $$PWD/DebugEngineMacro.h \
+ $$PWD/../../../interface/PluginInterface_SessionLoader.h
+SOURCES = sessionLoader.cpp
+TARGET = $$qtLibraryTarget(sessionLoader)