Skip to content
Browse files

moving everything to github

  • Loading branch information...
1 parent f7a91fd commit 38fe6790172cb4194ce28f9c5ac9fafb4cc1ef84 @mikhailvs mikhailvs committed
Showing with 2,956 additions and 0 deletions.
  1. +32 −0 code/OpenPuush/OpenPuush.pro
  2. +242 −0 code/OpenPuush/OpenPuush.pro.user
  3. +6 −0 code/OpenPuush/audio_mgr.cpp
  4. +18 −0 code/OpenPuush/audio_mgr.hpp
  5. +109 −0 code/OpenPuush/config.cpp
  6. +57 −0 code/OpenPuush/config.hpp
  7. +336 −0 code/OpenPuush/configwindow.cpp
  8. +88 −0 code/OpenPuush/configwindow.hpp
  9. +712 −0 code/OpenPuush/configwindow.ui
  10. +373 −0 code/OpenPuush/dropbox.cpp
  11. +105 −0 code/OpenPuush/dropbox.hpp
  12. +16 −0 code/OpenPuush/main.cpp
  13. +509 −0 code/OpenPuush/openpuush.cpp
  14. +94 −0 code/OpenPuush/openpuush.hpp
  15. +159 −0 code/OpenPuush/screenshot_overlay.cpp
  16. +43 −0 code/OpenPuush/screenshot_overlay.hpp
  17. +14 −0 code/OpenPuush/tray_menu.cpp
  18. +22 −0 code/OpenPuush/tray_menu.hpp
  19. +21 −0 code/OpenPuush/tray_menu.ui
  20. BIN graphics/apple.png
  21. BIN graphics/download_blank.png
  22. BIN graphics/iconset/0.png
  23. BIN graphics/iconset/1.png
  24. BIN graphics/iconset/10.png
  25. BIN graphics/iconset/2.png
  26. BIN graphics/iconset/3.png
  27. BIN graphics/iconset/4.png
  28. BIN graphics/iconset/5.png
  29. BIN graphics/iconset/6.png
  30. BIN graphics/iconset/7.png
  31. BIN graphics/iconset/8.png
  32. BIN graphics/iconset/9.png
  33. BIN graphics/iconset/error.png
  34. BIN graphics/iconset/success.png
  35. BIN graphics/openpush_logo.png
  36. BIN graphics/small_icons/0.png
  37. BIN graphics/small_icons/1.png
  38. BIN graphics/small_icons/10.png
  39. BIN graphics/small_icons/2.png
  40. BIN graphics/small_icons/3.png
  41. BIN graphics/small_icons/4.png
  42. BIN graphics/small_icons/5.png
  43. BIN graphics/small_icons/6.png
  44. BIN graphics/small_icons/7.png
  45. BIN graphics/small_icons/8.png
  46. BIN graphics/small_icons/9.png
  47. BIN graphics/small_icons/error.png
  48. BIN graphics/small_icons/success.png
  49. BIN graphics/windows.png
  50. BIN sounds/1.ogg
  51. BIN sounds/meh.ogg
