diff options
author | aunsane <aunsane@gmail.com> | 2017-05-07 02:25:29 +0300 |
---|---|---|
committer | aunsane <aunsane@gmail.com> | 2017-05-07 02:25:29 +0300 |
commit | ff6a107e5f566da2644fbfe36455467beafaeb1e (patch) | |
tree | 3d5b96794ee835c8686a74da6c418c440c91c403 /plugins/CloudFile/src/menus.cpp | |
parent | 453b3de91c372ee7b2661771aead6675e12fe98f (diff) |
CloudFile:
- reworked options to dupport default service
- added options to select conflict behavior
- multiple fix and refactoring
- version bump
Diffstat (limited to 'plugins/CloudFile/src/menus.cpp')
-rw-r--r-- | plugins/CloudFile/src/menus.cpp | 45 |
1 files changed, 24 insertions, 21 deletions
diff --git a/plugins/CloudFile/src/menus.cpp b/plugins/CloudFile/src/menus.cpp index 235ed4e196..13791c13de 100644 --- a/plugins/CloudFile/src/menus.cpp +++ b/plugins/CloudFile/src/menus.cpp @@ -15,25 +15,40 @@ void InitializeMenus() { CMenuItem mi; SET_UID(mi, 0x93d4495b, 0x259b, 0x4fba, 0xbc, 0x14, 0xf9, 0x46, 0x2c, 0xda, 0xfc, 0x6d); - mi.name.a = LPGEN("Upload files to..."); - mi.position = -2000020001; + mi.name.a = LPGEN("Upload to ..."); + + ptrA defaultService(db_get_sa(NULL, MODULE, "DefaultService")); + if (defaultService) { + CCloudServiceSearch search(defaultService); + CCloudService *service = Services.find(&search); + if (service) { + mi.name.a = LPGEN("Upload"); + mi.pszService = MODULE "/Default/Upload"; + CreateServiceFunctionObj(mi.pszService, UploadMenuCommand, service); + } + } + + mi.position = -2000019999; mi.hIcon = LoadIconEx(IDI_UPLOAD); hContactMenu = Menu_AddContactMenuItem(&mi); + if (defaultService) + return; + UNSET_UID(mi); - mi.flags |= CMIF_SYSTEM | CMIF_UNICODE; + mi.root = hContactMenu; size_t count = Services.getCount(); + for (size_t i = 0; i < count; i++) { CCloudService *service = Services[i]; - if (!db_get_b(NULL, service->GetModule(), "IsEnable", TRUE)) - continue; - - CMStringA serviceName(CMStringDataFormat::FORMAT, "%s/%s/Upload", MODULE, service->GetModule()); - + CMStringA serviceName = MODULE; + serviceName.AppendFormat("/%s/Upload", service->GetModule()); mi.pszService = serviceName.GetBuffer(); + + mi.flags = CMIF_SYSTEM | CMIF_UNICODE; mi.name.w = (wchar_t*)service->GetText(); mi.position = i; mi.hIcolibItem = GetIconHandle(Services[i]->GetIconId()); @@ -44,19 +59,7 @@ void InitializeMenus() int OnPrebuildContactMenu(WPARAM hContact, LPARAM) { - bool bShow = false; - char *proto = GetContactProto(hContact); - if (proto) { - bool bHasIM = (CallProtoService(proto, PS_GETCAPS, PFLAGNUM_1, 0) & PF1_IMSEND) != 0; - if (bHasIM) { - bool isProtoOnline = CallProtoService(proto, PS_GETSTATUS, 0, 0) > ID_STATUS_OFFLINE; - WORD status = db_get_w(hContact, proto, "Status", ID_STATUS_OFFLINE); - bool canSendOffline = (CallProtoService(proto, PS_GETCAPS, PFLAGNUM_4, 0) & PF4_IMSENDOFFLINE) > 0; - if (isProtoOnline && (status != ID_STATUS_OFFLINE || canSendOffline)) - bShow = true; - } - } - Menu_ShowItem(hContactMenu, bShow); + Menu_ShowItem(hContactMenu, CanSendToContact(hContact)); return 0; }
\ No newline at end of file |