From 2dda26c2d63fb543d06f046a5908ba43a5fd716e Mon Sep 17 00:00:00 2001 From: Alexander Lantsev Date: Fri, 3 Apr 2015 18:25:32 +0000 Subject: SkypeWeb: moved to core ui git-svn-id: http://svn.miranda-ng.org/main/trunk@12590 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- protocols/SkypeWeb/SkypeWeb_12.vcxproj | 12 ++-- protocols/SkypeWeb/SkypeWeb_12.vcxproj.filters | 16 +++-- protocols/SkypeWeb/res/resource.rc | 16 +---- protocols/SkypeWeb/src/common.h | 3 + protocols/SkypeWeb/src/skype_accounts.cpp | 11 +-- protocols/SkypeWeb/src/skype_dialogs.h | 50 ++++++++++++++ protocols/SkypeWeb/src/skype_options.cpp | 94 +++++++------------------- protocols/SkypeWeb/src/skype_options.h | 30 ++++++++ protocols/SkypeWeb/src/skype_proto.h | 6 +- 9 files changed, 133 insertions(+), 105 deletions(-) create mode 100644 protocols/SkypeWeb/src/skype_dialogs.h create mode 100644 protocols/SkypeWeb/src/skype_options.h diff --git a/protocols/SkypeWeb/SkypeWeb_12.vcxproj b/protocols/SkypeWeb/SkypeWeb_12.vcxproj index 7f776adc57..32dcf3f02c 100644 --- a/protocols/SkypeWeb/SkypeWeb_12.vcxproj +++ b/protocols/SkypeWeb/SkypeWeb_12.vcxproj @@ -207,15 +207,17 @@ - + - - + + + + @@ -238,8 +240,8 @@ - - + + diff --git a/protocols/SkypeWeb/SkypeWeb_12.vcxproj.filters b/protocols/SkypeWeb/SkypeWeb_12.vcxproj.filters index e7e11629e4..ee77cf1361 100644 --- a/protocols/SkypeWeb/SkypeWeb_12.vcxproj.filters +++ b/protocols/SkypeWeb/SkypeWeb_12.vcxproj.filters @@ -63,15 +63,21 @@ Header Files\requests - + Header Files\requests Header Files\requests - + Header Files\requests + + Header Files + + + Header Files + @@ -119,11 +125,11 @@ Source Files - + Source Files - - Source Files + + Source Files diff --git a/protocols/SkypeWeb/res/resource.rc b/protocols/SkypeWeb/res/resource.rc index b59bd87258..7a2074df00 100644 --- a/protocols/SkypeWeb/res/resource.rc +++ b/protocols/SkypeWeb/res/resource.rc @@ -108,7 +108,7 @@ FONT 8, "MS Shell Dlg", 400, 0, 0x1 BEGIN GROUPBOX "Account",IDC_STATIC,7,7,296,63,NOT WS_VISIBLE LTEXT "Skypename:",IDC_STATIC,12,19,69,11 - EDITTEXT IDC_SKYPENAME, 81, 17, 217, 12, ES_AUTOHSCROLL + EDITTEXT IDC_SKYPENAME,81,17,217,12,ES_AUTOHSCROLL LTEXT "Password:",IDC_STATIC,12,34,69,8 EDITTEXT IDC_PASSWORD,81,33,217,12,ES_PASSWORD | ES_AUTOHSCROLL LTEXT "Default group:",IDC_STATIC,12,51,69,12 @@ -139,26 +139,14 @@ GUIDELINES DESIGNINFO BEGIN IDD_ACCOUNT_MANAGER, DIALOG BEGIN - VERTGUIDE, 49 - BOTTOMMARGIN, 112 END IDD_OPTIONS_MAIN, DIALOG BEGIN - LEFTMARGIN, 7 - RIGHTMARGIN, 303 - VERTGUIDE, 12 - VERTGUIDE, 81 - VERTGUIDE, 298 - TOPMARGIN, 7 - BOTTOMMARGIN, 228 END - IDD_PASSWORD, DIALOG + IDD_PASSWORD_EDITOR, DIALOG BEGIN - RIGHTMARGIN, 204 - VERTGUIDE, 7 - BOTTOMMARGIN, 70 END END #endif // APSTUDIO_INVOKED diff --git a/protocols/SkypeWeb/src/common.h b/protocols/SkypeWeb/src/common.h index e2f4ef2f95..84060c4eba 100644 --- a/protocols/SkypeWeb/src/common.h +++ b/protocols/SkypeWeb/src/common.h @@ -36,6 +36,7 @@ #include #include #include +#include struct CSkypeProto; @@ -43,6 +44,8 @@ struct CSkypeProto; #include "resource.h" #include "skype_icons.h" #include "skype_menus.h" +#include "skype_dialogs.h" +#include "skype_options.h" #include "http_request.h" #include "requests\login.h" #include "requests\logout.h" diff --git a/protocols/SkypeWeb/src/skype_accounts.cpp b/protocols/SkypeWeb/src/skype_accounts.cpp index 4b1ae6d536..6a383045f2 100644 --- a/protocols/SkypeWeb/src/skype_accounts.cpp +++ b/protocols/SkypeWeb/src/skype_accounts.cpp @@ -24,12 +24,8 @@ int CSkypeProto::UninitAccount(CSkypeProto *proto) CSkypeProto* CSkypeProto::GetContactAccount(MCONTACT hContact) { for (int i = 0; i < Accounts.getCount(); i++) - { if (mir_strcmpi(GetContactProto(hContact), Accounts[i]->m_szModuleName) == 0) - { return Accounts[i]; - } - } return NULL; } @@ -42,10 +38,5 @@ int CSkypeProto::OnAccountLoaded(WPARAM, LPARAM) INT_PTR CSkypeProto::OnAccountManagerInit(WPARAM, LPARAM lParam) { - return (INT_PTR)CreateDialogParam( - g_hInstance, - MAKEINTRESOURCE(IDD_ACCOUNT_MANAGER), - (HWND)lParam, - CSkypeProto::MainOptionsProc, - (LPARAM)this); + return (INT_PTR)(CSkypeOptionsMain::CreateAccountManagerPage(this, (HWND)lParam))->GetHwnd(); } \ No newline at end of file diff --git a/protocols/SkypeWeb/src/skype_dialogs.h b/protocols/SkypeWeb/src/skype_dialogs.h new file mode 100644 index 0000000000..ee834bcd35 --- /dev/null +++ b/protocols/SkypeWeb/src/skype_dialogs.h @@ -0,0 +1,50 @@ +#ifndef _SKYPE_DIALOGS_H_ +#define _SKYPE_DIALOGS_H_ + +class CSkypeDlgBase : public CProtoDlgBase +{ +private: + typedef CProtoDlgBase CSuper; + +protected: + __inline CSkypeDlgBase(CSkypeProto *proto, int idDialog, HWND parent, bool show_label = true) : + CSuper(proto, idDialog, parent, show_label) { } +}; + +class CSkypePasswordEditor : public CSkypeDlgBase +{ +private: + typedef CSkypeDlgBase CSuper; + + CCtrlEdit m_password; + CCtrlCheck m_savePermanently; + + CCtrlButton m_ok; + +protected: + void OnInitDialog() + { + SendMessage(m_password.GetHwnd(), EM_LIMITTEXT, 20, 0); + } + + void OnOk(CCtrlButton*) + { + /*if (m_savePermanently.Enabled()) + m_proto->setString("Password", m_password.GetTextA()); + if (m_proto->password != NULL) + mir_free(m_proto->password); + m_proto->password = mir_utf8encodeW(m_password.GetText()); + */ + EndDialog(m_hwnd, 1); + } + +public: + CSkypePasswordEditor(CSkypeProto *proto) : + CSuper(proto, IDD_PASSWORD_EDITOR, NULL, false), m_ok(this, IDOK), + m_password(this, IDC_PASSWORD), m_savePermanently(this, IDC_SAVEPERMANENTLY) + { + m_ok.OnClick = Callback(this, &CSkypePasswordEditor::OnOk); + } +}; + +#endif //_SKYPE_DIALOGS_H_ \ No newline at end of file diff --git a/protocols/SkypeWeb/src/skype_options.cpp b/protocols/SkypeWeb/src/skype_options.cpp index ae8c1b9c4e..06cbbcf001 100644 --- a/protocols/SkypeWeb/src/skype_options.cpp +++ b/protocols/SkypeWeb/src/skype_options.cpp @@ -1,77 +1,30 @@ #include "common.h" -INT_PTR CSkypeProto::MainOptionsProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) +CSkypeOptionsMain::CSkypeOptionsMain(CSkypeProto *proto, int idDialog, HWND hwndParent) + : CSuper(proto, idDialog, hwndParent, false), + m_skypename(this, IDC_SKYPENAME), m_password(this, IDC_PASSWORD), + m_group(this, IDC_GROUP) { - CSkypeProto *proto = (CSkypeProto*)GetWindowLongPtr(hwnd, GWLP_USERDATA); - - switch (uMsg) - { - case WM_INITDIALOG: - TranslateDialogDefault(hwnd); - { - proto = (CSkypeProto*)lParam; - SetWindowLongPtr(hwnd, GWLP_USERDATA, lParam); - - ptrA login(proto->getStringA(SKYPE_SETTINGS_ID)); - SetDlgItemTextA(hwnd, IDC_SKYPENAME, login); - SendDlgItemMessage(hwnd, IDC_SKYPENAME, EM_LIMITTEXT, 32, 0); - - ptrA password(proto->getStringA("Password")); - SetDlgItemTextA(hwnd, IDC_PASSWORD, password); - SendDlgItemMessage(hwnd, IDC_PASSWORD, EM_LIMITTEXT, 20, 0); - - ptrT group(proto->getTStringA(SKYPE_SETTINGS_GROUP)); - SetDlgItemText(hwnd, IDC_GROUP, group ? group : _T("Skype")); - SendDlgItemMessage(hwnd, IDC_GROUP, EM_LIMITTEXT, 64, 0); - } - return TRUE; - - case WM_COMMAND: - { - switch (LOWORD(wParam)) - { - case IDC_SKYPENAME: - case IDC_GROUP: - case IDC_PASSWORD: - if ((HWND)lParam == GetFocus()) - { - if (HIWORD(wParam) != EN_CHANGE) return 0; - SendMessage(GetParent(hwnd), PSM_CHANGED, 0, 0); - } - break; - } - } - break; - - case WM_NOTIFY: - if (((NMHDR*)lParam)->code == PSN_APPLY) - { - char skypename[32]; - GetDlgItemTextA(hwnd, IDC_SKYPENAME, skypename, SIZEOF(skypename)); - proto->setString(SKYPE_SETTINGS_ID, skypename); + CreateLink(m_skypename, SKYPE_SETTINGS_ID, _T("")); + CreateLink(m_password, "Password", _T("")); + CreateLink(m_group, SKYPE_SETTINGS_GROUP, _T("Skype")); +} - char password[20]; - GetDlgItemTextA(hwnd, IDC_PASSWORD, password, SIZEOF(password)); - proto->setString(SKYPE_SETTINGS_PASSWORD, password); +void CSkypeOptionsMain::OnInitDialog() +{ + CSuper::OnInitDialog(); - TCHAR group[64]; - GetDlgItemText(hwnd, IDC_GROUP, group, SIZEOF(group)); - if (_tcslen(group) > 0) - { - proto->setTString(SKYPE_SETTINGS_GROUP, group); - Clist_CreateGroup(0, group); - } - else - { - proto->delSetting(NULL, SKYPE_SETTINGS_GROUP); - } + SendMessage(m_skypename.GetHwnd(), EM_LIMITTEXT, 32, 0); + SendMessage(m_password.GetHwnd(), EM_LIMITTEXT, 20, 0); + SendMessage(m_group.GetHwnd(), EM_LIMITTEXT, 64, 0); +} - return TRUE; - } - break; - } - return FALSE; +void CSkypeOptionsMain::OnApply() +{ + TCHAR *group = m_group.GetText(); + if (mir_tstrlen(group) > 0 && Clist_GroupExists(group)) + Clist_CreateGroup(0, group); } int CSkypeProto::OnOptionsInit(WPARAM wParam, LPARAM) @@ -81,13 +34,16 @@ int CSkypeProto::OnOptionsInit(WPARAM wParam, LPARAM) OPTIONSDIALOGPAGE odp = { sizeof(odp) }; odp.hInstance = g_hInstance; odp.pszTitle = title; - odp.dwInitParam = (LPARAM)this; + //odp.dwInitParam = (LPARAM)this; odp.flags = ODPF_BOLDGROUPS; odp.pszGroup = LPGEN("Network"); odp.pszTab = LPGEN("Account"); odp.pszTemplate = MAKEINTRESOURCEA(IDD_OPTIONS_MAIN); - odp.pfnDlgProc = MainOptionsProc; + odp.pfnDlgProc = CSkypeOptionsMain::DynamicDlgProc; + odp.dwInitParam = (LPARAM)&SkypeMainOptionsParam; + SkypeMainOptionsParam.create = CSkypeOptionsMain::CreateOptionsPage; + SkypeMainOptionsParam.param = this; Options_AddPage(wParam, &odp); mir_free(title); diff --git a/protocols/SkypeWeb/src/skype_options.h b/protocols/SkypeWeb/src/skype_options.h new file mode 100644 index 0000000000..56d08aedd8 --- /dev/null +++ b/protocols/SkypeWeb/src/skype_options.h @@ -0,0 +1,30 @@ +#ifndef _SKYPE_OPTIONS_H_ +#define _SKYPE_OPTIONS_H_ + +class CSkypeOptionsMain : public CSkypeDlgBase +{ +private: + typedef CSkypeDlgBase CSuper; + + CCtrlEdit m_skypename; + CCtrlEdit m_password; + CCtrlEdit m_group; + +protected: + CSkypeOptionsMain(CSkypeProto *proto, int idDialog, HWND hwndParent = NULL); + + void OnInitDialog(); + void OnApply(); + +public: + static CDlgBase *CreateAccountManagerPage(void *param, HWND owner) + { + CSkypeOptionsMain *page = new CSkypeOptionsMain((CSkypeProto*)param, IDD_ACCOUNT_MANAGER, owner); + page->Show(); + return page; + } + + static CDlgBase *CreateOptionsPage(void *param) { return new CSkypeOptionsMain((CSkypeProto*)param, IDD_OPTIONS_MAIN); } +}; + +#endif //_SKYPE_OPTIONS_H_ \ No newline at end of file diff --git a/protocols/SkypeWeb/src/skype_proto.h b/protocols/SkypeWeb/src/skype_proto.h index 5d86f4ce92..add8444093 100644 --- a/protocols/SkypeWeb/src/skype_proto.h +++ b/protocols/SkypeWeb/src/skype_proto.h @@ -3,8 +3,10 @@ typedef void(CSkypeProto::*SkypeResponseCallback)(const NETLIBHTTPREQUEST *response); -struct CSkypeProto : public PROTO < CSkypeProto > +struct CSkypeProto : public PROTO { + friend CSkypePasswordEditor; + public: ////////////////////////////////////////////////////////////////////////////////////// @@ -116,7 +118,7 @@ private: int OnInitStatusMenu(); // options - static INT_PTR CALLBACK MainOptionsProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam); + CSkypeDlgBase::CreateParam SkypeMainOptionsParam; int __cdecl OnOptionsInit(WPARAM wParam, LPARAM lParam); -- cgit v1.2.3