summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--plugins/DropBox/DropBox_11.vcxproj209
-rw-r--r--plugins/DropBox/DropBox_11.vcxproj.filters44
-rw-r--r--plugins/DropBox/res/resource.hbin0 -> 1176 bytes
-rw-r--r--plugins/DropBox/res/resource.rcbin0 -> 6916 bytes
-rw-r--r--plugins/DropBox/src/common.h31
-rw-r--r--plugins/DropBox/src/dropBox_proto.cpp383
-rw-r--r--plugins/DropBox/src/dropBox_proto.h43
-rw-r--r--plugins/DropBox/src/http_request.h87
-rw-r--r--plugins/DropBox/src/main.cpp63
-rw-r--r--plugins/DropBox/src/resource.hbin0 -> 1180 bytes
-rw-r--r--plugins/DropBox/src/version.h15
11 files changed, 875 insertions, 0 deletions
diff --git a/plugins/DropBox/DropBox_11.vcxproj b/plugins/DropBox/DropBox_11.vcxproj
new file mode 100644
index 0000000000..e0ae749cf7
--- /dev/null
+++ b/plugins/DropBox/DropBox_11.vcxproj
@@ -0,0 +1,209 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <ItemGroup Label="ProjectConfigurations">
+ <ProjectConfiguration Include="Debug|Win32">
+ <Configuration>Debug</Configuration>
+ <Platform>Win32</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Debug|x64">
+ <Configuration>Debug</Configuration>
+ <Platform>x64</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Release|Win32">
+ <Configuration>Release</Configuration>
+ <Platform>Win32</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Release|x64">
+ <Configuration>Release</Configuration>
+ <Platform>x64</Platform>
+ </ProjectConfiguration>
+ </ItemGroup>
+ <ItemGroup>
+ <ClInclude Include="res\resource.h" />
+ <ClInclude Include="src\common.h" />
+ <ClInclude Include="src\dropBox_proto.h" />
+ <ClInclude Include="src\http_request.h" />
+ <ClInclude Include="src\version.h" />
+ </ItemGroup>
+ <ItemGroup>
+ <ClCompile Include="src\main.cpp" />
+ <ClCompile Include="src\dropBox_proto.cpp" />
+ </ItemGroup>
+ <ItemGroup>
+ <ResourceCompile Include="res\Resource.rc" />
+ </ItemGroup>
+ <PropertyGroup Label="Globals">
+ <ProjectGuid>{CBA58126-3E02-4159-9BD3-059AF9DBC84E}</ProjectGuid>
+ <ProjectName>DropBox</ProjectName>
+ </PropertyGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
+ <ConfigurationType>DynamicLibrary</ConfigurationType>
+ <UseDebugLibraries>true</UseDebugLibraries>
+ <CharacterSet>Unicode</CharacterSet>
+ <PlatformToolset>v110_xp</PlatformToolset>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
+ <ConfigurationType>DynamicLibrary</ConfigurationType>
+ <UseDebugLibraries>true</UseDebugLibraries>
+ <CharacterSet>Unicode</CharacterSet>
+ <PlatformToolset>v110_xp</PlatformToolset>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
+ <ConfigurationType>DynamicLibrary</ConfigurationType>
+ <UseDebugLibraries>false</UseDebugLibraries>
+ <WholeProgramOptimization>true</WholeProgramOptimization>
+ <CharacterSet>Unicode</CharacterSet>
+ <PlatformToolset>v110_xp</PlatformToolset>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
+ <ConfigurationType>DynamicLibrary</ConfigurationType>
+ <UseDebugLibraries>false</UseDebugLibraries>
+ <WholeProgramOptimization>true</WholeProgramOptimization>
+ <CharacterSet>Unicode</CharacterSet>
+ <PlatformToolset>v110_xp</PlatformToolset>
+ </PropertyGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
+ <ImportGroup Label="ExtensionSettings">
+ </ImportGroup>
+ <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ </ImportGroup>
+ <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="PropertySheets">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ </ImportGroup>
+ <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ </ImportGroup>
+ <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="PropertySheets">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ </ImportGroup>
+ <PropertyGroup Label="UserMacros" />
+ <PropertyGroup>
+ <_ProjectFileVersion>10.0.30319.1</_ProjectFileVersion>
+ <OutDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(SolutionDir)$(Configuration)\Plugins\</OutDir>
+ <OutDir Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">$(SolutionDir)$(Configuration)64\Plugins\</OutDir>
+ <IntDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(SolutionDir)$(Configuration)\Obj\$(ProjectName)\</IntDir>
+ <IntDir Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">$(SolutionDir)$(Configuration)64\Obj\$(ProjectName)\</IntDir>
+ <OutDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(SolutionDir)$(Configuration)\Plugins\</OutDir>
+ <OutDir Condition="'$(Configuration)|$(Platform)'=='Release|x64'">$(SolutionDir)$(Configuration)64\Plugins\</OutDir>
+ <IntDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(SolutionDir)$(Configuration)\Obj\$(ProjectName)\</IntDir>
+ <IntDir Condition="'$(Configuration)|$(Platform)'=='Release|x64'">$(SolutionDir)$(Configuration)64\Obj\$(ProjectName)\</IntDir>
+ <IgnoreImportLibrary>true</IgnoreImportLibrary>
+ </PropertyGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
+ <ClCompile>
+ <WarningLevel>Level3</WarningLevel>
+ <Optimization>Disabled</Optimization>
+ <PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;_USRDLL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <AdditionalIncludeDirectories>..\..\include;..\..\plugins\ExternalAPI;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ <StringPooling>false</StringPooling>
+ <FunctionLevelLinking>true</FunctionLevelLinking>
+ <DisableSpecificWarnings>4996;%(DisableSpecificWarnings)</DisableSpecificWarnings>
+ <RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
+ <ObjectFileName>$(IntDir)\%(RelativeDir)\</ObjectFileName>
+ <PrecompiledHeaderFile>common.h</PrecompiledHeaderFile>
+ <PrecompiledHeader>NotUsing</PrecompiledHeader>
+ </ClCompile>
+ <Link>
+ <SubSystem>Windows</SubSystem>
+ <GenerateDebugInformation>true</GenerateDebugInformation>
+ <AdditionalLibraryDirectories>$(ProfileDir)..\..\bin11\lib</AdditionalLibraryDirectories>
+ <ImportLibrary>$(IntDir)$(TargetName).lib</ImportLibrary>
+ <AdditionalDependencies>comctl32.lib;%(AdditionalDependencies)</AdditionalDependencies>
+ <RandomizedBaseAddress>false</RandomizedBaseAddress>
+ <AdditionalOptions>/PDBALTPATH:%_PDB% %(AdditionalOptions)</AdditionalOptions>
+ </Link>
+ <ResourceCompile>
+ <PreprocessorDefinitions>_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <AdditionalIncludeDirectories>..\..\include\msapi</AdditionalIncludeDirectories>
+ </ResourceCompile>
+ </ItemDefinitionGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
+ <ClCompile>
+ <WarningLevel>Level3</WarningLevel>
+ <Optimization>Disabled</Optimization>
+ <PreprocessorDefinitions>_DEBUG;_WINDOWS;_USRDLL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <AdditionalIncludeDirectories>..\..\include;..\..\plugins\ExternalAPI;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ <StringPooling>false</StringPooling>
+ <FunctionLevelLinking>true</FunctionLevelLinking>
+ <DisableSpecificWarnings>4996;%(DisableSpecificWarnings)</DisableSpecificWarnings>
+ <RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
+ <ObjectFileName>$(IntDir)\%(RelativeDir)\</ObjectFileName>
+ <PrecompiledHeader>Use</PrecompiledHeader>
+ <PrecompiledHeaderFile>Steam.h</PrecompiledHeaderFile>
+ </ClCompile>
+ <Link>
+ <SubSystem>Windows</SubSystem>
+ <GenerateDebugInformation>true</GenerateDebugInformation>
+ <AdditionalLibraryDirectories>$(ProfileDir)..\..\bin11\lib</AdditionalLibraryDirectories>
+ <ImportLibrary>$(IntDir)$(TargetName).lib</ImportLibrary>
+ <AdditionalDependencies>comctl32.lib;%(AdditionalDependencies)</AdditionalDependencies>
+ <RandomizedBaseAddress>false</RandomizedBaseAddress>
+ <AdditionalOptions>/PDBALTPATH:%_PDB% %(AdditionalOptions)</AdditionalOptions>
+ </Link>
+ <ResourceCompile>
+ <PreprocessorDefinitions>_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <AdditionalIncludeDirectories>..\..\include\msapi</AdditionalIncludeDirectories>
+ </ResourceCompile>
+ </ItemDefinitionGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
+ <ClCompile>
+ <WarningLevel>Level3</WarningLevel>
+ <Optimization>Full</Optimization>
+ <FunctionLevelLinking>true</FunctionLevelLinking>
+ <IntrinsicFunctions>true</IntrinsicFunctions>
+ <PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;_USRDLL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <AdditionalIncludeDirectories>..\..\include;..\..\plugins\ExternalAPI;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ <DisableSpecificWarnings>4996;%(DisableSpecificWarnings)</DisableSpecificWarnings>
+ <ObjectFileName>$(IntDir)\%(RelativeDir)\</ObjectFileName>
+ <PrecompiledHeader>Use</PrecompiledHeader>
+ <PrecompiledHeaderFile>Steam.h</PrecompiledHeaderFile>
+ </ClCompile>
+ <Link>
+ <SubSystem>Windows</SubSystem>
+ <GenerateDebugInformation>true</GenerateDebugInformation>
+ <EnableCOMDATFolding>true</EnableCOMDATFolding>
+ <OptimizeReferences>true</OptimizeReferences>
+ <RandomizedBaseAddress>false</RandomizedBaseAddress>
+ <AdditionalDependencies>comctl32.lib;%(AdditionalDependencies)</AdditionalDependencies>
+ <AdditionalLibraryDirectories>$(ProfileDir)..\..\bin11\lib</AdditionalLibraryDirectories>
+ <ImportLibrary>$(IntDir)$(TargetName).lib</ImportLibrary>
+ </Link>
+ <ResourceCompile>
+ <PreprocessorDefinitions>NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <AdditionalIncludeDirectories>..\..\include\msapi</AdditionalIncludeDirectories>
+ </ResourceCompile>
+ </ItemDefinitionGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
+ <ClCompile>
+ <WarningLevel>Level3</WarningLevel>
+ <Optimization>Full</Optimization>
+ <FunctionLevelLinking>true</FunctionLevelLinking>
+ <IntrinsicFunctions>true</IntrinsicFunctions>
+ <PreprocessorDefinitions>NDEBUG;_WINDOWS;_USRDLL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <AdditionalIncludeDirectories>..\..\include;..\..\plugins\ExternalAPI;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ <DisableSpecificWarnings>4996;%(DisableSpecificWarnings)</DisableSpecificWarnings>
+ <ObjectFileName>$(IntDir)\%(RelativeDir)\</ObjectFileName>
+ <PrecompiledHeader>Use</PrecompiledHeader>
+ <PrecompiledHeaderFile>Steam.h</PrecompiledHeaderFile>
+ </ClCompile>
+ <Link>
+ <SubSystem>Windows</SubSystem>
+ <GenerateDebugInformation>true</GenerateDebugInformation>
+ <EnableCOMDATFolding>true</EnableCOMDATFolding>
+ <OptimizeReferences>true</OptimizeReferences>
+ <RandomizedBaseAddress>false</RandomizedBaseAddress>
+ <AdditionalDependencies>comctl32.lib;%(AdditionalDependencies)</AdditionalDependencies>
+ <AdditionalLibraryDirectories>$(ProfileDir)..\..\bin11\lib</AdditionalLibraryDirectories>
+ <ImportLibrary>$(IntDir)$(TargetName).lib</ImportLibrary>
+ </Link>
+ <ResourceCompile>
+ <PreprocessorDefinitions>NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <AdditionalIncludeDirectories>..\..\include\msapi</AdditionalIncludeDirectories>
+ </ResourceCompile>
+ </ItemDefinitionGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
+ <ImportGroup Label="ExtensionTargets">
+ </ImportGroup>
+</Project> \ No newline at end of file
diff --git a/plugins/DropBox/DropBox_11.vcxproj.filters b/plugins/DropBox/DropBox_11.vcxproj.filters
new file mode 100644
index 0000000000..0027b45275
--- /dev/null
+++ b/plugins/DropBox/DropBox_11.vcxproj.filters
@@ -0,0 +1,44 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <ItemGroup>
+ <ClCompile Include="src\dropBox_proto.cpp">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="src\main.cpp">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ </ItemGroup>
+ <ItemGroup>
+ <ClInclude Include="src\common.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ <ClInclude Include="res\resource.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ <ClInclude Include="src\http_request.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ <ClInclude Include="src\dropBox_proto.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ <ClInclude Include="src\version.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
+ </ItemGroup>
+ <ItemGroup>
+ <Filter Include="Header Files">
+ <UniqueIdentifier>{bb96e6a3-2d56-4aed-9352-30558014561b}</UniqueIdentifier>
+ </Filter>
+ <Filter Include="Resource Files">
+ <UniqueIdentifier>{007efe6e-3f6a-49d0-be83-77c03481c085}</UniqueIdentifier>
+ </Filter>
+ <Filter Include="Source Files">
+ <UniqueIdentifier>{badc339a-531c-4f2a-8a2e-e46bd5630044}</UniqueIdentifier>
+ </Filter>
+ </ItemGroup>
+ <ItemGroup>
+ <ResourceCompile Include="res\Resource.rc">
+ <Filter>Resource Files</Filter>
+ </ResourceCompile>
+ </ItemGroup>
+</Project> \ No newline at end of file
diff --git a/plugins/DropBox/res/resource.h b/plugins/DropBox/res/resource.h
new file mode 100644
index 0000000000..4b1586d386
--- /dev/null
+++ b/plugins/DropBox/res/resource.h
Binary files differ
diff --git a/plugins/DropBox/res/resource.rc b/plugins/DropBox/res/resource.rc
new file mode 100644
index 0000000000..e8c565a818
--- /dev/null
+++ b/plugins/DropBox/res/resource.rc
Binary files differ
diff --git a/plugins/DropBox/src/common.h b/plugins/DropBox/src/common.h
new file mode 100644
index 0000000000..64d4e4cab6
--- /dev/null
+++ b/plugins/DropBox/src/common.h
@@ -0,0 +1,31 @@
+#ifndef _COMMON_H_
+#define _COMMON_H_
+
+//#include <winsock2.h>
+#include <windows.h>
+#include <time.h>
+
+#include <newpluginapi.h>
+
+#include <m_options.h>
+#include <m_database.h>
+
+#include <m_protoint.h>
+#include <m_protomod.h>
+#include <m_protosvc.h>
+
+#include <m_netlib.h>
+
+#include <m_json.h>
+#include <m_langpack.h>
+#include <m_string.h>
+
+#include "version.h"
+#include "..\res\resource.h"
+
+#define MODULE "DropBox"
+
+extern HINSTANCE g_hInstance;
+extern HANDLE g_hNetlibUser;
+
+#endif //_COMMON_H_ \ No newline at end of file
diff --git a/plugins/DropBox/src/dropBox_proto.cpp b/plugins/DropBox/src/dropBox_proto.cpp
new file mode 100644
index 0000000000..f1991a9924
--- /dev/null
+++ b/plugins/DropBox/src/dropBox_proto.cpp
@@ -0,0 +1,383 @@
+#include "dropBox_proto.h"
+
+HANDLE g_hNetlibUser;
+ULONG g_fileId = 1;
+
+int OnModulesLoaded(WPARAM wParam, LPARAM lParam)
+{
+ NETLIBUSER nlu = { sizeof(nlu) };
+ nlu.flags = NUF_INCOMING | NUF_OUTGOING | NUF_HTTPCONNS | NUF_TCHAR;
+ nlu.szSettingsModule = MODULE;
+ nlu.szSettingsModule = MODULE;
+ nlu.ptszDescriptiveName = L"DropBox";
+
+ g_hNetlibUser = (HANDLE)CallService(MS_NETLIB_REGISTERUSER, 0, (LPARAM)&nlu);
+
+ DropBoxLogIn();
+
+ return 0;
+}
+
+int OnOptionsInit(WPARAM wParam, LPARAM lParam)
+{
+ OPTIONSDIALOGPAGE odp = { sizeof(odp) };
+ odp.position = 100000000;
+ odp.hInstance = g_hInstance;
+ odp.flags = ODPF_BOLDGROUPS;
+ odp.pszTemplate = MAKEINTRESOURCEA(IDD_OPTIONS_MAIN);
+ odp.pszGroup = LPGEN("Network");
+ odp.pszTitle = LPGEN("DropBox");
+ odp.pfnDlgProc = MainOptionsProc;
+
+ //Options_AddPage(wParam, &odp);
+
+ return 0;
+}
+
+INT_PTR DropBoxGetCaps(WPARAM wParam, LPARAM lParam)
+{
+ switch(wParam)
+ {
+ case PFLAGNUM_1:
+ return PF1_IM | PF1_FILESEND;
+ case PFLAGNUM_2:
+ return PF2_ONLINE;
+ case PFLAG_UNIQUEIDTEXT:
+ return (INT_PTR) "Dropbox ID";
+ case PFLAG_UNIQUEIDSETTING:
+ return (DWORD_PTR)"uid";
+ }
+
+ return 0;
+}
+
+HttpRequest *DropBoxCreateFileChunkedRequest(const char *data, int length)
+{
+ HttpRequest *request = new HttpRequest(g_hNetlibUser, REQUEST_PUT, DROPBOX_APICONTENT_URL "/chunked_upload");
+ request->AddParameter("access_token", db_get_sa(NULL, MODULE, "TokenSecret"));
+ if (length > 0)
+ {
+ //request->AddHeader("Content-Type", "application/octet-stream");
+ request->dataLength = length;
+ request->pData = (char*)mir_alloc(sizeof(char) * (length + 1));
+ memcpy(request->pData, data, length);
+ request->pData[length] = 0;
+ }
+
+ return request;
+}
+
+bool DropBoxSendFileChunkedStart(const char *data, int length, char *uploadId, int &offset)
+{
+ HttpRequest *request = DropBoxCreateFileChunkedRequest(data, length);
+ NETLIBHTTPREQUEST *response = request->Send();
+
+ delete request;
+
+ if (response && response->resultCode == 200)
+ {
+ JSONNODE *root = json_parse(response->pData);
+ if (root != NULL)
+ {
+ JSONNODE *node = json_get(root, "upload_id");
+ strcpy(uploadId, mir_u2a(json_as_string(node)));
+
+ node = json_get(root, "offset");
+ offset = json_as_int(node);
+
+ return true;
+ }
+ }
+
+ return 0;
+}
+
+bool DropBoxSendFileChunkedNext(const char *data, int length, const char *uploadId, int &offset)
+{
+ HttpRequest *request = DropBoxCreateFileChunkedRequest(data, length);
+ request->AddParameter("upload_id", uploadId);
+ request->AddParameter("offset", offset);
+
+ NETLIBHTTPREQUEST *response = request->Send();
+
+ delete request;
+
+ if (response && response->resultCode == 200)
+ {
+ JSONNODE *root = json_parse(response->pData);
+ if (root != NULL)
+ {
+ JSONNODE *node = json_get(root, "offset");
+ offset = json_as_int(node);
+
+ return true;
+ }
+ }
+
+ return false;
+}
+
+bool DropBoxSendFileChunkedEnd(const char *fileName, const char *uploadId, MCONTACT hContact)
+{
+ char url[MAX_PATH];
+ mir_snprintf(
+ url,
+ SIZEOF(url),
+ "%s/commit_chunked_upload/sandbox/%s",
+ DROPBOX_APICONTENT_URL,
+ fileName);
+
+ HttpRequest *request = new HttpRequest(g_hNetlibUser, REQUEST_POST, url);
+ request->AddParameter("upload_id", uploadId);
+ request->AddParameter("access_token", db_get_sa(NULL, MODULE, "TokenSecret"));
+
+ NETLIBHTTPREQUEST *response = request->Send();
+
+ delete request;
+
+ if (response && response->resultCode == 200)
+ {
+ //char message[MAX_PATH];
+ //mir_snprintf(
+ // message,
+ // SIZEOF(message),
+ // "%s/files/sandbox/%s",
+ // DROPBOX_APICONTENT_URL,
+ // fileName);
+
+ //PROTORECVEVENT recv = { 0 };
+ ////recv.flags = flags;
+ ////recv.lParam = (LPARAM)&param;
+ //recv.timestamp = time(NULL);
+ //recv.szMessage = ::mir_strdup(message);
+ //::ProtoChainRecvMsg(hContact, &recv);
+
+ return true;
+ }
+
+ return false;
+}
+
+void DropBoxAsyncFileSend(void *args)
+{
+}
+
+INT_PTR DropBoxSendFile(WPARAM wParam, LPARAM lParam)
+{
+ CCSDATA *pccsd=(CCSDATA*)lParam;
+
+ char **files = (char**)pccsd->lParam;
+ for (int i = 0; files[i]; i++)
+ {
+ FILE *file = fopen(files[i], "rb");
+ if (file != NULL)
+ {
+ int offset = 0;
+ bool isFirstChunk = true;
+ char *uploadId = new char[32];
+
+ const char *fileName = strrchr(files[i], '\\') + 1;
+
+ while (!feof(file) && !ferror(file))
+ {
+ char *data = new char[DROPBOX_FILE_CHUNK_SIZE + 1];
+ size_t count = fread(data, sizeof(char), DROPBOX_FILE_CHUNK_SIZE, file);
+
+ if (isFirstChunk)
+ {
+ DropBoxSendFileChunkedStart(data, count, uploadId, offset);
+ isFirstChunk = false;
+ }
+ else
+ {
+ DropBoxSendFileChunkedNext(data, count, uploadId, offset);
+ }
+ }
+
+ fclose(file);
+
+ return DropBoxSendFileChunkedEnd(fileName, uploadId, pccsd->hContact);
+
+ }
+
+ //ULONG fileId = ::InterlockedIncrement(&g_fileId);
+
+ //return fileId;
+ }
+
+ return 0;
+}
+
+INT_PTR DropBoxSendMessage(WPARAM wParam, LPARAM lParam)
+{
+ return 0;
+}
+
+INT_PTR DropBoxReceiveMessage(WPARAM wParam, LPARAM lParam)
+{
+ /*CCSDATA *pccsd = (CCSDATA *)lParam;
+ PROTORECVEVENT *ppre = (PROTORECVEVENT *)pccsd->lParam;
+ return CallService(MS_PROTO_CHAINRECV, wParam, lParam);
+
+ DBEVENTINFO dbei = { sizeof(dbei) };
+ dbei.szModule = MODULE;
+ dbei.timestamp = ppre->timestamp;
+ dbei.eventType = type;
+ dbei.cbBlob = ppre->cbCustomDataSize;
+ dbei.pBlob = ppre->szMessage;
+ dbei.flags = flags;
+ return ::db_event_add(pccsd->hContact, &dbei);*/
+
+ return 0;
+}
+
+void SetContactStatus(MCONTACT hContact, int newStatus)
+{
+ if (db_get_w(hContact, MODULE, "Status", ID_STATUS_OFFLINE) != newStatus)
+ db_set_w(hContact, MODULE, "Status", newStatus);
+}
+
+bool DropBoxLogIn()
+{
+ char *access_token = db_get_sa(NULL, MODULE, "TokenSecret");
+ if (!access_token)
+ {
+ ShellExecuteA(NULL, "open", "https://www.dropbox.com/1/oauth2/authorize?response_type=code&client_id="DROPBOX_API_KEY, NULL, NULL, SW_SHOWDEFAULT);
+
+ char request_token[128];
+ request_token[0] = 0;
+
+ if (DialogBoxParam(
+ g_hInstance,
+ MAKEINTRESOURCE(IDD_TOKEN_REQUEST),
+ NULL,
+ TokenRequestProc,
+ (LPARAM)&request_token) == IDOK)
+ {
+ HttpRequest *request = new HttpRequest(g_hNetlibUser, REQUEST_POST, DROPBOX_API_URL "/oauth2/token");
+ request->AddParameter("grant_type", "authorization_code");
+ request->AddParameter("code", request_token);
+ request->AddHeader("Content-Type", "application/x-www-form-urlencoded");
+ char data[64];
+ mir_snprintf(
+ data,
+ SIZEOF(data),
+ "client_id=%s&client_secret=%s",
+ DROPBOX_API_KEY,
+ DROPBOX_API_SECRET);
+ request->pData = mir_strdup(data);
+ request->dataLength = strlen(data);
+
+ NETLIBHTTPREQUEST *response = request->Send();
+
+ if (response && response->resultCode == 200)
+ {
+ JSONNODE *root = json_parse(response->pData);
+ if (root != NULL)
+ {
+ JSONNODE *node = json_get(root, "access_token");
+ access_token = mir_u2a(json_as_string(node));
+ db_set_s(NULL, MODULE, "TokenSecret", access_token);
+
+ MCONTACT hContact = (MCONTACT)CallService(MS_DB_CONTACT_ADD, 0, 0);
+ if (!CallService(MS_PROTO_ADDTOCONTACT, hContact, (LPARAM)MODULE))
+ {
+ node = json_get(root, "uid");
+ wchar_t *uid = json_as_string(node);
+ db_set_ws(hContact, MODULE, "uid", uid);
+
+ db_set_s(hContact, MODULE, "Nick", MODULE);
+ db_set_w(hContact, MODULE, "Status", ID_STATUS_ONLINE);
+ //SetContactStatus(hContact, ID_STATUS_ONLINE);
+ }
+
+ delete node;
+ delete root;
+ delete request;
+ //delete access_token;
+
+ return true;
+ }
+ }
+
+ delete request;
+ }
+ }
+ /*else
+ {
+ for (MCONTACT hContact = db_find_first(MODULE); hContact; hContact = db_find_next(hContact, MODULE))
+ SetContactStatus(hContact, ID_STATUS_ONLINE);
+ }*/
+
+ return false;
+}
+
+//void LogOut()
+//{
+// HttpRequest<CDropBoxProto> *request = new HttpRequest<CDropBoxProto>(this, REQUEST_POST, DROPBOX_API_URL "/disable_access_token");
+// //request->SendAsync(&CDropBoxProto::AsyncFunc);
+// request->Send();
+//
+// delete request;
+//}
+
+INT_PTR CALLBACK TokenRequestProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
+{
+ char *token = reinterpret_cast<char*>(::GetWindowLongPtr(hwndDlg, GWLP_USERDATA));
+
+ switch (msg)
+ {
+ case WM_INITDIALOG:
+ TranslateDialogDefault(hwndDlg);
+
+ token = (char*)lParam;
+ SetWindowLongPtr(hwndDlg, GWLP_USERDATA, lParam);
+ {
+ //::SendMessage(hwndDlg, WM_SETICON, ICON_BIG, (LPARAM)CSkypeProto::IconList[0].Handle);
+ //::SendMessage(hwndDlg, WM_SETICON, ICON_SMALL, (LPARAM)CSkypeProto::IconList[0].Handle);
+
+ /*wchar_t title[MAX_PATH];
+ ::mir_sntprintf(
+ title,
+ MAX_PATH,
+ ::TranslateT("Enter a password for %s:"),
+ param->login);*/
+ //::SetDlgItemText(hwndDlg, IDC_INSTRUCTION, title);
+
+ SendDlgItemMessage(hwndDlg, IDC_TOKEN, EM_LIMITTEXT, 128 - 1, 0);
+ }
+ break;
+
+ case WM_CLOSE:
+ EndDialog(hwndDlg, 0);
+ break;
+
+ case WM_COMMAND:
+ {
+ switch (LOWORD(wParam))
+ {
+ case IDOK:
+ {
+ char data[128];
+ GetDlgItemTextA(hwndDlg, IDC_TOKEN, data, SIZEOF(data));
+ strcpy(token, data);
+
+ EndDialog(hwndDlg, IDOK);
+ }
+ break;
+
+ case IDCANCEL:
+ EndDialog(hwndDlg, IDCANCEL);
+ break;
+ }
+ }
+ break;
+ }
+
+ return FALSE;
+}
+
+INT_PTR CALLBACK MainOptionsProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
+{
+ return FALSE;
+} \ No newline at end of file
diff --git a/plugins/DropBox/src/dropBox_proto.h b/plugins/DropBox/src/dropBox_proto.h
new file mode 100644
index 0000000000..2127755059
--- /dev/null
+++ b/plugins/DropBox/src/dropBox_proto.h
@@ -0,0 +1,43 @@
+#ifndef _DROPBOX_PROTO_H_
+#define _DROPBOX_PROTO_H_
+
+//#include "common.h"
+#include "http_request.h"
+
+#define DROPBOX_API_VER "1"
+
+#define DROPBOX_API_URL "https://api.dropbox.com/" DROPBOX_API_VER
+#define DROPBOX_APICONTENT_URL "https://api-content.dropbox.com/" DROPBOX_API_VER
+
+#define DROPBOX_API_KEY "fa8du7gkf2q8xzg"
+#include "..\..\DropBoxApi\sekret_key.h"
+
+#define DROPBOX_FILE_CHUNK_SIZE 100 * 1024 //100 KB
+//4 * 1024 * 1024 // 4 MB
+
+extern ULONG g_fileId;
+
+void SetContactStatus(MCONTACT hContact, int newStatus);
+bool DropBoxLogIn();
+
+int OnOptionsInit(WPARAM wParam, LPARAM lParam);
+int OnModulesLoaded(WPARAM wParam, LPARAM lParam);
+
+INT_PTR DropBoxGetCaps(WPARAM wParam, LPARAM lParam);
+
+INT_PTR DropBoxSendMessage(WPARAM wParam, LPARAM lParam);
+INT_PTR DropBoxReceiveMessage(WPARAM wParam, LPARAM lParam);
+
+HttpRequest *DropBoxCreateFileChunkedRequest(const char *data, int length);
+bool DropBoxSendFileChunkedStart(const char *data, int length, char *uploadId, int &offset);
+bool DropBoxSendFileChunkedNext(const char *data, int length, const char *uploadId, int &offset);
+bool DropBoxSendFileChunkedEnd(const char *fileName, const char *uploadId, MCONTACT hContact);
+
+void DropBoxAsyncFileSend(void *args);
+
+INT_PTR DropBoxSendFile(WPARAM wParam, LPARAM lParam);
+
+INT_PTR CALLBACK MainOptionsProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam);
+INT_PTR CALLBACK TokenRequestProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam);
+
+#endif //_DROPBOX_PROTO_H_ \ No newline at end of file
diff --git a/plugins/DropBox/src/http_request.h b/plugins/DropBox/src/http_request.h
new file mode 100644
index 0000000000..582de2fa83
--- /dev/null
+++ b/plugins/DropBox/src/http_request.h
@@ -0,0 +1,87 @@
+#ifndef _HTTP_REQUEST_H_
+#define _HTTP_REQUEST_H_
+
+#include "common.h"
+
+class HttpRequest : public NETLIBHTTPREQUEST, public MZeroedObject
+{
+public:
+ HttpRequest(HANDLE hNetlibUser, int requestType, LPCSTR url)
+ {
+ cbSize = sizeof(NETLIBHTTPREQUEST);
+ flags = NLHRF_HTTP11;
+ this->requestType = requestType;
+
+ m_hNetlibUser = hNetlibUser;
+ m_szUrl = mir_strdup(url);
+ }
+
+ ~HttpRequest()
+ {
+ for (int i=0; i < headersCount; i++)
+ {
+ mir_free(headers[i].szName);
+ mir_free(headers[i].szValue);
+ }
+ mir_free(headers);
+ mir_free(pData);
+ }
+
+
+ void AddHeader(LPCSTR szName, LPCSTR szValue)
+ {
+ headers = (NETLIBHTTPHEADER*)mir_realloc(headers, sizeof(NETLIBHTTPHEADER)*(headersCount+1));
+ headers[headersCount].szName = mir_strdup(szName);
+ headers[headersCount].szValue = mir_strdup(szValue);
+ headersCount++;
+ }
+
+ void AddParameter(LPCSTR szName, LPCSTR szValue)
+ {
+ if(m_szUrl.Find('?') == -1)
+ m_szUrl.AppendFormat("?%s=%s", szName, szValue);
+ else
+ m_szUrl.AppendFormat("&%s=%s", szName, szValue);
+ }
+
+ void AddParameter(LPCSTR szName, int value)
+ {
+ if(m_szUrl.Find('?') == -1)
+ m_szUrl.AppendFormat("?%s=%i", szName, value);
+ else
+ m_szUrl.AppendFormat("&%s=%i", szName, value);
+ }
+
+ NETLIBHTTPREQUEST *Send()
+ {
+ szUrl = m_szUrl.GetBuffer();
+ return (NETLIBHTTPREQUEST*)CallService(MS_NETLIB_HTTPTRANSACTION, (WPARAM)m_hNetlibUser, (LPARAM)this);
+ }
+
+ //void SendAsync(typename CBaseProto<T>::AsyncHttpRequest callback)
+ //{
+ // szUrl = m_szUrl.GetBuffer();
+ // AsyncParam param = { this, proto, callback };
+ // /*HANDLE hThread = */mir_forkthread(SendAsync, &param);
+ // //WaitForSingleObject(hThread, INFINITE);
+ //}
+
+private:
+
+ CMStringA m_szUrl;
+ HANDLE m_hNetlibUser;
+
+ /*static void SendAsync(void *arg)
+ {
+ AsyncParam *param = (AsyncParam*)arg;
+ NETLIBHTTPREQUEST* response = (NETLIBHTTPREQUEST*)CallService(MS_NETLIB_HTTPTRANSACTION, (WPARAM)param->m_proto->m_hNetlibUser, (LPARAM)param->m_request);
+
+ CBaseProto<T> *proto = param->m_proto;
+ AsyncRequestCallback callback = param->m_callback;
+ proto->*callback(response);
+
+ delete response;
+ }*/
+};
+
+#endif //_HTTP_REQUEST_H_ \ No newline at end of file
diff --git a/plugins/DropBox/src/main.cpp b/plugins/DropBox/src/main.cpp
new file mode 100644
index 0000000000..a4e97b0a24
--- /dev/null
+++ b/plugins/DropBox/src/main.cpp
@@ -0,0 +1,63 @@
+//#include "dropBox_proto.h"
+#include "dropBox_proto.h"
+
+int hLangpack;
+HINSTANCE g_hInstance;
+
+PLUGININFOEX pluginInfo =
+{
+ sizeof(PLUGININFOEX),
+ __PLUGIN_NAME,
+ PLUGIN_MAKE_VERSION(__MAJOR_VERSION, __MINOR_VERSION, __RELEASE_NUM, __BUILD_NUM),
+ __DESCRIPTION,
+ __AUTHOR,
+ __AUTHOREMAIL,
+ __COPYRIGHT,
+ __AUTHORWEB,
+ UNICODE_AWARE,
+ // {B908773A-86F7-4A91-8674-6A20BA0E67D1}
+ {0xb908773a, 0x86f7, 0x4a91, {0x86, 0x74, 0x6a, 0x20, 0xba, 0xe, 0x67, 0xd1}}
+
+};
+
+DWORD WINAPI DllMain(HINSTANCE hInstance, DWORD, LPVOID)
+{
+ g_hInstance = hInstance;
+
+ return TRUE;
+}
+
+extern "C" __declspec(dllexport) PLUGININFOEX* MirandaPluginInfoEx(DWORD mirandaVersion)
+{
+ return &pluginInfo;
+}
+
+extern "C" __declspec(dllexport) const MUUID MirandaInterfaces[] = {MIID_PROTOCOL, MIID_LAST};
+
+extern "C" int __declspec(dllexport) Load(void)
+{
+ mir_getLP(&pluginInfo);
+
+ HookEvent(ME_OPT_INITIALISE, OnOptionsInit);
+ HookEvent(ME_SYSTEM_MODULESLOADED, OnModulesLoaded);
+
+ PROTOCOLDESCRIPTOR pd = { PROTOCOLDESCRIPTOR_V3_SIZE };
+ pd.szName = MODULE;
+ pd.type = PROTOTYPE_VIRTUAL;
+
+ CallService(MS_PROTO_REGISTERMODULE, 0, (LPARAM)&pd);
+
+ CreateProtoServiceFunction(MODULE, PS_GETCAPS, DropBoxGetCaps);
+
+ CreateProtoServiceFunction(MODULE, PSS_FILE, DropBoxSendFile);
+
+ CreateProtoServiceFunction(MODULE, PSS_MESSAGE, DropBoxSendMessage);
+ CreateProtoServiceFunction(MODULE, PSR_MESSAGE, DropBoxReceiveMessage);
+
+ return 0;
+}
+
+extern "C" int __declspec(dllexport) Unload(void)
+{
+ return 0;
+} \ No newline at end of file
diff --git a/plugins/DropBox/src/resource.h b/plugins/DropBox/src/resource.h
new file mode 100644
index 0000000000..a88429637c
--- /dev/null
+++ b/plugins/DropBox/src/resource.h
Binary files differ
diff --git a/plugins/DropBox/src/version.h b/plugins/DropBox/src/version.h
new file mode 100644
index 0000000000..dc8892c2de
--- /dev/null
+++ b/plugins/DropBox/src/version.h
@@ -0,0 +1,15 @@
+#define __MAJOR_VERSION 0
+#define __MINOR_VERSION 11
+#define __RELEASE_NUM 0
+#define __BUILD_NUM 0
+
+#include <stdver.h>
+
+#define __PLUGIN_NAME "DropBox"
+#define __INTERNAL_NAME "DropBox"
+#define __FILENAME "DropBox.dll"
+#define __DESCRIPTION "Provide ability to load file on DropBox."
+#define __AUTHOR "unsane"
+#define __AUTHOREMAIL ""
+#define __AUTHORWEB "http://miranda-ng.org/p/DropBox/"
+#define __COPYRIGHT "© 2014 Miranda NG project"