diff options
author | aunsane <aunsane@gmail.com> | 2017-04-16 01:32:19 +0300 |
---|---|---|
committer | aunsane <aunsane@gmail.com> | 2017-04-16 01:32:58 +0300 |
commit | 0b9fa1d90f8d0aff7118837ceb1211b578a5a9c8 (patch) | |
tree | 3b8be7b839a98a3a52a38d713c2d708ada015510 /plugins/CloudFile/src/srmm.cpp | |
parent | 008fb731e3e3b587f596afba1cfe7446de7f0cac (diff) |
CloudFile: initial commit
- Dropbox (worked)
- Yandex.Disk (worked)
- GDrive (not worked)
Diffstat (limited to 'plugins/CloudFile/src/srmm.cpp')
-rw-r--r-- | plugins/CloudFile/src/srmm.cpp | 77 |
1 files changed, 77 insertions, 0 deletions
diff --git a/plugins/CloudFile/src/srmm.cpp b/plugins/CloudFile/src/srmm.cpp new file mode 100644 index 0000000000..e903d90721 --- /dev/null +++ b/plugins/CloudFile/src/srmm.cpp @@ -0,0 +1,77 @@ +#include "stdafx.h" + +int OnSrmmToolbarLoaded(WPARAM, LPARAM) +{ + BBButton bbd = {}; + bbd.pszModuleName = MODULE; + bbd.bbbFlags = BBBF_ISIMBUTTON | BBBF_ISCHATBUTTON | BBBF_ISRSIDEBUTTON; + + CMStringW tooltip(CMStringDataFormat::FORMAT, TranslateT("Upload files to ...")); + bbd.pwszTooltip = tooltip; + bbd.hIcon = GetIconHandle(IDI_UPLOAD); + bbd.dwButtonID = BBB_ID_FILE_SEND; + bbd.dwDefPos = 100 + bbd.dwButtonID; + Srmm_AddButton(&bbd); + + return 0; +} + +int OnSrmmWindowOpened(WPARAM, LPARAM lParam) +{ + MessageWindowEventData *ev = (MessageWindowEventData*)lParam; + if (ev->uType == MSG_WINDOW_EVT_OPENING && ev->hContact) { + char *proto = GetContactProto(ev->hContact); + bool isProtoOnline = CallProtoService(proto, PS_GETSTATUS, 0, 0) > ID_STATUS_OFFLINE; + WORD status = db_get_w(ev->hContact, proto, "Status", ID_STATUS_OFFLINE); + bool canSendOffline = (CallProtoService(proto, PS_GETCAPS, PFLAGNUM_4, 0) & PF4_IMSENDOFFLINE) > 0; + + BBButton bbd = {}; + bbd.pszModuleName = MODULE; + bbd.dwButtonID = BBB_ID_FILE_SEND; + bbd.bbbFlags = BBSF_RELEASED; + if (!isProtoOnline || (status == ID_STATUS_OFFLINE && !canSendOffline)) + bbd.bbbFlags = BBSF_DISABLED; + + //Srmm_SetButtonState(ev->hContact, &bbd); + } + + return 0; +} + +int OnSrmmButtonPressed(WPARAM, LPARAM lParam) +{ + CustomButtonClickData *cbc = (CustomButtonClickData*)lParam; + + if (mir_strcmp(cbc->pszModule, MODULE)) + return 0; + + if (cbc->dwButtonId != BBB_ID_FILE_SEND) + return 0; + + HMENU hMenu = CreatePopupMenu(); + + size_t count = Services.getCount(); + for (size_t i = 0; i < count; i++) { + CCloudService *service = Services[i]; + + InsertMenu(hMenu, i, MF_STRING, i + 1, service->GetText()); + //HBITMAP hBitmap = (HBITMAP)LoadImage(hInstance, MAKEINTRESOURCE(IDI_UPLOAD), IMAGE_ICON, 16, 16, 0); + //SetMenuItemBitmaps(hMenu, i, MF_BITMAP, hBitmap, hBitmap); + } + + int ind = TrackPopupMenu(hMenu, TPM_RETURNCMD, cbc->pt.x, cbc->pt.y, 0, cbc->hwndFrom, NULL); + if (ind > 0) { + CCloudService *service = Services[ind - 1]; + + auto it = service->InterceptedContacts.find(cbc->hContact); + if (it == service->InterceptedContacts.end()) + { + HWND hwnd = (HWND)CallService(MS_FILE_SENDFILE, cbc->hContact, 0); + service->InterceptedContacts[cbc->hContact] = hwnd; + } + else + SetActiveWindow(it->second); + } + + return 0; +}
\ No newline at end of file |