diff options
-rw-r--r-- | plugins/CloudFile/res/resource.rc | 13 | ||||
-rw-r--r-- | plugins/CloudFile/src/Services/dropbox_service.cpp | 4 | ||||
-rw-r--r-- | plugins/CloudFile/src/Services/dropbox_service.h | 4 | ||||
-rw-r--r-- | plugins/CloudFile/src/Services/google_service.cpp | 4 | ||||
-rw-r--r-- | plugins/CloudFile/src/Services/google_service.h | 2 | ||||
-rw-r--r-- | plugins/CloudFile/src/Services/microsoft_api.h | 4 | ||||
-rw-r--r-- | plugins/CloudFile/src/Services/microsoft_service.cpp | 4 | ||||
-rw-r--r-- | plugins/CloudFile/src/Services/microsoft_service.h | 2 | ||||
-rw-r--r-- | plugins/CloudFile/src/Services/yandex_service.cpp | 4 | ||||
-rw-r--r-- | plugins/CloudFile/src/Services/yandex_service.h | 2 | ||||
-rw-r--r-- | plugins/CloudFile/src/cloud_service.cpp | 3 | ||||
-rw-r--r-- | plugins/CloudFile/src/cloud_service.h | 3 | ||||
-rw-r--r-- | plugins/CloudFile/src/menus.cpp | 6 | ||||
-rw-r--r-- | plugins/CloudFile/src/options.cpp | 60 | ||||
-rw-r--r-- | plugins/CloudFile/src/options.h | 6 | ||||
-rw-r--r-- | plugins/CloudFile/src/resource.h | 2 | ||||
-rw-r--r-- | plugins/CloudFile/src/srmm.cpp | 7 |
17 files changed, 103 insertions, 27 deletions
diff --git a/plugins/CloudFile/res/resource.rc b/plugins/CloudFile/res/resource.rc index 3e7b688e25..93713dece3 100644 --- a/plugins/CloudFile/res/resource.rc +++ b/plugins/CloudFile/res/resource.rc @@ -83,13 +83,15 @@ STYLE DS_SETFONT | DS_FIXEDSYS | WS_CHILD EXSTYLE WS_EX_CONTROLPARENT FONT 8, "MS Shell Dlg", 0, 0, 0x1 BEGIN - GROUPBOX "Download link",-1,5,5,297,57 + GROUPBOX "Download link",IDC_STATIC,5,5,297,57 CONTROL "Autosend download link to contact",IDC_URL_AUTOSEND, - "Button",BS_AUTORADIOBUTTON,15,19,282,10 + "Button",BS_AUTORADIOBUTTON,11,19,282,10 CONTROL "Paste download link into message input area",IDC_URL_COPYTOMIA, - "Button",BS_AUTORADIOBUTTON,15,32,282,10 + "Button",BS_AUTORADIOBUTTON,11,32,282,10 CONTROL "Copy download link to clipboard",IDC_URL_COPYTOCB, - "Button",BS_AUTOCHECKBOX | WS_TABSTOP,15,45,282,10 + "Button",BS_AUTOCHECKBOX | WS_TABSTOP,11,45,282,10 + GROUPBOX "Services",IDC_STATIC,5,65,297,96 + CONTROL "",IDC_SERVICES,"SysListView32",LVS_REPORT | LVS_ALIGNLEFT | LVS_NOCOLUMNHEADER | WS_BORDER | WS_TABSTOP,11,76,285,76 END IDD_OAUTH DIALOGEX 0, 0, 193, 83 @@ -135,7 +137,8 @@ BEGIN BEGIN LEFTMARGIN, 5 RIGHTMARGIN, 302 - VERTGUIDE, 15 + VERTGUIDE, 11 + VERTGUIDE, 296 TOPMARGIN, 5 BOTTOMMARGIN, 229 END diff --git a/plugins/CloudFile/src/Services/dropbox_service.cpp b/plugins/CloudFile/src/Services/dropbox_service.cpp index 10fbf7ef40..70ff1deb96 100644 --- a/plugins/CloudFile/src/Services/dropbox_service.cpp +++ b/plugins/CloudFile/src/Services/dropbox_service.cpp @@ -16,9 +16,9 @@ const wchar_t* CDropboxService::GetText() const return L"Dropbox"; } -HANDLE CDropboxService::GetIcon() const +int CDropboxService::GetIconId() const { - return GetIconHandle(IDI_DROPBOX); + return IDI_DROPBOX; } bool CDropboxService::IsLoggedIn() diff --git a/plugins/CloudFile/src/Services/dropbox_service.h b/plugins/CloudFile/src/Services/dropbox_service.h index 93b2fb53d3..362a9751fc 100644 --- a/plugins/CloudFile/src/Services/dropbox_service.h +++ b/plugins/CloudFile/src/Services/dropbox_service.h @@ -21,8 +21,8 @@ public: const char* GetModule() const; const wchar_t* GetText() const; - HANDLE GetIcon() const; - + int GetIconId() const; + bool IsLoggedIn(); void Login(); void Logout(); diff --git a/plugins/CloudFile/src/Services/google_service.cpp b/plugins/CloudFile/src/Services/google_service.cpp index f7ab294135..d378f8bf55 100644 --- a/plugins/CloudFile/src/Services/google_service.cpp +++ b/plugins/CloudFile/src/Services/google_service.cpp @@ -16,9 +16,9 @@ const wchar_t* CGDriveService::GetText() const return L"GDrive"; } -HANDLE CGDriveService::GetIcon() const +int CGDriveService::GetIconId() const { - return GetIconHandle(IDI_GDRIVE); + return IDI_GDRIVE; } bool CGDriveService::IsLoggedIn() diff --git a/plugins/CloudFile/src/Services/google_service.h b/plugins/CloudFile/src/Services/google_service.h index d9c99009c6..a35827eaf8 100644 --- a/plugins/CloudFile/src/Services/google_service.h +++ b/plugins/CloudFile/src/Services/google_service.h @@ -19,7 +19,7 @@ public: const char* GetModule() const; const wchar_t* GetText() const; - HANDLE GetIcon() const; + int GetIconId() const; bool IsLoggedIn(); void Login(); diff --git a/plugins/CloudFile/src/Services/microsoft_api.h b/plugins/CloudFile/src/Services/microsoft_api.h index b7f6ebd073..0717a7a00a 100644 --- a/plugins/CloudFile/src/Services/microsoft_api.h +++ b/plugins/CloudFile/src/Services/microsoft_api.h @@ -31,8 +31,8 @@ namespace OneDriveAPI AddHeader("Content-Type", "application/x-www-form-urlencoded"); CMStringA data(CMStringDataFormat::FORMAT, - "client_id=%s&client_secret=%s&grant_type=refresh_token&refresh_token=%s", - MS_APP_ID, MS_CLIENT_SECRET, refreshToken); + "client_id=%s&grant_type=refresh_token&refresh_token=%s", + MS_APP_ID, refreshToken); SetData(data.GetBuffer(), data.GetLength()); } }; diff --git a/plugins/CloudFile/src/Services/microsoft_service.cpp b/plugins/CloudFile/src/Services/microsoft_service.cpp index d002db45e6..d988ec222a 100644 --- a/plugins/CloudFile/src/Services/microsoft_service.cpp +++ b/plugins/CloudFile/src/Services/microsoft_service.cpp @@ -16,9 +16,9 @@ const wchar_t* COneDriveService::GetText() const return L"OneDrive"; } -HANDLE COneDriveService::GetIcon() const +int COneDriveService::GetIconId() const { - return GetIconHandle(IDI_ONEDRIVE); + return IDI_ONEDRIVE; } bool COneDriveService::IsLoggedIn() diff --git a/plugins/CloudFile/src/Services/microsoft_service.h b/plugins/CloudFile/src/Services/microsoft_service.h index bf689ee8c2..7853378e07 100644 --- a/plugins/CloudFile/src/Services/microsoft_service.h +++ b/plugins/CloudFile/src/Services/microsoft_service.h @@ -19,7 +19,7 @@ public: const char* GetModule() const; const wchar_t* GetText() const; - HANDLE GetIcon() const; + int GetIconId() const; bool IsLoggedIn(); void Login(); diff --git a/plugins/CloudFile/src/Services/yandex_service.cpp b/plugins/CloudFile/src/Services/yandex_service.cpp index 2d08aa63a2..9ed788fd4c 100644 --- a/plugins/CloudFile/src/Services/yandex_service.cpp +++ b/plugins/CloudFile/src/Services/yandex_service.cpp @@ -16,9 +16,9 @@ const wchar_t* CYandexService::GetText() const return L"Яндекс.Диск"; } -HANDLE CYandexService::GetIcon() const +int CYandexService::GetIconId() const { - return GetIconHandle(IDI_YADISK); + return IDI_YADISK; } bool CYandexService::IsLoggedIn() diff --git a/plugins/CloudFile/src/Services/yandex_service.h b/plugins/CloudFile/src/Services/yandex_service.h index a3a84735c4..e3b122ffa1 100644 --- a/plugins/CloudFile/src/Services/yandex_service.h +++ b/plugins/CloudFile/src/Services/yandex_service.h @@ -19,7 +19,7 @@ public: const char* GetModule() const; const wchar_t* GetText() const; - HANDLE GetIcon() const; + int GetIconId() const; bool IsLoggedIn(); void Login(); diff --git a/plugins/CloudFile/src/cloud_service.cpp b/plugins/CloudFile/src/cloud_service.cpp index ee2bebe4d4..3f35bc1d4b 100644 --- a/plugins/CloudFile/src/cloud_service.cpp +++ b/plugins/CloudFile/src/cloud_service.cpp @@ -20,6 +20,9 @@ void InitServices() for (size_t i = 0; i < count; i++) { CCloudService *service = Services[i]; + if (!db_get_b(NULL, service->GetModule(), "IsEnable", TRUE)) + continue; + CMStringA moduleName(CMStringDataFormat::FORMAT, "%s/%s", MODULE, service->GetModule()); pd.type = PROTOTYPE_VIRTUAL; pd.szName = moduleName.GetBuffer(); diff --git a/plugins/CloudFile/src/cloud_service.h b/plugins/CloudFile/src/cloud_service.h index 8d52e4cea0..705330e386 100644 --- a/plugins/CloudFile/src/cloud_service.h +++ b/plugins/CloudFile/src/cloud_service.h @@ -4,6 +4,7 @@ class CCloudService { protected: + int id; HNETLIBUSER hConnection; // utils @@ -23,7 +24,7 @@ public: virtual const char* GetModule() const = 0; virtual const wchar_t* GetText() const = 0; - virtual HANDLE GetIcon() const = 0; + virtual int GetIconId() const = 0; virtual bool IsLoggedIn() = 0; virtual void Login() = 0; diff --git a/plugins/CloudFile/src/menus.cpp b/plugins/CloudFile/src/menus.cpp index d9a6db9b3e..804facffd5 100644 --- a/plugins/CloudFile/src/menus.cpp +++ b/plugins/CloudFile/src/menus.cpp @@ -35,11 +35,15 @@ void InitializeMenus() 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()); + mi.pszService = serviceName.GetBuffer(); mi.name.w = (wchar_t*)service->GetText(); mi.position = i; - mi.hIcolibItem = Services[i]->GetIcon(); + mi.hIcolibItem = GetIconHandle(Services[i]->GetIconId()); Menu_AddContactMenuItem(&mi); CreateServiceFunctionObj(mi.pszService, UploadMenuCommand, service); } diff --git a/plugins/CloudFile/src/options.cpp b/plugins/CloudFile/src/options.cpp index 48a0f3c995..e09b659bc1 100644 --- a/plugins/CloudFile/src/options.cpp +++ b/plugins/CloudFile/src/options.cpp @@ -4,7 +4,8 @@ COptionsMain::COptionsMain() : CPluginDlgBase(hInstance, IDD_OPTIONS_MAIN, MODULE), m_urlAutoSend(this, IDC_URL_AUTOSEND), m_urlPasteToMessageInputArea(this, IDC_URL_COPYTOMIA), - m_urlCopyToClipboard(this, IDC_URL_COPYTOCB) + m_urlCopyToClipboard(this, IDC_URL_COPYTOCB), + m_services(this, IDC_SERVICES), isServiceListInit(false) { CreateLink(m_urlAutoSend, "UrlAutoSend", DBVT_BYTE, 1); CreateLink(m_urlPasteToMessageInputArea, "UrlPasteToMessageInputArea", DBVT_BYTE, 0); @@ -14,6 +15,59 @@ COptionsMain::COptionsMain() void COptionsMain::OnInitDialog() { CDlgBase::OnInitDialog(); + + m_services.SetExtendedListViewStyle(LVS_EX_FULLROWSELECT | LVS_EX_CHECKBOXES | LVS_EX_INFOTIP); + + m_services.AddColumn(0, TranslateT("Account name"), 50); + + size_t count = Services.getCount(); + for (size_t i = 0; i < count; i++) { + CCloudService *service = Services[i]; + + int iItem = m_services.AddItem(mir_wstrdup(service->GetText()), -1, (LPARAM)service); + //m_services.SetItem(iItem, 1, mir_a2u(service->GetModule)); + int isEnable = db_get_b(NULL, service->GetModule(), "IsEnable", TRUE); + m_services.SetCheckState(iItem, isEnable); + } + + m_services.SetColumnWidth(0, LVSCW_AUTOSIZE_USEHEADER); + + isServiceListInit = true; +} + +void COptionsMain::OnApply() +{ + int count = m_services.GetItemCount(); + for (int iItem = 0; iItem < count; iItem++) + { + CCloudService *service = (CCloudService*)m_services.GetItemData(iItem); + + int isEnable = m_services.GetCheckState(iItem); + db_set_b(NULL, service->GetModule(), "IsEnable", isEnable); + } +} + +INT_PTR COptionsMain::DlgProc(UINT msg, WPARAM wParam, LPARAM lParam) +{ + switch (msg) + { + case WM_NOTIFY: + { + LPNMHDR lpnmHdr = (LPNMHDR)lParam; + if (lpnmHdr->idFrom == (UINT_PTR)m_services.GetCtrlId() && lpnmHdr->code == LVN_ITEMCHANGED) + { + LPNMLISTVIEW pnmv = (LPNMLISTVIEW)lParam; + if (pnmv->uChanged & LVIF_STATE && pnmv->uNewState & LVIS_STATEIMAGEMASK) + { + if (isServiceListInit) + NotifyChange(); + } + } + } + break; + } + + return CDlgBase::DlgProc(msg, wParam, lParam); } ///////////////////////////////////////////////////////////////////////////////// @@ -23,9 +77,9 @@ int OnOptionsInitialized(WPARAM wParam, LPARAM) OPTIONSDIALOGPAGE odp = { 0 }; odp.szTitle.w = _A2W(MODULE); odp.flags = ODPF_BOLDGROUPS | ODPF_UNICODE | ODPF_DONTTRANSLATE; - odp.szGroup.w = LPGENW("Network"); + odp.szGroup.w = LPGENW("Services"); - odp.szTab.w = LPGENW("General"); + //odp.szTab.w = LPGENW("General"); odp.pDialog = new COptionsMain(); Options_AddPage(wParam, &odp); diff --git a/plugins/CloudFile/src/options.h b/plugins/CloudFile/src/options.h index 3fb20157b1..d6f5e7caaf 100644 --- a/plugins/CloudFile/src/options.h +++ b/plugins/CloudFile/src/options.h @@ -8,8 +8,14 @@ private: CCtrlCheck m_urlPasteToMessageInputArea; CCtrlCheck m_urlCopyToClipboard; + bool isServiceListInit; + CCtrlListView m_services; + protected: void OnInitDialog(); + void OnApply(); + + INT_PTR DlgProc(UINT msg, WPARAM wParam, LPARAM lParam); public: COptionsMain(); diff --git a/plugins/CloudFile/src/resource.h b/plugins/CloudFile/src/resource.h index db382f9fb1..4360fd84b5 100644 --- a/plugins/CloudFile/src/resource.h +++ b/plugins/CloudFile/src/resource.h @@ -17,6 +17,8 @@ #define IDC_URL_COPYTOCB 1002 #define IDC_URL_COPYTOMIA 1003 #define IDC_URL_AUTOSEND 1004 +#define IDC_ACCOUNTS 1011 +#define IDC_SERVICES 1011 // Next default values for new objects // diff --git a/plugins/CloudFile/src/srmm.cpp b/plugins/CloudFile/src/srmm.cpp index e903d90721..d1b55c0ec0 100644 --- a/plugins/CloudFile/src/srmm.cpp +++ b/plugins/CloudFile/src/srmm.cpp @@ -32,7 +32,7 @@ int OnSrmmWindowOpened(WPARAM, LPARAM lParam) if (!isProtoOnline || (status == ID_STATUS_OFFLINE && !canSendOffline)) bbd.bbbFlags = BBSF_DISABLED; - //Srmm_SetButtonState(ev->hContact, &bbd); + Srmm_SetButtonState(ev->hContact, &bbd); } return 0; @@ -54,8 +54,11 @@ int OnSrmmButtonPressed(WPARAM, LPARAM lParam) for (size_t i = 0; i < count; i++) { CCloudService *service = Services[i]; + if (!db_get_b(NULL, service->GetModule(), "IsEnable", TRUE)) + continue; + InsertMenu(hMenu, i, MF_STRING, i + 1, service->GetText()); - //HBITMAP hBitmap = (HBITMAP)LoadImage(hInstance, MAKEINTRESOURCE(IDI_UPLOAD), IMAGE_ICON, 16, 16, 0); + //HBITMAP hBitmap = (HBITMAP)LoadImage(hInstance, MAKEINTRESOURCE(service->GetIconId()), IMAGE_ICON, 16, 16, 0); //SetMenuItemBitmaps(hMenu, i, MF_BITMAP, hBitmap, hBitmap); } |