View
32 code/OpenPuush/OpenPuush.pro
@@ -0,0 +1,32 @@
+######################################################################
+# Automatically generated by qmake (2.01a) Fri Aug 10 20:31:37 2012
+######################################################################
+
+TEMPLATE = app
+TARGET = OpenPuush
+DEPENDPATH += .
+INCLUDEPATH += .
+
+CONFIG += qxt
+QT += core gui network
+QXT += core gui
+
+# Input
+HEADERS += dropbox.hpp screenshot_overlay.hpp \
+ openpuush.hpp \
+ configwindow.hpp \
+ audio_mgr.hpp \
+ config.hpp \
+ tray_menu.hpp
+SOURCES += dropbox.cpp main.cpp screenshot_overlay.cpp \
+ openpuush.cpp \
+ configwindow.cpp \
+ audio_mgr.cpp \
+ config.cpp \
+ tray_menu.cpp
+
+LIBS += -lphonon
+
+FORMS += \
+ configwindow.ui \
+ tray_menu.ui
View
242 code/OpenPuush/OpenPuush.pro.user
@@ -0,0 +1,242 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE QtCreatorProject>
+<!-- Written by Qt Creator 2.5.2, 2012-08-20T20:52:02. -->
+<qtcreator>
+ <data>
+ <variable>ProjectExplorer.Project.ActiveTarget</variable>
+ <value type="int">0</value>
+ </data>
+ <data>
+ <variable>ProjectExplorer.Project.EditorSettings</variable>
+ <valuemap type="QVariantMap">
+ <value type="bool" key="EditorConfiguration.AutoIndent">true</value>
+ <value type="bool" key="EditorConfiguration.AutoSpacesForTabs">false</value>
+ <value type="bool" key="EditorConfiguration.CamelCaseNavigation">true</value>
+ <valuemap type="QVariantMap" key="EditorConfiguration.CodeStyle.0">
+ <value type="QString" key="language">Cpp</value>
+ <valuemap type="QVariantMap" key="value">
+ <value type="QString" key="CurrentPreferences">CppGlobal</value>
+ </valuemap>
+ </valuemap>
+ <valuemap type="QVariantMap" key="EditorConfiguration.CodeStyle.1">
+ <value type="QString" key="language">QmlJS</value>
+ <valuemap type="QVariantMap" key="value">
+ <value type="QString" key="CurrentPreferences">QmlJSGlobal</value>
+ </valuemap>
+ </valuemap>
+ <value type="int" key="EditorConfiguration.CodeStyle.Count">2</value>
+ <value type="QByteArray" key="EditorConfiguration.Codec">System</value>
+ <value type="bool" key="EditorConfiguration.ConstrainTooltips">false</value>
+ <value type="int" key="EditorConfiguration.IndentSize">4</value>
+ <value type="bool" key="EditorConfiguration.KeyboardTooltips">false</value>
+ <value type="bool" key="EditorConfiguration.MouseNavigation">true</value>
+ <value type="int" key="EditorConfiguration.PaddingMode">1</value>
+ <value type="bool" key="EditorConfiguration.ScrollWheelZooming">true</value>
+ <value type="int" key="EditorConfiguration.SmartBackspaceBehavior">0</value>
+ <value type="bool" key="EditorConfiguration.SpacesForTabs">true</value>
+ <value type="int" key="EditorConfiguration.TabKeyBehavior">0</value>
+ <value type="int" key="EditorConfiguration.TabSize">8</value>
+ <value type="bool" key="EditorConfiguration.UseGlobal">true</value>
+ <value type="int" key="EditorConfiguration.Utf8BomBehavior">1</value>
+ <value type="bool" key="EditorConfiguration.addFinalNewLine">true</value>
+ <value type="bool" key="EditorConfiguration.cleanIndentation">true</value>
+ <value type="bool" key="EditorConfiguration.cleanWhitespace">true</value>
+ <value type="bool" key="EditorConfiguration.inEntireDocument">false</value>
+ </valuemap>
+ </data>
+ <data>
+ <variable>ProjectExplorer.Project.PluginSettings</variable>
+ <valuemap type="QVariantMap"/>
+ </data>
+ <data>
+ <variable>ProjectExplorer.Project.Target.0</variable>
+ <valuemap type="QVariantMap">
+ <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Desktop</value>
+ <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Desktop</value>
+ <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.Target.DesktopTarget</value>
+ <value type="int" key="ProjectExplorer.Target.ActiveBuildConfiguration">1</value>
+ <value type="int" key="ProjectExplorer.Target.ActiveDeployConfiguration">0</value>
+ <value type="int" key="ProjectExplorer.Target.ActiveRunConfiguration">0</value>
+ <valuemap type="QVariantMap" key="ProjectExplorer.Target.BuildConfiguration.0">
+ <value type="QString" key="ProjectExplorer.BuildCOnfiguration.ToolChain">ProjectExplorer.ToolChain.Gcc:{606b30ab-642e-4f5b-85de-4711b597e6e7}</value>
+ <valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
+ <valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
+ <value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
+ <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">qmake</value>
+ <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
+ <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">QtProjectManager.QMakeBuildStep</value>
+ <value type="bool" key="QtProjectManager.QMakeBuildStep.LinkQmlDebuggingLibrary">false</value>
+ <value type="bool" key="QtProjectManager.QMakeBuildStep.LinkQmlDebuggingLibraryAuto">true</value>
+ <value type="QString" key="QtProjectManager.QMakeBuildStep.QMakeArguments"></value>
+ <value type="bool" key="QtProjectManager.QMakeBuildStep.QMakeForced">false</value>
+ </valuemap>
+ <valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.1">
+ <value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
+ <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Make</value>
+ <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
+ <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.MakeStep</value>
+ <value type="bool" key="Qt4ProjectManager.MakeStep.Clean">false</value>
+ <value type="QString" key="Qt4ProjectManager.MakeStep.MakeArguments"></value>
+ <value type="QString" key="Qt4ProjectManager.MakeStep.MakeCommand"></value>
+ </valuemap>
+ <value type="int" key="ProjectExplorer.BuildStepList.StepsCount">2</value>
+ <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Build</value>
+ <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
+ <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Build</value>
+ </valuemap>
+ <valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.1">
+ <valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
+ <value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
+ <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Make</value>
+ <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
+ <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.MakeStep</value>
+ <value type="bool" key="Qt4ProjectManager.MakeStep.Clean">true</value>
+ <value type="QString" key="Qt4ProjectManager.MakeStep.MakeArguments">clean</value>
+ <value type="QString" key="Qt4ProjectManager.MakeStep.MakeCommand"></value>
+ </valuemap>
+ <value type="int" key="ProjectExplorer.BuildStepList.StepsCount">1</value>
+ <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Clean</value>
+ <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
+ <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Clean</value>
+ </valuemap>
+ <value type="int" key="ProjectExplorer.BuildConfiguration.BuildStepListCount">2</value>
+ <value type="bool" key="ProjectExplorer.BuildConfiguration.ClearSystemEnvironment">false</value>
+ <valuelist type="QVariantList" key="ProjectExplorer.BuildConfiguration.UserEnvironmentChanges"/>
+ <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Qt 4.8.1 in PATH (System) Release</value>
+ <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
+ <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.Qt4BuildConfiguration</value>
+ <value type="int" key="Qt4ProjectManager.Qt4BuildConfiguration.BuildConfiguration">0</value>
+ <value type="QString" key="Qt4ProjectManager.Qt4BuildConfiguration.BuildDirectory">/home/mikhail/Desktop/schemes/openpush/code/OpenPuush/OpenPuush-build-desktop-Qt_4_8_1_in_PATH__System__Release</value>
+ <value type="int" key="Qt4ProjectManager.Qt4BuildConfiguration.QtVersionId">1</value>
+ <value type="bool" key="Qt4ProjectManager.Qt4BuildConfiguration.UseShadowBuild">true</value>
+ </valuemap>
+ <valuemap type="QVariantMap" key="ProjectExplorer.Target.BuildConfiguration.1">
+ <value type="QString" key="ProjectExplorer.BuildCOnfiguration.ToolChain">ProjectExplorer.ToolChain.Gcc:{606b30ab-642e-4f5b-85de-4711b597e6e7}</value>
+ <valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
+ <valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
+ <value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
+ <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">qmake</value>
+ <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
+ <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">QtProjectManager.QMakeBuildStep</value>
+ <value type="bool" key="QtProjectManager.QMakeBuildStep.LinkQmlDebuggingLibrary">false</value>
+ <value type="bool" key="QtProjectManager.QMakeBuildStep.LinkQmlDebuggingLibraryAuto">true</value>
+ <value type="QString" key="QtProjectManager.QMakeBuildStep.QMakeArguments"></value>
+ <value type="bool" key="QtProjectManager.QMakeBuildStep.QMakeForced">false</value>
+ </valuemap>
+ <valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.1">
+ <value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
+ <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Make</value>
+ <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
+ <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.MakeStep</value>
+ <value type="bool" key="Qt4ProjectManager.MakeStep.Clean">false</value>
+ <value type="QString" key="Qt4ProjectManager.MakeStep.MakeArguments"></value>
+ <value type="QString" key="Qt4ProjectManager.MakeStep.MakeCommand"></value>
+ </valuemap>
+ <value type="int" key="ProjectExplorer.BuildStepList.StepsCount">2</value>
+ <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Build</value>
+ <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
+ <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Build</value>
+ </valuemap>
+ <valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.1">
+ <valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
+ <value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
+ <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Make</value>
+ <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
+ <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.MakeStep</value>
+ <value type="bool" key="Qt4ProjectManager.MakeStep.Clean">true</value>
+ <value type="QString" key="Qt4ProjectManager.MakeStep.MakeArguments">clean</value>
+ <value type="QString" key="Qt4ProjectManager.MakeStep.MakeCommand"></value>
+ </valuemap>
+ <value type="int" key="ProjectExplorer.BuildStepList.StepsCount">1</value>
+ <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Clean</value>
+ <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
+ <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Clean</value>
+ </valuemap>
+ <value type="int" key="ProjectExplorer.BuildConfiguration.BuildStepListCount">2</value>
+ <value type="bool" key="ProjectExplorer.BuildConfiguration.ClearSystemEnvironment">false</value>
+ <valuelist type="QVariantList" key="ProjectExplorer.BuildConfiguration.UserEnvironmentChanges"/>
+ <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Qt 4.8.1 in PATH (System) Debug</value>
+ <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
+ <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.Qt4BuildConfiguration</value>
+ <value type="int" key="Qt4ProjectManager.Qt4BuildConfiguration.BuildConfiguration">2</value>
+ <value type="QString" key="Qt4ProjectManager.Qt4BuildConfiguration.BuildDirectory">/home/mikhail/Desktop/schemes/openpush/code/OpenPuush/OpenPuush-build-desktop-Qt_4_8_1_in_PATH__System__Debug</value>
+ <value type="int" key="Qt4ProjectManager.Qt4BuildConfiguration.QtVersionId">1</value>
+ <value type="bool" key="Qt4ProjectManager.Qt4BuildConfiguration.UseShadowBuild">true</value>
+ </valuemap>
+ <value type="int" key="ProjectExplorer.Target.BuildConfigurationCount">2</value>
+ <valuemap type="QVariantMap" key="ProjectExplorer.Target.DeployConfiguration.0">
+ <valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
+ <value type="int" key="ProjectExplorer.BuildStepList.StepsCount">0</value>
+ <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Deploy</value>
+ <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
+ <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Deploy</value>
+ </valuemap>
+ <value type="int" key="ProjectExplorer.BuildConfiguration.BuildStepListCount">1</value>
+ <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">No deployment</value>
+ <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
+ <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.DefaultDeployConfiguration</value>
+ </valuemap>
+ <value type="int" key="ProjectExplorer.Target.DeployConfigurationCount">1</value>
+ <valuemap type="QVariantMap" key="ProjectExplorer.Target.RunConfiguration.0">
+ <value type="bool" key="Analyzer.Project.UseGlobal">true</value>
+ <valuelist type="QVariantList" key="Analyzer.Valgrind.AddedSuppressionFiles"/>
+ <value type="bool" key="Analyzer.Valgrind.Callgrind.CollectBusEvents">false</value>
+ <value type="bool" key="Analyzer.Valgrind.Callgrind.CollectSystime">false</value>
+ <value type="bool" key="Analyzer.Valgrind.Callgrind.EnableBranchSim">false</value>
+ <value type="bool" key="Analyzer.Valgrind.Callgrind.EnableCacheSim">false</value>
+ <value type="bool" key="Analyzer.Valgrind.Callgrind.EnableEventToolTips">true</value>
+ <value type="double" key="Analyzer.Valgrind.Callgrind.MinimumCostRatio">0.01</value>
+ <value type="double" key="Analyzer.Valgrind.Callgrind.VisualisationMinimumCostRatio">10</value>
+ <value type="bool" key="Analyzer.Valgrind.FilterExternalIssues">true</value>
+ <value type="int" key="Analyzer.Valgrind.NumCallers">25</value>
+ <valuelist type="QVariantList" key="Analyzer.Valgrind.RemovedSuppressionFiles"/>
+ <value type="bool" key="Analyzer.Valgrind.TrackOrigins">true</value>
+ <value type="QString" key="Analyzer.Valgrind.ValgrindExecutable">valgrind</value>
+ <valuelist type="QVariantList" key="Analyzer.Valgrind.VisibleErrorKinds">
+ <value type="int">0</value>
+ <value type="int">1</value>
+ <value type="int">2</value>
+ <value type="int">3</value>
+ <value type="int">4</value>
+ <value type="int">5</value>
+ <value type="int">6</value>
+ <value type="int">7</value>
+ <value type="int">8</value>
+ <value type="int">9</value>
+ <value type="int">10</value>
+ <value type="int">11</value>
+ <value type="int">12</value>
+ <value type="int">13</value>
+ <value type="int">14</value>
+ </valuelist>
+ <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">OpenPuush</value>
+ <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
+ <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.Qt4RunConfiguration</value>
+ <value type="int" key="Qt4ProjectManager.Qt4RunConfiguration.BaseEnvironmentBase">2</value>
+ <value type="QString" key="Qt4ProjectManager.Qt4RunConfiguration.CommandLineArguments"></value>
+ <value type="QString" key="Qt4ProjectManager.Qt4RunConfiguration.ProFile">OpenPuush.pro</value>
+ <value type="bool" key="Qt4ProjectManager.Qt4RunConfiguration.UseDyldImageSuffix">false</value>
+ <value type="bool" key="Qt4ProjectManager.Qt4RunConfiguration.UseTerminal">false</value>
+ <valuelist type="QVariantList" key="Qt4ProjectManager.Qt4RunConfiguration.UserEnvironmentChanges"/>
+ <value type="QString" key="Qt4ProjectManager.Qt4RunConfiguration.UserWorkingDirectory"></value>
+ <value type="uint" key="RunConfiguration.QmlDebugServerPort">3768</value>
+ <value type="bool" key="RunConfiguration.UseCppDebugger">true</value>
+ <value type="bool" key="RunConfiguration.UseQmlDebugger">false</value>
+ <value type="bool" key="RunConfiguration.UseQmlDebuggerAuto">true</value>
+ </valuemap>
+ <value type="int" key="ProjectExplorer.Target.RunConfigurationCount">1</value>
+ </valuemap>
+ </data>
+ <data>
+ <variable>ProjectExplorer.Project.TargetCount</variable>
+ <value type="int">1</value>
+ </data>
+ <data>
+ <variable>ProjectExplorer.Project.Updater.EnvironmentId</variable>
+ <value type="QString">{504dd5fd-b903-4b87-a9dc-5c1e1bfefc06}</value>
+ </data>
+ <data>
+ <variable>ProjectExplorer.Project.Updater.FileVersion</variable>
+ <value type="int">11</value>
+ </data>
+</qtcreator>
View
6 code/OpenPuush/audio_mgr.cpp
@@ -0,0 +1,6 @@
+#include "audio_mgr.hpp"
+
+audio_mgr::audio_mgr(QObject *parent) :
+ QObject(parent)
+{
+}
View
18 code/OpenPuush/audio_mgr.hpp
@@ -0,0 +1,18 @@
+#ifndef AUDIO_MGR_HPP
+#define AUDIO_MGR_HPP
+
+#include <QObject>
+
+class audio_mgr : public QObject
+{
+ Q_OBJECT
+public:
+ explicit audio_mgr(QObject *parent = 0);
+
+signals:
+
+public slots:
+
+};
+
+#endif // AUDIO_MGR_HPP
View
109 code/OpenPuush/config.cpp
@@ -0,0 +1,109 @@
+#include <cstdlib>
+#include <QSettings>
+#include <QString>
+
+#include "config.hpp"
+
+static const char * names[] = {
+ "dropbox/oauth/access_token_secret",
+ "dropbox/oauth/access_token",
+ "dropbox/user/display_name",
+ "dropbox/user/uid",
+ "dropbox/user/used",
+ "general/general_settings/start_on_boot",
+ "general/on_upload/sound_notification",
+ "general/on_upload/copy_link",
+ "general/on_upload/open_link",
+ "general/on_upload/save_copy",
+ "general/on_upload/local_copy_path",
+ "general/icon_onclick/show_settings",
+ "general/icon_onclick/begin_screen_capture",
+ "general/icon_onclick/open_file_dialog",
+ "shortcuts/capture_fullscreen",
+ "shortcuts/capture_current_window",
+ "shortcuts/capture_area",
+ "shortcuts/upload_file",
+ "shortcuts/upload_clipboard",
+ "shortcuts/toggle_functionality",
+ "updates/last_update_check",
+ "advanced/compression/no_compression",
+ "advanced/compression/smart_compression",
+ "advanced/desktop_integration/show_explorer_menu",
+ "advanced/multiple_monitors/capture_all_screens",
+ "advanced/multiple_monitors/capture_screen_with_cursor",
+ "advanced/multiple_monitors/capture_primary_screen",
+ "advanced/experimental/enable_experimental"
+};
+
+static QSettings * _instance;
+
+config::config()
+{
+ std::atexit(&cleanup);
+}
+
+void config::cleanup()
+{
+ if (_instance)
+ {
+ delete _instance;
+ _instance = 0;
+ }
+}
+
+QSettings & config::instance()
+{
+ static QSettings * _instance = 0;
+ if (!_instance)
+ {
+ _instance = new QSettings(QSettings::IniFormat, QSettings::UserScope, "opuu.sh", "OpenPuush");
+ }
+ return *_instance;
+}
+
+void config::save(setting setting, const QVariant & val)
+{
+ instance().setValue(names[setting], val);
+}
+
+QVariant config::load(config::setting setting, const QVariant & def)
+{
+ return instance().value(names[setting], def);
+}
+
+void config::defaults()
+{
+ save(START_ON_BOOT, true);
+ save(SOUND_NOTIFICATION, true);
+ save(COPY_LINK, true);
+ save(OPEN_LINK, false);
+ save(SAVE_COPY, false);
+ save(LOCAL_COPY_PATH, "");
+ save(SHOW_SETTINGS, true);
+ save(BEGIN_SCREEN_CAPTURE, false);
+ save(OPEN_FILE_DIALOG, false);
+ save(CAPTURE_FULLSCREEN, "Ctrl+Shift+3");
+ save(CAPTURE_CURRENT_WINDOW, "Ctrl+Shift+2");
+ save(CAPTURE_AREA, "Ctrl+Shift+4");
+ save(UPLOAD_FILE, "Ctrl+Shift+U");
+ save(UPLOAD_CLIPBOARD, "Ctrl+Shift+5");
+ save(TOGGLE_FUNCTIONALITY, "Ctrl+Alt+P");
+ save(LAST_UPDATE_CHECK, 0);
+ save(NO_COMPRESSION, true);
+ save(SMART_COMPRESSION, false);
+ save(SHOW_EXPLORER_MENU, true);
+ save(CAPTURE_ALL_SCREENS, true);
+ save(CAPTURE_SCREEN_WITH_CURSOR, false);
+ save(CAPTURE_PRIMARY_SCREEN, false);
+ save(ENABLE_EXPERIMENTAL, false);
+}
+
+bool config::first_run()
+{
+ bool r = 0;
+ for (int i = 5; i < 28; ++i)
+ {
+ r |= instance().contains(names[i]);
+ }
+ return !r;
+}
View
57 code/OpenPuush/config.hpp
@@ -0,0 +1,57 @@
+#ifndef CONFIG_HPP
+#define CONFIG_HPP
+
+#include <QVariant>
+#define UNUSED(x) (void)(x)
+
+class QString;
+class QSettings;
+
+class config
+{
+public:
+ enum setting
+ {
+ DROPBOX_OAUTH_ACCESS_TOKEN_SECRET = 0,
+ DROPBOX_OAUTH_ACCESS_TOKEN,
+ DROPBOX_DISPLAY_NAME,
+ DROPBOX_UID,
+ DROPBOX_USED,
+ START_ON_BOOT,
+ SOUND_NOTIFICATION,
+ COPY_LINK,
+ OPEN_LINK,
+ SAVE_COPY,
+ LOCAL_COPY_PATH,
+ SHOW_SETTINGS,
+ BEGIN_SCREEN_CAPTURE,
+ OPEN_FILE_DIALOG,
+ CAPTURE_FULLSCREEN,
+ CAPTURE_CURRENT_WINDOW,
+ CAPTURE_AREA,
+ UPLOAD_FILE,
+ UPLOAD_CLIPBOARD,
+ TOGGLE_FUNCTIONALITY,
+ LAST_UPDATE_CHECK,
+ NO_COMPRESSION,
+ SMART_COMPRESSION,
+ SHOW_EXPLORER_MENU,
+ CAPTURE_ALL_SCREENS,
+ CAPTURE_SCREEN_WITH_CURSOR,
+ CAPTURE_PRIMARY_SCREEN,
+ ENABLE_EXPERIMENTAL,
+ NONE
+ };
+
+ static void save(setting, const QVariant &);
+ static QVariant load(setting, const QVariant & def = QVariant());
+ static void defaults();
+ static bool first_run();
+
+private:
+ config();
+ static void cleanup();
+ static QSettings & instance();
+};
+
+#endif // CONFIG_HPP
View
336 code/OpenPuush/configwindow.cpp
@@ -0,0 +1,336 @@
+#include <QFileDialog>
+#include <QDir>
+#include <QDebug>
+#include <QKeyEvent>
+#include <QDesktopServices>
+#include <QUrl>
+
+#include "configwindow.hpp"
+#include "ui_configwindow.h"
+
+#define TOGGLE_SETTING(m, s) void configwindow::m(bool _) { \
+ config::save(config::s, _); \
+}
+
+#define SET_SHORTCUT(m, s) void configwindow::m() { \
+ current_shortcut = config::s; \
+ n_keys_pressed = 0; \
+ emit set_shortcuts_enabled(false, false); \
+}
+
+#define LOAD_CHECKBOX(m, s) ui->m->setChecked(config::load(config::s).toBool())
+
+#define LOAD_SHORTCUT(m, s) ui->m->setText(config::load(config::s).toString())
+
+configwindow::configwindow(QWidget *parent) :
+ QTabWidget(parent),
+ ui(new Ui::configwindow),
+ n_keys_pressed(0),
+ logged_in(true)
+{
+ ui->setupUi(this);
+
+ current_shortcut = config::NONE;
+
+ init_settings();
+ init_account();
+}
+
+configwindow::~configwindow()
+{
+ delete ui;
+}
+
+void configwindow::init_settings()
+{
+ LOAD_CHECKBOX(start_on_startup, START_ON_BOOT);
+ LOAD_CHECKBOX(play_notification_sound, SOUND_NOTIFICATION);
+ LOAD_CHECKBOX(copy_link_to_clipboard, COPY_LINK);
+ LOAD_CHECKBOX(open_link_in_browser, OPEN_LINK);
+ LOAD_CHECKBOX(save_a_local_copy_of_image, SAVE_COPY);
+ LOAD_CHECKBOX(show_settings_dialog, SHOW_SETTINGS);
+ LOAD_CHECKBOX(begin_screen_capture_mode, BEGIN_SCREEN_CAPTURE);
+ LOAD_CHECKBOX(open_upload_file_dialog, OPEN_FILE_DIALOG);
+ LOAD_CHECKBOX(no_compression, NO_COMPRESSION);
+ LOAD_CHECKBOX(smart_compression, SMART_COMPRESSION);
+ LOAD_CHECKBOX(show_context_menu, SHOW_EXPLORER_MENU);
+ LOAD_CHECKBOX(capture_all_screens, CAPTURE_ALL_SCREENS);
+ LOAD_CHECKBOX(capture_primary_screen, CAPTURE_PRIMARY_SCREEN);
+ LOAD_CHECKBOX(capture_screen_with_cursor, CAPTURE_SCREEN_WITH_CURSOR);
+ LOAD_CHECKBOX(enable_experimental_features, ENABLE_EXPERIMENTAL);
+
+ LOAD_SHORTCUT(capture_fullscreen_button, CAPTURE_FULLSCREEN);
+ LOAD_SHORTCUT(capture_current_window_button, CAPTURE_CURRENT_WINDOW);
+ LOAD_SHORTCUT(capture_area_button, CAPTURE_AREA);
+ LOAD_SHORTCUT(upload_file_button, UPLOAD_FILE);
+ LOAD_SHORTCUT(upload_clipboard_button, UPLOAD_CLIPBOARD);
+ LOAD_SHORTCUT(toggle_functionality_button, TOGGLE_FUNCTIONALITY);
+
+ ui->save_a_local_copy_of_image->setEnabled(config::load(config::SAVE_COPY).toBool());
+ ui->path_to_local_copy->setText(config::load(config::LOCAL_COPY_PATH).toString());
+}
+
+TOGGLE_SETTING(on_play_notification_sound_toggled, SOUND_NOTIFICATION)
+TOGGLE_SETTING(on_copy_link_to_clipboard_toggled, COPY_LINK)
+TOGGLE_SETTING(on_open_link_in_browser_toggled, OPEN_LINK)
+TOGGLE_SETTING(on_show_settings_dialog_toggled, SHOW_SETTINGS)
+TOGGLE_SETTING(on_begin_screen_capture_mode_toggled, BEGIN_SCREEN_CAPTURE)
+TOGGLE_SETTING(on_open_upload_file_dialog_toggled, OPEN_FILE_DIALOG)
+TOGGLE_SETTING(on_no_compression_toggled, NO_COMPRESSION)
+TOGGLE_SETTING(on_smart_compression_toggled, SMART_COMPRESSION)
+TOGGLE_SETTING(on_show_context_menu_toggled, SHOW_EXPLORER_MENU)
+TOGGLE_SETTING(on_capture_all_screens_toggled, CAPTURE_ALL_SCREENS)
+TOGGLE_SETTING(on_capture_primary_screen_toggled, CAPTURE_PRIMARY_SCREEN)
+TOGGLE_SETTING(on_capture_screen_with_cursor_toggled, CAPTURE_SCREEN_WITH_CURSOR)
+TOGGLE_SETTING(on_enable_experimental_features_toggled, ENABLE_EXPERIMENTAL)
+
+void configwindow::on_start_on_startup_toggled(bool checked)
+{
+ config::save(config::START_ON_BOOT, checked);
+
+ emit toggle_start_on_boot();
+}
+
+void configwindow::on_save_a_local_copy_of_image_toggled(bool checked)
+{
+ if (!checked)
+ {
+ ui->save_a_local_copy_of_image->setChecked(checked);
+ ui->save_a_local_copy_of_image->setEnabled(false);
+ ui->path_to_local_copy->setText("");
+ config::save(config::SAVE_COPY, false);
+ qDebug() << "here i am, in on_save_a_local_copy_of_image_toggled";
+ }
+}
+
+void configwindow::on_browse_for_local_path_clicked()
+{
+ QString dir = QFileDialog::getExistingDirectory(this, "Choose where to store local copies",
+ QDir::homePath());
+
+ if (QDir(dir).exists())
+ {
+ ui->path_to_local_copy->setText(dir);
+
+ config::save(config::LOCAL_COPY_PATH, dir);
+ config::save(config::SAVE_COPY, true);
+ ui->save_a_local_copy_of_image->setChecked(true);
+ ui->save_a_local_copy_of_image->setEnabled(true);
+ }
+ else
+ {
+ emit error_occurred("The directory you selected doesnt exist!");
+ }
+}
+
+QString configwindow::lookup(int key)
+{
+ QString str;
+ switch ((Qt::Key) key)
+ {
+#define _case(key) case Qt::Key_##key:{str=#key;break;}
+#define __case(key, val) case Qt::Key_##key:{str=#val;break;}
+ _case(Shift)
+ __case(Control, Ctrl)
+ _case(Meta)
+ _case(Alt)
+ _case(CapsLock)
+ _case(NumLock)
+ _case(ScrollLock)
+ _case(Return)
+ _case(Enter)
+ _case(Insert)
+ _case(Delete)
+ _case(Left)
+ _case(Up)
+ _case(Right)
+ _case(Down)
+ _case(Escape)
+ _case(A)
+ _case(B)
+ _case(C)
+ _case(D)
+ _case(E)
+ _case(F)
+ _case(G)
+ _case(H)
+ _case(I)
+ _case(J)
+ _case(K)
+ _case(L)
+ _case(M)
+ _case(N)
+ _case(O)
+ _case(P)
+ _case(Q)
+ _case(R)
+ _case(S)
+ _case(T)
+ _case(U)
+ _case(V)
+ _case(W)
+ _case(X)
+ _case(Y)
+ _case(Z)
+ case Qt::Key_ParenRight:
+ _case(0)
+ case Qt::Key_Exclam:
+ _case(1)
+ case Qt::Key_At:
+ _case(2)
+ case Qt::Key_NumberSign:
+ _case(3)
+ case Qt::Key_Dollar:
+ _case(4)
+ case Qt::Key_Percent:
+ _case(5)
+ case Qt::Key_AsciiCircum: // "caret"
+ _case(6)
+ case Qt::Key_Ampersand:
+ _case(7)
+ case Qt::Key_Asterisk:
+ _case(8)
+ case Qt::Key_ParenLeft:
+ _case(9)
+#undef _case
+#undef __case
+ default:
+ break;
+ }
+ return str;
+}
+
+void configwindow::keyPressEvent(QKeyEvent * e)
+{
+ QTabWidget::keyPressEvent(e);
+ if (current_shortcut != config::NONE)
+ {
+ ++n_keys_pressed;
+ keys_pressed.append(lookup(e->key()));
+ }
+}
+
+void configwindow::keyReleaseEvent(QKeyEvent * e)
+{
+ QTabWidget::keyReleaseEvent(e);
+ if (current_shortcut != config::NONE && --n_keys_pressed == 0)
+ {
+ QString shortcut = keys_pressed.join("+");
+
+ config::setting test[] = {
+ config::CAPTURE_FULLSCREEN,
+ config::CAPTURE_CURRENT_WINDOW,
+ config::CAPTURE_AREA,
+ config::UPLOAD_FILE,
+ config::UPLOAD_CLIPBOARD,
+ config::TOGGLE_FUNCTIONALITY
+ };
+
+ QPushButton * button;
+ switch (current_shortcut)
+ {
+ case config::CAPTURE_FULLSCREEN:
+ button = ui->capture_fullscreen_button;
+ break;
+ case config::CAPTURE_CURRENT_WINDOW:
+ button = ui->capture_current_window_button;
+ break;
+ case config::CAPTURE_AREA:
+ button = ui->capture_area_button;
+ break;
+ case config::UPLOAD_FILE:
+ button = ui->upload_file_button;
+ break;
+ case config::UPLOAD_CLIPBOARD:
+ button = ui->upload_clipboard_button;
+ break;
+ case config::TOGGLE_FUNCTIONALITY:
+ button = ui->toggle_functionality_button;
+ break;
+ default:
+ break;
+ }
+
+ bool okay = true;
+ for (int i = 0; i < 6; ++i)
+ {
+ if (config::load(test[i]).toString() == shortcut && button->text() != shortcut)
+ {
+ okay = false;
+ }
+ }
+
+ if (okay)
+ {
+ config::save(current_shortcut, shortcut);
+ button->setText(shortcut);
+ }
+ else
+ {
+ emit error_occurred(QString("The shortcut \"%1\" is already being used!").arg(shortcut));
+ }
+
+ keys_pressed.clear();
+ current_shortcut = config::NONE;
+ emit set_shortcuts_enabled(true, false);
+ }
+}
+
+SET_SHORTCUT(on_capture_fullscreen_button_clicked, CAPTURE_FULLSCREEN)
+SET_SHORTCUT(on_capture_current_window_button_clicked, CAPTURE_CURRENT_WINDOW)
+SET_SHORTCUT(on_capture_area_button_clicked, CAPTURE_AREA)
+SET_SHORTCUT(on_upload_file_button_clicked, UPLOAD_FILE)
+SET_SHORTCUT(on_upload_clipboard_button_clicked, UPLOAD_CLIPBOARD)
+SET_SHORTCUT(on_toggle_functionality_button_clicked, TOGGLE_FUNCTIONALITY)
+
+void configwindow::init_account()
+{
+ ui->username_label->setText(config::load(config::DROPBOX_DISPLAY_NAME, "hmbl9r").toString());
+ ui->used_info_label->setText(config::load(config::DROPBOX_USED, "0%").toString());
+}
+
+void configwindow::update_account_info(QString name, QString used)
+{
+ ui->username_label->setText(name);
+ ui->used_info_label->setText(used);
+}
+
+void configwindow::on_go_to_dropbox_button_clicked()
+{
+ QDesktopServices::openUrl(QUrl("https://www.dropbox.com/home/Public/OpenPuush"));
+}
+
+void configwindow::on_logout_button_clicked()
+{
+ if (!logged_in)
+ {
+ emit login_pressed();
+ }
+ else
+ {
+ emit logout_pressed();
+ }
+
+ logged_in = !logged_in;
+}
+
+void configwindow::set_logged_in(login_state state)
+{
+ ui->logout_button->setEnabled(true);
+ switch (state)
+ {
+ case LOGGED_IN:
+ ui->logout_button->setText("Logout");
+ break;
+ case LOGGED_OUT:
+ ui->logout_button->setText("Login");
+ ui->username_label->setText("Unknown");
+ ui->used_info_label->setText("Unknown");
+ break;
+ }
+}
+
+void configwindow::on_check_for_updates_button_clicked()
+{
+ emit error_occurred("This feature has not yet been implemented.");
+}
View
88 code/OpenPuush/configwindow.hpp
@@ -0,0 +1,88 @@
+#ifndef CONFIGWINDOW_HPP
+#define CONFIGWINDOW_HPP
+
+#include <QTabWidget>
+#include "config.hpp"
+
+namespace Ui {
+ class configwindow;
+}
+
+class QStringList;
+
+class configwindow : public QTabWidget
+{
+ Q_OBJECT
+
+public:
+ enum login_state
+ {
+ LOGGED_IN,
+ LOGGED_OUT
+ };
+
+ explicit configwindow(QWidget *parent = 0);
+ ~configwindow();
+ void update_account_info(QString, QString);
+
+public slots:
+ void set_logged_in(login_state);
+
+private slots:
+ void on_start_on_startup_toggled(bool checked);
+ void on_play_notification_sound_toggled(bool checked);
+ void on_copy_link_to_clipboard_toggled(bool checked);
+ void on_open_link_in_browser_toggled(bool checked);
+ void on_save_a_local_copy_of_image_toggled(bool checked);
+ void on_show_settings_dialog_toggled(bool checked);
+ void on_begin_screen_capture_mode_toggled(bool checked);
+ void on_open_upload_file_dialog_toggled(bool checked);
+ void on_no_compression_toggled(bool checked);
+ void on_smart_compression_toggled(bool checked);
+ void on_show_context_menu_toggled(bool checked);
+ void on_capture_all_screens_toggled(bool checked);
+ void on_capture_primary_screen_toggled(bool checked);
+ void on_capture_screen_with_cursor_toggled(bool checked);
+ void on_enable_experimental_features_toggled(bool checked);
+
+ void on_browse_for_local_path_clicked();
+
+ void on_capture_fullscreen_button_clicked();
+ void on_capture_current_window_button_clicked();
+ void on_capture_area_button_clicked();
+ void on_upload_file_button_clicked();
+ void on_upload_clipboard_button_clicked();
+ void on_toggle_functionality_button_clicked();
+
+ void on_go_to_dropbox_button_clicked();
+
+ void on_logout_button_clicked();
+
+ void on_check_for_updates_button_clicked();
+
+signals:
+ void set_shortcuts_enabled(bool, bool);
+ void toggle_start_on_boot();
+ void error_occurred(QString);
+ void logout_pressed();
+ void login_pressed();
+
+protected:
+ void keyPressEvent(QKeyEvent *);
+ void keyReleaseEvent(QKeyEvent *);
+
+private:
+ Ui::configwindow * ui;
+
+ QString lookup(int);
+
+ void init_settings();
+ void init_account();
+
+ config::setting current_shortcut;
+ short n_keys_pressed;
+ QStringList keys_pressed;
+ bool logged_in;
+};
+
+#endif // CONFIGWINDOW_HPP
View
712 code/OpenPuush/configwindow.ui
@@ -0,0 +1,712 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>configwindow</class>
+ <widget class="QTabWidget" name="configwindow">
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>515</width>
+ <height>320</height>
+ </rect>
+ </property>
+ <property name="minimumSize">
+ <size>
+ <width>515</width>
+ <height>320</height>
+ </size>
+ </property>
+ <property name="maximumSize">
+ <size>
+ <width>515</width>
+ <height>320</height>
+ </size>
+ </property>
+ <property name="windowTitle">
+ <string>TabWidget</string>
+ </property>
+ <property name="currentIndex">
+ <number>4</number>
+ </property>
+ <widget class="QWidget" name="general">
+ <attribute name="title">
+ <string>General</string>
+ </attribute>
+ <widget class="QGroupBox" name="general_settings">
+ <property name="geometry">
+ <rect>
+ <x>10</x>
+ <y>10</y>
+ <width>490</width>
+ <height>51</height>
+ </rect>
+ </property>
+ <property name="styleSheet">
+ <string notr="true"/>
+ </property>
+ <property name="title">
+ <string>General Settings</string>
+ </property>
+ <widget class="QCheckBox" name="start_on_startup">
+ <property name="geometry">
+ <rect>
+ <x>20</x>
+ <y>20</y>
+ <width>211</width>
+ <height>20</height>
+ </rect>
+ </property>
+ <property name="text">
+ <string>Start OpenPuush on startup</string>
+ </property>
+ </widget>
+ </widget>
+ <widget class="QGroupBox" name="on_successful_upload">
+ <property name="geometry">
+ <rect>
+ <x>10</x>
+ <y>70</y>
+ <width>490</width>
+ <height>90</height>
+ </rect>
+ </property>
+ <property name="title">
+ <string>On Successful upload</string>
+ </property>
+ <widget class="QCheckBox" name="play_notification_sound">
+ <property name="geometry">
+ <rect>
+ <x>20</x>
+ <y>20</y>
+ <width>191</width>
+ <height>20</height>
+ </rect>
+ </property>
+ <property name="text">
+ <string>Play a notification sound</string>
+ </property>
+ </widget>
+ <widget class="QCheckBox" name="copy_link_to_clipboard">
+ <property name="geometry">
+ <rect>
+ <x>20</x>
+ <y>40</y>
+ <width>171</width>
+ <height>20</height>
+ </rect>
+ </property>
+ <property name="text">
+ <string>Copy link to clipboard</string>
+ </property>
+ </widget>
+ <widget class="QCheckBox" name="open_link_in_browser">
+ <property name="geometry">
+ <rect>
+ <x>20</x>
+ <y>60</y>
+ <width>161</width>
+ <height>20</height>
+ </rect>
+ </property>
+ <property name="text">
+ <string>Open link in browser</string>
+ </property>
+ </widget>
+ <widget class="QCheckBox" name="save_a_local_copy_of_image">
+ <property name="geometry">
+ <rect>
+ <x>270</x>
+ <y>20</y>
+ <width>221</width>
+ <height>20</height>
+ </rect>
+ </property>
+ <property name="text">
+ <string>Save a local copy of images</string>
+ </property>
+ </widget>
+ <widget class="QLineEdit" name="path_to_local_copy">
+ <property name="enabled">
+ <bool>true</bool>
+ </property>
+ <property name="geometry">
+ <rect>
+ <x>270</x>
+ <y>50</y>
+ <width>161</width>
+ <height>25</height>
+ </rect>
+ </property>
+ <property name="readOnly">
+ <bool>true</bool>
+ </property>
+ </widget>
+ <widget class="QToolButton" name="browse_for_local_path">
+ <property name="geometry">
+ <rect>
+ <x>440</x>
+ <y>50</y>
+ <width>26</width>
+ <height>23</height>
+ </rect>
+ </property>
+ <property name="text">
+ <string>...</string>
+ </property>
+ </widget>
+ </widget>
+ <widget class="QGroupBox" name="tray_icon_behaviour">
+ <property name="geometry">
+ <rect>
+ <x>10</x>
+ <y>169</y>
+ <width>490</width>
+ <height>110</height>
+ </rect>
+ </property>
+ <property name="title">
+ <string>Tray Icon Behaviour</string>
+ </property>
+ <widget class="QLabel" name="on_double_click_label">
+ <property name="geometry">
+ <rect>
+ <x>20</x>
+ <y>20</y>
+ <width>121</width>
+ <height>16</height>
+ </rect>
+ </property>
+ <property name="text">
+ <string>On double-click...</string>
+ </property>
+ </widget>
+ <widget class="QRadioButton" name="show_settings_dialog">
+ <property name="geometry">
+ <rect>
+ <x>40</x>
+ <y>40</y>
+ <width>161</width>
+ <height>20</height>
+ </rect>
+ </property>
+ <property name="text">
+ <string>Show settings dialog</string>
+ </property>
+ </widget>
+ <widget class="QRadioButton" name="begin_screen_capture_mode">
+ <property name="geometry">
+ <rect>
+ <x>40</x>
+ <y>60</y>
+ <width>211</width>
+ <height>20</height>
+ </rect>
+ </property>
+ <property name="text">
+ <string>Begin screen capture mode</string>
+ </property>
+ </widget>
+ <widget class="QRadioButton" name="open_upload_file_dialog">
+ <property name="geometry">
+ <rect>
+ <x>40</x>
+ <y>80</y>
+ <width>181</width>
+ <height>20</height>
+ </rect>
+ </property>
+ <property name="text">
+ <string>Open upload file dialog</string>
+ </property>
+ </widget>
+ </widget>
+ </widget>
+ <widget class="QWidget" name="key_bindings">
+ <attribute name="title">
+ <string>Key Bindings</string>
+ </attribute>
+ <widget class="QGroupBox" name="keyboard_bindings">
+ <property name="geometry">
+ <rect>
+ <x>8</x>
+ <y>9</y>
+ <width>491</width>
+ <height>270</height>
+ </rect>
+ </property>
+ <property name="title">
+ <string>Keyboard Bindings</string>
+ </property>
+ <widget class="QPushButton" name="capture_fullscreen_button">
+ <property name="geometry">
+ <rect>
+ <x>240</x>
+ <y>30</y>
+ <width>161</width>
+ <height>27</height>
+ </rect>
+ </property>
+ <property name="text">
+ <string>Ctrl+Shift+3</string>
+ </property>
+ </widget>
+ <widget class="QPushButton" name="capture_current_window_button">
+ <property name="geometry">
+ <rect>
+ <x>240</x>
+ <y>60</y>
+ <width>161</width>
+ <height>27</height>
+ </rect>
+ </property>
+ <property name="text">
+ <string>Ctrl+Shift+2</string>
+ </property>
+ </widget>
+ <widget class="QPushButton" name="capture_area_button">
+ <property name="geometry">
+ <rect>
+ <x>240</x>
+ <y>90</y>
+ <width>161</width>
+ <height>27</height>
+ </rect>
+ </property>
+ <property name="text">
+ <string>Ctrl+Shift+4</string>
+ </property>
+ </widget>
+ <widget class="QPushButton" name="upload_file_button">
+ <property name="geometry">
+ <rect>
+ <x>240</x>
+ <y>120</y>
+ <width>161</width>
+ <height>27</height>
+ </rect>
+ </property>
+ <property name="text">
+ <string>Ctrl+Shift+U</string>
+ </property>
+ </widget>
+ <widget class="QPushButton" name="upload_clipboard_button">
+ <property name="geometry">
+ <rect>
+ <x>240</x>
+ <y>200</y>
+ <width>161</width>
+ <height>27</height>
+ </rect>
+ </property>
+ <property name="text">
+ <string>Ctrl+Shift+5</string>
+ </property>
+ </widget>
+ <widget class="QPushButton" name="toggle_functionality_button">
+ <property name="geometry">
+ <rect>
+ <x>240</x>
+ <y>230</y>
+ <width>161</width>
+ <height>27</height>
+ </rect>
+ </property>
+ <property name="text">
+ <string>Ctrl+Alt+P</string>
+ </property>
+ </widget>
+ <widget class="QLabel" name="capture_fullscreen_label">
+ <property name="geometry">
+ <rect>
+ <x>90</x>
+ <y>31</y>
+ <width>141</width>
+ <height>20</height>
+ </rect>
+ </property>
+ <property name="text">
+ <string>Capture full screen:</string>
+ </property>
+ <property name="alignment">
+ <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
+ </property>
+ </widget>
+ <widget class="QLabel" name="capture_current_window_label">
+ <property name="geometry">
+ <rect>
+ <x>30</x>
+ <y>60</y>
+ <width>201</width>
+ <height>20</height>
+ </rect>
+ </property>
+ <property name="text">
+ <string>Capture current window:</string>
+ </property>
+ <property name="alignment">
+ <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
+ </property>
+ </widget>
+ <widget class="QLabel" name="capture_area_label">
+ <property name="geometry">
+ <rect>
+ <x>80</x>
+ <y>90</y>
+ <width>151</width>
+ <height>20</height>
+ </rect>
+ </property>
+ <property name="text">
+ <string>Capture area:</string>
+ </property>
+ <property name="alignment">
+ <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
+ </property>
+ </widget>
+ <widget class="QLabel" name="upload_file_label">
+ <property name="geometry">
+ <rect>
+ <x>130</x>
+ <y>120</y>
+ <width>101</width>
+ <height>20</height>
+ </rect>
+ </property>
+ <property name="text">
+ <string>Upload file:</string>
+ </property>
+ <property name="alignment">
+ <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
+ </property>
+ </widget>
+ <widget class="QLabel" name="use_shortcut_tip_label">
+ <property name="geometry">
+ <rect>
+ <x>50</x>
+ <y>160</y>
+ <width>351</width>
+ <height>31</height>
+ </rect>
+ </property>
+ <property name="text">
+ <string>Use this shortcut in Windows Explorer to quickly upload selected files.</string>
+ </property>
+ <property name="wordWrap">
+ <bool>true</bool>
+ </property>
+ <property name="openExternalLinks">
+ <bool>false</bool>
+ </property>
+ </widget>
+ <widget class="QLabel" name="upload_clipboard_label">
+ <property name="geometry">
+ <rect>
+ <x>100</x>
+ <y>200</y>
+ <width>131</width>
+ <height>20</height>
+ </rect>
+ </property>
+ <property name="text">
+ <string>Upload clipboard:</string>
+ </property>
+ <property name="alignment">
+ <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
+ </property>
+ </widget>
+ <widget class="QLabel" name="toggle_functionality_label">
+ <property name="geometry">
+ <rect>
+ <x>10</x>
+ <y>230</y>
+ <width>221</width>
+ <height>20</height>
+ </rect>
+ </property>
+ <property name="text">
+ <string>Toggle OpenPuush functionality:</string>
+ </property>
+ <property name="alignment">
+ <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
+ </property>
+ </widget>
+ </widget>
+ </widget>
+ <widget class="QWidget" name="account">
+ <attribute name="title">
+ <string>Account</string>
+ </attribute>
+ <widget class="QGroupBox" name="account_details">
+ <property name="geometry">
+ <rect>
+ <x>10</x>
+ <y>10</y>
+ <width>491</width>
+ <height>271</height>
+ </rect>
+ </property>
+ <property name="title">
+ <string>Account Details</string>
+ </property>
+ <widget class="QWidget" name="gridLayoutWidget">
+ <property name="geometry">
+ <rect>
+ <x>60</x>
+ <y>60</y>
+ <width>361</width>
+ <height>92</height>
+ </rect>
+ </property>
+ <layout class="QGridLayout" name="gridLayout">
+ <item row="1" column="0">
+ <widget class="QLabel" name="used_label">
+ <property name="text">
+ <string>Used:</string>
+ </property>
+ <property name="alignment">
+ <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
+ </property>
+ </widget>
+ </item>
+ <item row="0" column="0">
+ <widget class="QLabel" name="logged_in_as_label">
+ <property name="text">
+ <string>Logged in as:</string>
+ </property>
+ <property name="alignment">
+ <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
+ </property>
+ </widget>
+ </item>
+ <item row="0" column="1">
+ <widget class="QLabel" name="username_label">
+ <property name="text">
+ <string>hmbl9r@gmail.com</string>
+ </property>
+ </widget>
+ </item>
+ <item row="2" column="0">
+ <widget class="QPushButton" name="go_to_dropbox_button">
+ <property name="text">
+ <string>Go to Dropbox</string>
+ </property>
+ </widget>
+ </item>
+ <item row="2" column="1">
+ <widget class="QPushButton" name="logout_button">
+ <property name="text">
+ <string>Logout</string>
+ </property>
+ </widget>
+ </item>
+ <item row="1" column="1">
+ <widget class="QLabel" name="used_info_label">
+ <property name="text">
+ <string>10%</string>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </widget>
+ </widget>
+ </widget>
+ <widget class="QWidget" name="updates">
+ <attribute name="title">
+ <string>Updates</string>
+ </attribute>
+ <widget class="QGroupBox" name="update_management">
+ <property name="geometry">
+ <rect>
+ <x>9</x>
+ <y>9</y>
+ <width>491</width>
+ <height>271</height>
+ </rect>
+ </property>
+ <property name="title">
+ <string>Update Management</string>
+ </property>
+ <widget class="QWidget" name="horizontalLayoutWidget">
+ <property name="geometry">
+ <rect>
+ <x>30</x>
+ <y>40</y>
+ <width>421</width>
+ <height>51</height>
+ </rect>
+ </property>
+ <layout class="QHBoxLayout" name="update_management_layout">
+ <item>
+ <widget class="QLabel" name="last_checked_date">
+ <property name="text">
+ <string>Last checked:</string>
+ </property>
+ <property name="alignment">
+ <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QLabel" name="last_checked_label">
+ <property name="text">
+ <string>8/13/2012 5:06:48 PM</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QPushButton" name="check_for_updates_button">
+ <property name="text">
+ <string>Check for updates</string>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </widget>
+ </widget>
+ </widget>
+ <widget class="QWidget" name="advanced">
+ <attribute name="title">
+ <string>Advanced</string>
+ </attribute>
+ <widget class="QGroupBox" name="screen_capture_quality">
+ <property name="geometry">
+ <rect>
+ <x>9</x>
+ <y>9</y>
+ <width>491</width>
+ <height>81</height>
+ </rect>
+ </property>
+ <property name="title">
+ <string>Screen Capture Quality</string>
+ </property>
+ <widget class="QWidget" name="verticalLayoutWidget">
+ <property name="geometry">
+ <rect>
+ <x>10</x>
+ <y>30</y>
+ <width>481</width>
+ <height>48</height>
+ </rect>
+ </property>
+ <layout class="QVBoxLayout" name="screen_capture_quality_layout">
+ <item>
+ <widget class="QRadioButton" name="no_compression">
+ <property name="text">
+ <string>Always use png</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QRadioButton" name="smart_compression">
+ <property name="text">
+ <string>Smart (use JPEG unless PNG is smaller in filesize)</string>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </widget>
+ </widget>
+ <widget class="QGroupBox" name="context_menu">
+ <property name="geometry">
+ <rect>
+ <x>10</x>
+ <y>90</y>
+ <width>491</width>
+ <height>41</height>
+ </rect>
+ </property>
+ <property name="title">
+ <string>Context Menu</string>
+ </property>
+ <widget class="QCheckBox" name="show_context_menu">
+ <property name="geometry">
+ <rect>
+ <x>10</x>
+ <y>20</y>
+ <width>481</width>
+ <height>21</height>
+ </rect>
+ </property>
+ <property name="text">
+ <string>Show explorer context menu item</string>
+ </property>
+ </widget>
+ </widget>
+ <widget class="QGroupBox" name="fullscreen_capture">
+ <property name="geometry">
+ <rect>
+ <x>10</x>
+ <y>140</y>
+ <width>491</width>
+ <height>101</height>
+ </rect>
+ </property>
+ <property name="title">
+ <string>Fullscreen Capture</string>
+ </property>
+ <widget class="QWidget" name="verticalLayoutWidget_2">
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>20</y>
+ <width>481</width>
+ <height>74</height>
+ </rect>
+ </property>
+ <layout class="QVBoxLayout" name="fullscreen_capture_layout">
+ <item>
+ <widget class="QRadioButton" name="capture_all_screens">
+ <property name="text">
+ <string>Capture all screens</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QRadioButton" name="capture_primary_screen">
+ <property name="text">
+ <string>Capture screen containing mouse cursor</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QRadioButton" name="capture_screen_with_cursor">
+ <property name="text">
+ <string>Always capture primary screen</string>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </widget>
+ </widget>
+ <widget class="QGroupBox" name="dangerous_stuff">
+ <property name="geometry">
+ <rect>
+ <x>10</x>
+ <y>240</y>
+ <width>491</width>
+ <height>41</height>
+ </rect>
+ </property>
+ <property name="title">
+ <string>Dangerous Stuff</string>
+ </property>
+ <widget class="QCheckBox" name="enable_experimental_features">
+ <property name="geometry">
+ <rect>
+ <x>11</x>
+ <y>19</y>
+ <width>217</width>
+ <height>20</height>
+ </rect>
+ </property>
+ <property name="text">
+ <string>Enable experimental features</string>
+ </property>
+ </widget>
+ </widget>
+ </widget>
+ </widget>
+ <resources/>
+ <connections/>
+</ui>
View
373 code/OpenPuush/dropbox.cpp
@@ -0,0 +1,373 @@
+#include <QString>
+#include <QUrl>
+#include <QCryptographicHash>
+#include <QByteArray>
+#include <QDateTime>
+#include <QNetworkRequest>
+#include <QNetworkAccessManager>
+#include <QNetworkReply>
+#include <QDesktopServices>
+#include <QRegExp>
+#include <QStringList>
+#include <QTcpServer>
+#include <QTcpSocket>
+#include <QApplication>
+#include <QClipboard>
+#include <QFile>
+#include <QFileInfo>
+
+#include <QxtCore/QxtJSON>
+
+#include "dropbox.hpp"
+#include "config.hpp"
+
+dropbox::dropbox(QObject *) : app_key("nwy4ujlf00t1cjt"),
+ app_secret("fm4qw5sjgoqqmg5"),
+ base_url("https://api.dropbox.com/1"),
+ conf_location("./openpuush.conf")
+{
+ manager = new QNetworkAccessManager(this);
+ server = new QTcpServer(this);
+
+ connect(server, SIGNAL(newConnection()), this, SLOT(http_connection()));
+ connect(manager, SIGNAL(finished(QNetworkReply *)), this, SLOT(network_reply(QNetworkReply *)));
+
+ current_action = OTHER;
+}
+
+dropbox::~dropbox()
+{
+ delete manager;
+ delete server;
+}
+
+void dropbox::check_authentication()
+{
+ if (!load_config())
+ {
+ authenticate();
+ }
+ else
+ {
+ emit got_authorized();
+ }
+}
+
+void dropbox::logout()
+{
+ config::save(config::DROPBOX_OAUTH_ACCESS_TOKEN_SECRET, "");
+ config::save(config::DROPBOX_OAUTH_ACCESS_TOKEN, "");
+ config::save(config::DROPBOX_UID, "");
+ config::save(config::DROPBOX_DISPLAY_NAME, "");
+ config::save(config::DROPBOX_USED, "");
+
+ oauth_access_token = "";
+ oauth_access_token_secret = "";
+ oauth_token_secret = "";
+ uid = "";
+}
+
+void dropbox::network_reply(QNetworkReply * reply)
+{
+ QString raw = QString(reply->readAll());
+ QStringList params = raw.split(QString("&"));
+ switch (current_action)
+ {
+ case REQUEST_TOKEN:
+ {
+ try
+ {
+ oauth_token_secret = params[0].split("=")[1];
+ QString oauth_token = params[1].split("=")[1];
+
+ QString url = "https://www.dropbox.com/1/oauth/authorize?oauth_token=" +
+ oauth_token + "&oauth_callback=http://127.0.0.1:8080";
+
+ QDesktopServices::openUrl(url);
+
+ reply->deleteLater();
+
+ if (!server->listen(QHostAddress::LocalHost, 8080))
+ {
+ emit error_occurred("Could not start local server");
+ }
+ }
+ catch (...)
+ {
+ emit error_occurred("Unable to parse request token parameters.");
+ }
+
+ break;
+ }
+ case ACCESS_TOKEN:
+ {
+ try
+ {
+ oauth_access_token_secret = params[0].split("=")[1];
+ oauth_access_token = params[1].split("=")[1];
+ uid = params[2].split("=")[1];
+ emit got_authorized();
+
+ save_config();
+ }
+ catch (...)
+ {
+ emit error_occurred("Unable to parse access token parameters.");
+ }
+
+ break;
+ }
+ case ACCOUNT_INFO:
+ {
+ try
+ {
+ QMap<QString, QVariant> json = QxtJSON::parse(raw).toMap();
+ QMap<QString, QVariant> quota_info = json.value("quota_info").toMap();
+ QMap<QString, QString> info;
+
+ double percent_used = quota_info.value("normal").toDouble() /
+ quota_info.value("quota").toDouble();
+ percent_used *= 100;
+
+ QString used = QString("%1%").arg(percent_used, 0, 'f', 1);
+ QString display_name = json.value("display_name").toString();
+
+ info.insert("display_name", display_name);
+ info.insert("used", used);
+
+ config::save(config::DROPBOX_DISPLAY_NAME, display_name);
+ config::save(config::DROPBOX_USED, used);
+
+ emit got_account_info(info);
+ }
+ catch (...)
+ {
+ emit error_occurred("Unable to parse account info.");
+ }
+
+ break;
+ }
+ case FILES_PUT:
+ {
+ break;
+ }
+ case FILEOPS_CREATE_FOLDER:
+ {
+ break;
+ }
+ default:
+ break;
+ }
+ current_action = OTHER;
+}
+
+void dropbox::account_info()
+{
+ QNetworkRequest request(QUrl(base_url + "/account/info"));
+ QByteArray authorization = oauth_authorization_header(base_url + "/account/info",
+ app_key,
+ oauth_access_token,
+ "PLAINTEXT",
+ encode(app_secret) + "&" + encode(oauth_access_token_secret));
+ request.setRawHeader(QByteArray("Authorization"), authorization);
+
+ current_action = ACCOUNT_INFO;
+ manager->get(request);
+}
+
+void dropbox::file_put(const QString & path)
+{
+ QFile file(path);
+ QFileInfo info(file);
+ file.open(QIODevice::ReadOnly);
+ QDataStream data(&file);
+ QString filename(info.fileName());
+ file_put(data, filename);
+}
+
+void dropbox::file_put(QDataStream & data, QString & filename)
+{
+ QUrl url(QString("https://api-content.dropbox.com/1/files_put/dropbox/Public/OpenPuush/%1")
+ .arg(filename));
+ QNetworkRequest request(url);
+ QByteArray authorization = oauth_authorization_header(url.toString(),
+ app_key,
+ oauth_access_token,
+ "PLAINTEXT",
+ encode(app_secret) + "&" + encode(oauth_access_token_secret));
+ request.setRawHeader(QByteArray("Authorization"), authorization);
+
+ current_action = FILES_PUT;
+ reply = manager->put(request, data.device());
+ reply_sent_common(QString("http://dl.dropbox.com/u/%1/OpenPuush/%2").arg(uid, encode(filename)));
+}
+
+void dropbox::file_put(QByteArray & data, QString & filename)
+{
+ QUrl url(QString("https://api-content.dropbox.com/1/files_put/dropbox/Public/OpenPuush/%1")
+ .arg(filename));
+ QNetworkRequest request(url);
+ QByteArray authorization = oauth_authorization_header(url.toString(),
+ app_key,
+ oauth_access_token,
+ "PLAINTEXT",
+ encode(app_secret) + "&" + encode(oauth_access_token_secret));
+ request.setRawHeader(QByteArray("Authorization"), authorization);
+
+ current_action = FILES_PUT;
+ reply = manager->put(request, data);
+ reply_sent_common(QString("http://dl.dropbox.com/u/%1/OpenPuush/%2").arg(uid, encode(filename)));
+}
+
+void dropbox::reply_sent_common(const QString & link)
+{
+ connect(reply, SIGNAL(uploadProgress(qint64, qint64)), this, SLOT(file_upload_progress_slot(qint64,qint64)));
+ connect(reply, SIGNAL(finished()), this, SLOT(file_upload_finished_slot()));
+ connect(reply, SIGNAL(error(QNetworkReply::NetworkError)), this, SLOT(file_upload_error()));
+
+ emit link_ready(link);
+}
+
+void dropbox::http_connection()
+{
+ client = server->nextPendingConnection();
+ connect(client, SIGNAL(disconnected()), client, SLOT(deleteLater()));
+
+ QByteArray block;
+ QDataStream out(&block, QIODevice::ReadWrite);
+ out.setVersion(QDataStream::Qt_4_8);
+
+ QString raw_request;
+ if (client->waitForReadyRead(1000))
+ {
+ raw_request = QString(client->readAll());
+ }
+
+ QStringList params = raw_request.mid(6, raw_request.indexOf(" HTTP") - 6).split("&");
+ QString uid = params[0].split("=")[1];
+ QString oauth_token = params[1].split("=")[1];
+
+ out << "HTTP/1.1 200 OK\r\nContent-type: text/html\r\n\r\n"
+ "<!doctype html>"
+ "<html>"
+ "<head>"
+ "<title>Authorized OpenPush</title>"
+ "</head>"
+ "<body>"
+ "<h1>Authorized Openpush!</h1>"
+ "<h3>You may close this window whenever you feel like it."
+ "</body>"
+ "</html>";
+
+ client->write(block);
+ client->close();
+ server->close();
+
+ QNetworkRequest request(QUrl(base_url + "/oauth/access_token"));
+ QByteArray authorization = oauth_authorization_header(base_url + "/account/info",
+ app_key,
+ oauth_token,
+ "PLAINTEXT",
+ encode(app_secret) + "&" + encode(oauth_token_secret));
+ request.setRawHeader(QByteArray("Authorization"), authorization);
+
+ current_action = ACCESS_TOKEN;
+ manager->get(request);
+}
+
+QByteArray dropbox::oauth_authorization_header(const QString & realm,
+ const QString & oauth_consumer_key,
+ const QString & oauth_token,
+ const QString & oauth_signature_method,
+ const QString & oauth_signature)
+{
+ QByteArray val;
+ val.append(QString("OAuth realm=\"%1\","
+ "oauth_consumer_key=\"%2\","
+ "oauth_token=\"%3\","
+ "oauth_nonce=\"%4\","
+ "oauth_timestamp=\"%5\","
+ "oauth_signature_method=\"%6\","
+ "oauth_version=\"%7\","
+ "oauth_signature=\"%8\"")
+ .arg(realm,
+ oauth_consumer_key,
+ oauth_token,
+ encode(nonce()),
+ timestamp(),
+ oauth_signature_method,
+ "1.0",
+ encode(oauth_signature)));
+ return val;
+}
+
+void dropbox::authenticate()
+{
+ QString signature = encode(app_secret) + "&";
+
+ QUrl url;
+ url.setUrl(base_url + "/oauth/request_token");
+ url.addQueryItem("oauth_consumer_key", app_key);
+ url.addQueryItem("oauth_nonce", encode(nonce()));
+ url.addQueryItem("oauth_signature", encode(signature));
+ url.addQueryItem("oauth_signature_method", "PLAINTEXT");
+ url.addQueryItem("oauth_timestamp", encode(timestamp()));
+ url.addQueryItem("oauth_version", "1.0");
+
+ current_action = REQUEST_TOKEN;
+ manager->post(QNetworkRequest(url), QByteArray());
+}
+
+QString dropbox::timestamp()
+{
+ return QString("%1").arg(QDateTime::currentDateTime().toTime_t());
+}
+
+QString dropbox::nonce()
+{
+ QByteArray b;
+ b.append(timestamp());
+ return QString(QCryptographicHash::hash(b, QCryptographicHash::Sha1).toHex());
+}
+
+QString dropbox::encode(const QString & str)
+{
+ return QString(QUrl::toPercentEncoding(str));
+}
+
+bool dropbox::load_config()
+{
+ oauth_access_token_secret = config::load(config::DROPBOX_OAUTH_ACCESS_TOKEN_SECRET).toString();
+ oauth_access_token = config::load(config::DROPBOX_OAUTH_ACCESS_TOKEN).toString();
+ uid = config::load(config::DROPBOX_UID).toString();
+
+ bool success = true;
+ if (oauth_access_token_secret == "" || oauth_access_token == "" || uid == "")
+ {
+ success = false;
+ }
+
+ return success;
+}
+
+void dropbox::save_config()
+{
+ config::save(config::DROPBOX_OAUTH_ACCESS_TOKEN_SECRET, oauth_access_token_secret);
+ config::save(config::DROPBOX_OAUTH_ACCESS_TOKEN, oauth_access_token);
+ config::save(config::DROPBOX_UID, uid);
+}
+
+void dropbox::file_upload_progress_slot(qint64 sent, qint64 total)
+{
+ emit upload_progress(sent, total);
+}
+
+void dropbox::file_upload_finished_slot()
+{
+ emit upload_finished();
+}
+
+void dropbox::file_upload_error()
+{
+ emit upload_error();
+}
View
105 code/OpenPuush/dropbox.hpp
@@ -0,0 +1,105 @@
+#ifndef DROPBOX_HPP
+#define DROPBOX_HPP
+
+#include <QObject>
+#include <QMap>
+
+class QString;
+class QNetworkReply;
+class QNetworkAccessManager;
+class QTcpServer;
+class QTcpSocket;
+class QFile;
+class QNetworkReply;
+
+class dropbox : public QObject
+{
+ Q_OBJECT
+
+public:
+ explicit dropbox(QObject * parent = 0);
+ ~dropbox();
+
+ void file_put(const QString &);
+ void file_put(QDataStream &, QString &);
+ void file_put(QByteArray &, QString &);
+
+public slots:
+ void check_authentication();
+ void logout();
+
+private slots:
+ void network_reply(QNetworkReply *);
+ void http_connection();
+ void file_upload_progress_slot(qint64, qint64);
+ void file_upload_finished_slot();
+ void file_upload_error();
+ void account_info();
+
+signals:
+ void got_authorized();
+ void got_account_info(QMap<QString, QString>);
+ void upload_progress(qint64, qint64);
+ void upload_finished();
+ void upload_error();
+ void link_ready(QString);
+ void error_occurred(QString);
+
+private:
+ enum action
+ {
+ REQUEST_TOKEN,
+ ACCESS_TOKEN,
+ ACCOUNT_INFO,
+ FILES_GET,
+ FILES_PUT,
+ FILES_POST,
+ METADATA,
+ DELTA,
+ REVISIONS,
+ RESTORE,
+ SEARCH,
+ SHARES,
+ MEDIA,
+ COPY_REF,
+ THUMBNAILS,
+ FILEOPS_COPY,
+ FILEOPS_CREATE_FOLDER,
+ FILEOPS_DELETE,
+ FILEOPS_MOVE,
+ OTHER
+ };
+
+ const QString app_key;
+ const QString app_secret;
+ const QString base_url;
+ const QString conf_location;
+
+ QString oauth_token_secret;
+ QString oauth_access_token_secret;
+ QString oauth_access_token;
+ QString uid;
+
+ action current_action;
+
+ QNetworkAccessManager * manager;
+ QNetworkReply * reply;
+ QTcpServer * server;
+ QTcpSocket * client;
+
+ void authenticate();
+ void save_config();
+ bool load_config();
+ void reply_sent_common(const QString &);
+
+ QString timestamp();
+ QString nonce();
+ QString encode(const QString &);
+ QByteArray oauth_authorization_header(const QString &,
+ const QString &,
+ const QString &,
+ const QString &,
+ const QString &);
+};
+
+#endif // DROPBOX_HPP
View
16 code/OpenPuush/main.cpp
@@ -0,0 +1,16 @@
+#include <QApplication>
+
+#include "openpuush.hpp"
+#include "dropbox.hpp"
+
+int main(int argc, char *argv[])
+{
+ QApplication a(argc, argv);
+
+ a.setApplicationName("OpenPuush");
+
+ openpuush m;
+ (void)(m);
+
+ return a.exec();
+}
View
509 code/OpenPuush/openpuush.cpp
@@ -0,0 +1,509 @@
+#include <QPainter>
+#include <QPaintEvent>
+#include <QPushButton>
+#include <QDebug>
+#include <QDataStream>
+#include <QBuffer>
+#include <QDateTime>
+#include <QClipboard>
+#include <QApplication>
+#include <QDesktopWidget>
+#include <QFileDialog>
+#include <QTimer>
+#include <QAction>
+#include <QDir>
+#include <QTemporaryFile>
+#include <QUrl>
+#include <QDesktopServices>
+
+#include <phonon/AudioOutput>
+#include <phonon/MediaObject>
+#include <phonon/MediaSource>
+#include <phonon/VideoWidget>
+
+#include <QxtGlobalShortcut>
+
+#include "dropbox.hpp"
+#include "openpuush.hpp"
+#include "screenshot_overlay.hpp"
+#include "config.hpp"
+#include "configwindow.hpp"
+#include "tray_menu.hpp"
+
+#define set_shortcut(s,e) s->setShortcut(QKeySequence(config::load(config::e).toString()))
+
+static const QString NOT_AUTHORIZED_MESSAGE = "Your action could not be completed because\n"
+ "OpenPuush is not linked with a Dropbox account.";
+
+openpuush::openpuush(QObject *parent) :
+ QObject(parent),
+ base_path(QDir::currentPath()),
+ dropbox_authenticated(false),
+ shortcuts_enabled(true),
+ follow_tray_icon_link(false)
+{
+ QApplication::setQuitOnLastWindowClosed(false);
+
+ if (config::first_run())
+ {
+ config::defaults();
+ }
+
+ load_start_on_boot();
+
+ // order is important here!
+ init_dropbox();
+ init_ss_overlay();
+ init_file_dialog();
+ init_shortcuts();
+ init_conf_win();
+ init_tray_icon();
+ init_tray_icon_context_menu();
+}
+
+openpuush::~openpuush()
+{
+ delete db;
+ delete conf_win;
+ delete ss_overlay;
+ delete menu;
+ delete tray_icon;
+ delete file_dialog;
+ delete info_update_timer;
+ delete fullscreen_shortcut;
+ delete current_window_shortcut;
+ delete ss_overlay_shortcut;
+ delete file_shortcut;
+ delete upload_clipboard_shortcut;
+ delete toggle_functionality_shortcut;
+}
+
+void openpuush::init_conf_win()
+{
+ conf_win = new configwindow();
+ connect(conf_win, SIGNAL(set_shortcuts_enabled(bool,bool)),
+ this, SLOT(set_shortcuts_enabled(bool,bool)));
+ connect(conf_win, SIGNAL(error_occurred(QString)), this, SLOT(error_occurred(QString)));
+ connect(conf_win, SIGNAL(toggle_start_on_boot()), this, SLOT(load_start_on_boot()));
+ connect(conf_win, SIGNAL(login_pressed()), this, SLOT(db_login()));
+ connect(conf_win, SIGNAL(logout_pressed()), this, SLOT(db_logout()));
+}
+
+void openpuush::init_ss_overlay()
+{
+ ss_overlay = new screenshot_overlay();
+ connect(ss_overlay, SIGNAL(got_screenshot(QPixmap)), this, SLOT(got_screenshot(QPixmap)));
+}
+
+void openpuush::init_file_dialog()
+{
+ file_dialog = new QFileDialog();
+ file_dialog->setFileMode(QFileDialog::AnyFile);
+
+ connect(file_dialog, SIGNAL(fileSelected(QString)), this, SLOT(upload_file(QString)));
+}
+
+void openpuush::init_dropbox()
+{
+ db = new dropbox();
+
+ connect(db, SIGNAL(got_authorized()), this, SLOT(db_authorized()));
+ connect(db, SIGNAL(upload_progress(qint64, qint64)),
+ this, SLOT(db_upload_progress(qint64,qint64)));
+ connect(db, SIGNAL(upload_finished()), this, SLOT(db_upload_finished()));
+ connect(db, SIGNAL(link_ready(QString)), this, SLOT(db_link_ready(QString)));
+ connect(db, SIGNAL(got_account_info(QMap<QString,QString>)),
+ this, SLOT(db_info_received(QMap<QString,QString>)));
+
+ info_update_timer = new QTimer();
+
+ connect(info_update_timer, SIGNAL(timeout()), this, SLOT(update_db_info()));
+
+ QTimer::singleShot(0, db, SLOT(check_authentication()));
+}
+
+void openpuush::init_tray_icon()
+{
+ tray_icon = new QSystemTrayIcon(this);
+ tray_icon->setIcon(QIcon(base_path + "/icons/0.png"));
+ tray_icon->show();
+
+ connect(tray_icon, SIGNAL(activated(QSystemTrayIcon::ActivationReason)),
+ this, SLOT(tray_icon_activated(QSystemTrayIcon::ActivationReason)));
+ connect(tray_icon, SIGNAL(messageClicked()), this, SLOT(follow_link()));
+}
+
+void openpuush::init_shortcuts()
+{
+ fullscreen_shortcut = new QxtGlobalShortcut(this);
+ connect(fullscreen_shortcut, SIGNAL(activated()), this, SLOT(fullscreen_ss()));
+
+ current_window_shortcut = new QxtGlobalShortcut(this);
+ connect(current_window_shortcut, SIGNAL(activated()), this, SLOT(upload_current_window()));
+
+ ss_overlay_shortcut = new QxtGlobalShortcut(this);
+ connect(ss_overlay_shortcut, SIGNAL(activated()), this, SLOT(show_ss_overlay()));
+
+ file_shortcut = new QxtGlobalShortcut(this);
+ connect(file_shortcut, SIGNAL(activated()), file_dialog, SLOT(show()));
+
+ upload_clipboard_shortcut = new QxtGlobalShortcut(this);
+ connect(upload_clipboard_shortcut, SIGNAL(activated()), this, SLOT(upload_clipboard()));
+
+ toggle_functionality_shortcut = new QxtGlobalShortcut(this);
+ connect(toggle_functionality_shortcut, SIGNAL(activated()), this, SLOT(toggle_functionality()));
+
+ update_shortcuts();
+}
+
+void openpuush::init_tray_icon_context_menu()
+{
+ menu = new tray_menu();
+}
+
+void openpuush::update_shortcuts()
+{
+ set_shortcut(fullscreen_shortcut, CAPTURE_FULLSCREEN);
+ set_shortcut(current_window_shortcut, CAPTURE_CURRENT_WINDOW);
+ set_shortcut(ss_overlay_shortcut, CAPTURE_AREA);
+ set_shortcut(file_shortcut, UPLOAD_FILE);
+ set_shortcut(upload_clipboard_shortcut, UPLOAD_CLIPBOARD);
+ set_shortcut(toggle_functionality_shortcut, TOGGLE_FUNCTIONALITY);
+}
+
+void openpuush::update_db_info()
+{
+ QTimer::singleShot(0, db, SLOT(account_info()));
+}
+
+void openpuush::db_authorized()
+{
+ dropbox_authenticated = true;
+ QTimer::singleShot(200, db, SLOT(account_info()));
+ info_update_timer->start(1000 * 60 * 5);
+ conf_win->set_logged_in(configwindow::LOGGED_IN);
+}
+
+void openpuush::db_upload_progress(qint64 sent, qint64 total)
+{
+ int img_num = (sent * 10) / total;
+
+ tray_icon->setIcon(QIcon(base_path + QString("/icons/%1.png").arg(img_num)));
+
+ qDebug() << ((sent * 100) / total) << "%";
+}
+
+void openpuush::db_upload_finished()
+{
+ tray_icon->setIcon(QIcon(base_path + "/icons/success.png"));
+ QTimer::singleShot(2000, this, SLOT(tray_icon_normal()));
+ tray_icon->showMessage("Success", link, QSystemTrayIcon::NoIcon, 2000);
+ follow_tray_icon_link = true;
+
+ if (config::load(config::SOUND_NOTIFICATION).toBool())
+ {
+ /*Phonon::createPlayer(Phonon::VideoCategory,
+ Phonon::MediaSource(base_path + "/sounds/fin.ogg"))->play();*/
+ }
+
+ if (config::load(config::COPY_LINK).toBool())
+ {
+ QApplication::clipboard()->setText(link);
+ }
+
+ if (config::load(config::OPEN_LINK).toBool())
+ {
+ QDesktopServices::openUrl(link);
+ }
+}
+
+void openpuush::db_upload_error()
+{
+ tray_icon->setIcon(QIcon(base_path + "/icons/error.png"));
+ QTimer::singleShot(2000, this, SLOT(tray_icon_normal()));
+ tray_icon->showMessage("Error", "The current action failed.");
+ /*Phonon::createPlayer(Phonon::VideoCategory,