summaryrefslogtreecommitdiff
path: root/plugins/Dropbox/src/dropbox_events.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/Dropbox/src/dropbox_events.cpp')
-rw-r--r--plugins/Dropbox/src/dropbox_events.cpp102
1 files changed, 46 insertions, 56 deletions
diff --git a/plugins/Dropbox/src/dropbox_events.cpp b/plugins/Dropbox/src/dropbox_events.cpp
index 0e5472ef0b..325a328152 100644
--- a/plugins/Dropbox/src/dropbox_events.cpp
+++ b/plugins/Dropbox/src/dropbox_events.cpp
@@ -1,9 +1,11 @@
#include "common.h"
-int CDropbox::OnModulesLoaded(WPARAM wParam, LPARAM lParam)
+int CDropbox::OnModulesLoaded(void *obj, WPARAM wParam, LPARAM lParam)
{
- HookEvent(ME_FILEDLG_CANCELED, CDropbox::OnFileDoalogCancelled);
- HookEvent(ME_FILEDLG_SUCCEEDED, CDropbox::OnFileDoalogSuccessed);
+ CDropbox *instance = (CDropbox*)obj;
+
+ HookEventObj(ME_FILEDLG_CANCELED, OnFileDoalogCancelled, obj);
+ HookEventObj(ME_FILEDLG_SUCCEEDED, OnFileDoalogSuccessed, obj);
NETLIBUSER nlu = { sizeof(nlu) };
nlu.flags = NUF_INCOMING | NUF_OUTGOING | NUF_HTTPCONNS | NUF_TCHAR;
@@ -11,30 +13,7 @@ int CDropbox::OnModulesLoaded(WPARAM wParam, LPARAM lParam)
nlu.szSettingsModule = MODULE;
nlu.ptszDescriptiveName = L"Dropbox";
- INSTANCE->hNetlibUser = (HANDLE)CallService(MS_NETLIB_REGISTERUSER, 0, (LPARAM)&nlu);
-
- MCONTACT hContact = GetDefaultContact();
- if (!hContact)
- {
- hContact = (MCONTACT)CallService(MS_DB_CONTACT_ADD, 0, 0);
- if (!CallService(MS_PROTO_ADDTOCONTACT, hContact, (LPARAM)MODULE))
- {
- db_set_s(NULL, MODULE, "Nick", MODULE);
- db_set_s(hContact, MODULE, "Nick", MODULE);
- db_set_ws(hContact, "CList", "MyHandle", L"Dropbox");
-
- if (HasAccessToken() && db_get_w(hContact, MODULE, "Status", ID_STATUS_OFFLINE) == ID_STATUS_OFFLINE)
- {
- db_set_w(hContact, MODULE, "Status", ID_STATUS_ONLINE);
- }
-
- if (!db_get_b(NULL, "FirstRun", MODULE, 0))
- {
- mir_forkthread(CDropbox::RequestApiAuthorizationAsync, 0);
- db_set_b(NULL, "FirstRun", MODULE, 1);
- }
- }
- }
+ instance->hNetlibUser = (HANDLE)CallService(MS_NETLIB_REGISTERUSER, 0, (LPARAM)&nlu);
if (ServiceExists(MS_BB_ADDBUTTON))
{
@@ -48,14 +27,14 @@ int CDropbox::OnModulesLoaded(WPARAM wParam, LPARAM lParam)
bbd.dwDefPos = 100 + bbd.dwButtonID;
CallService(MS_BB_ADDBUTTON, 0, (LPARAM)&bbd);
- HookEvent(ME_MSG_WINDOWEVENT, CDropbox::OnSrmmWindowOpened);
- HookEvent(ME_MSG_BUTTONPRESSED, CDropbox::OnSrmmButtonPressed);
+ HookEventObj(ME_MSG_WINDOWEVENT, OnSrmmWindowOpened, obj);
+ HookEventObj(ME_MSG_BUTTONPRESSED, OnTabSrmmButtonPressed, obj);
}
return 0;
}
-int CDropbox::OnPreShutdown(WPARAM wParam, LPARAM lParam)
+int CDropbox::OnPreShutdown(void *obj, WPARAM wParam, LPARAM lParam)
{
if (ServiceExists(MS_BB_ADDBUTTON))
{
@@ -69,7 +48,20 @@ int CDropbox::OnPreShutdown(WPARAM wParam, LPARAM lParam)
return 0;
}
-int CDropbox::OnOptionsInit(WPARAM wParam, LPARAM lParam)
+int CDropbox::OnContactDeleted(void *obj, WPARAM hContact, LPARAM lParam)
+{
+ CDropbox *instance = (CDropbox*)obj;
+
+ if (lstrcmpiA(GetContactProto(hContact), MODULE) == 0)
+ {
+ if (instance->HasAccessToken())
+ instance->DestroyAcceessToken();
+ }
+
+ return 0;
+}
+
+int CDropbox::OnOptionsInitialized(void *obj, WPARAM wParam, LPARAM lParam)
{
OPTIONSDIALOGPAGE odp = { sizeof(odp) };
odp.position = 100000000;
@@ -77,27 +69,19 @@ int CDropbox::OnOptionsInit(WPARAM wParam, LPARAM lParam)
odp.flags = ODPF_BOLDGROUPS;
odp.pszTemplate = MAKEINTRESOURCEA(IDD_OPTIONS_MAIN);
odp.pszGroup = LPGEN("Network");
- odp.pszTitle = LPGEN("Dropbox");
+ odp.pszTitle = "Dropbox";
odp.pfnDlgProc = MainOptionsProc;
+ odp.dwInitParam = (LPARAM)obj;
Options_AddPage(wParam, &odp);
return 0;
}
-int CDropbox::OnContactDeleted(WPARAM hContact, LPARAM lParam)
+int CDropbox::OnSrmmWindowOpened(void *obj, WPARAM wParam, LPARAM lParam)
{
- if (lstrcmpiA(GetContactProto(hContact), MODULE) == 0)
- {
- if (HasAccessToken())
- INSTANCE->DestroyAcceessToken();
- }
+ CDropbox *instance = (CDropbox*)obj;
- return 0;
-}
-
-int CDropbox::OnSrmmWindowOpened(WPARAM wParam, LPARAM lParam)
-{
MessageWindowEventData *ev = (MessageWindowEventData*)lParam;
if (ev->uType == MSG_WINDOW_EVT_OPENING && ev->hContact)
{
@@ -105,9 +89,9 @@ int CDropbox::OnSrmmWindowOpened(WPARAM wParam, LPARAM lParam)
BBButton bbd = { sizeof(bbd) };
bbd.pszModuleName = MODULE;
- if (ev->hContact == GetDefaultContact() || !HasAccessToken() || status == ID_STATUS_OFFLINE)
+ if (ev->hContact == instance->GetDefaultContact() || !instance->HasAccessToken() || status == ID_STATUS_OFFLINE)
bbd.bbbFlags = BBSF_HIDDEN | BBSF_DISABLED;
- else if (INSTANCE->hContactTransfer)
+ else if (instance->hTransferContact)
bbd.bbbFlags = BBSF_DISABLED;
bbd.dwButtonID = BBB_ID_FILE_SEND;
@@ -117,38 +101,44 @@ int CDropbox::OnSrmmWindowOpened(WPARAM wParam, LPARAM lParam)
return 0;
}
-int CDropbox::OnSrmmButtonPressed(WPARAM wParam, LPARAM lParam)
+int CDropbox::OnTabSrmmButtonPressed(void *obj, WPARAM wParam, LPARAM lParam)
{
+ CDropbox *instance = (CDropbox*)obj;
+
CustomButtonClickData *cbc = (CustomButtonClickData *)lParam;
if (!strcmp(cbc->pszModule, MODULE) && cbc->dwButtonId == BBB_ID_FILE_SEND && cbc->hContact)
{
- INSTANCE->hContactTransfer = cbc->hContact;
+ instance->hTransferContact = cbc->hContact;
- HWND hwnd = (HWND)CallService(MS_FILE_SENDFILE, GetDefaultContact(), 0);
+ HWND hwnd = (HWND)CallService(MS_FILE_SENDFILE, instance->GetDefaultContact(), 0);
- dcftp[hwnd] = cbc->hContact;
+ instance->dcftp[hwnd] = cbc->hContact;
}
return 0;
}
-int CDropbox::OnFileDoalogCancelled(WPARAM hContact, LPARAM lParam)
+int CDropbox::OnFileDoalogCancelled(void *obj, WPARAM hContact, LPARAM lParam)
{
+ CDropbox *instance = (CDropbox*)obj;
+
HWND hwnd = (HWND)lParam;
- if (INSTANCE->hContactTransfer == dcftp[hwnd])
+ if (instance->hTransferContact == instance->dcftp[hwnd])
{
- dcftp.erase((HWND)lParam);
- INSTANCE->hContactTransfer = 0;
+ instance->dcftp.erase((HWND)lParam);
+ instance->hTransferContact = 0;
}
return 0;
}
-int CDropbox::OnFileDoalogSuccessed(WPARAM hContact, LPARAM lParam)
+int CDropbox::OnFileDoalogSuccessed(void *obj, WPARAM hContact, LPARAM lParam)
{
+ CDropbox *instance = (CDropbox*)obj;
+
HWND hwnd = (HWND)lParam;
- if (INSTANCE->hContactTransfer == dcftp[hwnd])
- dcftp.erase((HWND)lParam);
+ if (instance->hTransferContact == instance->dcftp[hwnd])
+ instance->dcftp.erase((HWND)lParam);
return 0;
} \ No newline at end of file