diff options
author | George Hazan <ghazan@miranda.im> | 2019-12-24 20:49:41 +0300 |
---|---|---|
committer | George Hazan <ghazan@miranda.im> | 2019-12-24 20:49:41 +0300 |
commit | 8adeaba742faf26339786d0a92e7f295911cd30b (patch) | |
tree | dd04239f51dc5f1a91853a70c50ac0d3bcdf24bf /protocols/Facebook/src | |
parent | 15357b4ba28cdc9085896da1855c428e1eb7c5e8 (diff) |
Facebook: default group added to options
Diffstat (limited to 'protocols/Facebook/src')
-rw-r--r-- | protocols/Facebook/src/options.cpp | 73 | ||||
-rw-r--r-- | protocols/Facebook/src/proto.cpp | 10 | ||||
-rw-r--r-- | protocols/Facebook/src/proto.h | 16 | ||||
-rw-r--r-- | protocols/Facebook/src/resource.h | 17 | ||||
-rw-r--r-- | protocols/Facebook/src/server.cpp | 1 |
5 files changed, 112 insertions, 5 deletions
diff --git a/protocols/Facebook/src/options.cpp b/protocols/Facebook/src/options.cpp new file mode 100644 index 0000000000..0abb338403 --- /dev/null +++ b/protocols/Facebook/src/options.cpp @@ -0,0 +1,73 @@ +/* + +Facebook plugin for Miranda NG +Copyright © 2019 Miranda NG team + +This program is free software: you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation, either version 2 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program. If not, see <http://www.gnu.org/licenses/>. + +*/ + +#include "stdafx.h" + +typedef CProtoDlgBase<FacebookProto> CFBDlgBase; + +class CFacebookAccOptsDlg : public CFBDlgBase +{ + CCtrlEdit edtGroup; + +public: + CFacebookAccOptsDlg(FacebookProto *pThis) : + CFBDlgBase(pThis, IDD_OPTIONS), + edtGroup(this, IDC_GROUP) + { + CreateLink(edtGroup, pThis->m_wszDefaultGroup); + } + + bool OnInitDialog() override + { + ptrA login(m_proto->getStringA(DBKEY_LOGIN)); + if (login != nullptr) + SetDlgItemTextA(m_hwnd, IDC_UN, login); + + ptrA password(m_proto->getStringA(DBKEY_PASS)); + if (password != nullptr) + SetDlgItemTextA(m_hwnd, IDC_PW, password); + return true; + } + + bool OnApply() override + { + char str[128]; + + GetDlgItemTextA(m_hwnd, IDC_UN, str, _countof(str)); + m_proto->setString(DBKEY_LOGIN, str); + + GetDlgItemTextA(m_hwnd, IDC_PW, str, _countof(str)); + m_proto->setString(DBKEY_PASS, str); + return true; + } +}; + +int FacebookProto::OnOptionsInit(WPARAM wParam, LPARAM) +{ + OPTIONSDIALOGPAGE odp = {}; + odp.position = -790000000; + odp.szTitle.w = m_tszUserName; + odp.szGroup.w = LPGENW("Network"); + + odp.szTab.w = LPGENW("Account"); + odp.pDialog = new CFacebookAccOptsDlg(this); + g_plugin.addOptions(wParam, &odp); + return 0; +}
\ No newline at end of file diff --git a/protocols/Facebook/src/proto.cpp b/protocols/Facebook/src/proto.cpp index 31b99b2100..66e35e4744 100644 --- a/protocols/Facebook/src/proto.cpp +++ b/protocols/Facebook/src/proto.cpp @@ -30,7 +30,8 @@ static int CompareUsers(const FacebookUser *p1, const FacebookUser *p2) FacebookProto::FacebookProto(const char *proto_name, const wchar_t *username) : PROTO<FacebookProto>(proto_name, username), - m_users(50, CompareUsers) + m_users(50, CompareUsers), + m_wszDefaultGroup(this, "DefaultGroup", L"Facebook") { for (auto &cc : AccContacts()) { CMStringA szId(getMStringA(cc, DBKEY_ID)); @@ -82,7 +83,14 @@ FacebookProto::FacebookProto(const char *proto_name, const wchar_t *username) : nlu.szDescriptiveName.w = descr; m_hNetlibUser = Netlib_RegisterUser(&nlu); + // Services CreateProtoService(PS_CREATEACCMGRUI, &FacebookProto::SvcCreateAccMgrUI); + + // Events + HookProtoEvent(ME_OPT_INITIALISE, &FacebookProto::OnOptionsInit); + + // Default group + Clist_GroupCreate(0, m_wszDefaultGroup); } FacebookProto::~FacebookProto() diff --git a/protocols/Facebook/src/proto.h b/protocols/Facebook/src/proto.h index a8ba6c6d39..219e569625 100644 --- a/protocols/Facebook/src/proto.h +++ b/protocols/Facebook/src/proto.h @@ -409,6 +409,11 @@ public: return m_szModuleName; } + ////////////////////////////////////////////////////////////////////////////////////// + // options + + CMOption<wchar_t *> m_wszDefaultGroup; // clist group to store contacts + //////////////////////////////////////////////////////////////////////////////////////// // PROTO_INTERFACE @@ -419,10 +424,15 @@ public: int SetStatus(int iNewStatus) override; - //////////////////////// + //////////////////////////////////////////////////////////////////////////////////////// + // Events - // Services - INT_PTR __cdecl SvcCreateAccMgrUI(WPARAM, LPARAM); + int __cdecl OnOptionsInit(WPARAM, LPARAM); + + //////////////////////////////////////////////////////////////////////////////////////// + // Services + + INT_PTR __cdecl SvcCreateAccMgrUI(WPARAM, LPARAM); }; struct CMPlugin : public ACCPROTOPLUGIN<FacebookProto> diff --git a/protocols/Facebook/src/resource.h b/protocols/Facebook/src/resource.h index a4091c5c95..2db5b9fc2e 100644 --- a/protocols/Facebook/src/resource.h +++ b/protocols/Facebook/src/resource.h @@ -1,8 +1,23 @@ //{{NO_DEPENDENCIES}} // Microsoft Visual C++ generated include file. -// Used by D:\Development\Miranda NG\Miranda NG\protocols\FacebookRM\res\facebook.rc +// Used by w:\miranda-ng\protocols\Facebook\res\facebook.rc // #define IDI_FACEBOOK 101 +#define IDD_OPTIONS 102 #define IDD_FACEBOOKACCOUNT 111 +#define IDC_EDIT1 1000 #define IDC_UN 1001 #define IDC_PW 1002 +#define IDC_NEWACCOUNTLINK 1003 +#define IDC_GROUP 1004 + +// Next default values for new objects +// +#ifdef APSTUDIO_INVOKED +#ifndef APSTUDIO_READONLY_SYMBOLS +#define _APS_NEXT_RESOURCE_VALUE 102 +#define _APS_NEXT_COMMAND_VALUE 40001 +#define _APS_NEXT_CONTROL_VALUE 1004 +#define _APS_NEXT_SYMED_VALUE 101 +#endif +#endif diff --git a/protocols/Facebook/src/server.cpp b/protocols/Facebook/src/server.cpp index 7d48bd0ad3..ee2820a521 100644 --- a/protocols/Facebook/src/server.cpp +++ b/protocols/Facebook/src/server.cpp @@ -63,6 +63,7 @@ bool FacebookProto::RefreshContacts() hContact = db_add_contact(); Proto_AddToContact(hContact, m_szModuleName); setWString(hContact, DBKEY_ID, wszId); + Clist_SetGroup(hContact, m_wszDefaultGroup); m_users.insert(new FacebookUser(id, hContact)); } |