diff options
Diffstat (limited to 'plugins/CloudFile/src/events.cpp')
-rw-r--r-- | plugins/CloudFile/src/events.cpp | 62 |
1 files changed, 62 insertions, 0 deletions
diff --git a/plugins/CloudFile/src/events.cpp b/plugins/CloudFile/src/events.cpp new file mode 100644 index 0000000000..815a5f0b96 --- /dev/null +++ b/plugins/CloudFile/src/events.cpp @@ -0,0 +1,62 @@ +#include "stdafx.h" + +int OnModulesLoaded(WPARAM, LPARAM) +{ + HookEvent(ME_OPT_INITIALISE, OnOptionsInitialized); + // srfile + size_t count = Services.getCount(); + for (size_t i = 0; i < count; i++) { + CCloudService *service = Services[i]; + + HookEventObj(ME_FILEDLG_CANCELED, OnFileDialogCanceled, service); + } + // menus + HookEvent(ME_CLIST_PREBUILDCONTACTMENU, OnPrebuildContactMenu); + // srmm + HookEvent(ME_MSG_TOOLBARLOADED, OnSrmmToolbarLoaded); + HookEvent(ME_MSG_WINDOWEVENT, OnSrmmWindowOpened); + HookEvent(ME_MSG_BUTTONPRESSED, OnSrmmButtonPressed); + + return 0; +} + +int OnProtoAck(WPARAM, LPARAM lParam) +{ + ACKDATA *ack = (ACKDATA*)lParam; + + if (!mir_strcmp(ack->szModule, MODULE)) + return 0; // don't rebroadcast our own acks + + if (ack->type == ACKTYPE_STATUS) { + WORD status = ack->lParam; + bool canSendOffline = (CallProtoService(ack->szModule, PS_GETCAPS, PFLAGNUM_4, 0) & PF4_IMSENDOFFLINE) > 0; + + for (MCONTACT hContact = db_find_first(ack->szModule); hContact; hContact = db_find_next(hContact, ack->szModule)) { + MessageWindowData msgw; + if (!Srmm_GetWindowData(hContact, msgw) && msgw.uState & MSG_WINDOW_STATE_EXISTS) { + BBButton bbd = {}; + bbd.pszModuleName = MODULE; + bbd.dwButtonID = BBB_ID_FILE_SEND; + bbd.bbbFlags = BBSF_RELEASED; + + if (status == ID_STATUS_OFFLINE && !canSendOffline) + bbd.bbbFlags = BBSF_DISABLED; + + Srmm_SetButtonState(hContact, &bbd); + } + } + } + + return 0; +} + +int OnFileDialogCanceled(void* obj, WPARAM hContact, LPARAM) +{ + CCloudService *service = (CCloudService*)obj; + + auto it = service->InterceptedContacts.find(hContact); + if (it != service->InterceptedContacts.end()) + service->InterceptedContacts.erase(it); + + return 0; +} |