summaryrefslogtreecommitdiff
path: root/protocols
diff options
context:
space:
mode:
authorGeorge Hazan <ghazan@miranda.im>2019-12-24 20:49:41 +0300
committerGeorge Hazan <ghazan@miranda.im>2019-12-24 20:49:41 +0300
commit8adeaba742faf26339786d0a92e7f295911cd30b (patch)
treedd04239f51dc5f1a91853a70c50ac0d3bcdf24bf /protocols
parent15357b4ba28cdc9085896da1855c428e1eb7c5e8 (diff)
Facebook: default group added to options
Diffstat (limited to 'protocols')
-rw-r--r--protocols/Facebook/facebook.vcxproj3
-rw-r--r--protocols/Facebook/res/facebook.rc69
-rw-r--r--protocols/Facebook/src/options.cpp73
-rw-r--r--protocols/Facebook/src/proto.cpp10
-rw-r--r--protocols/Facebook/src/proto.h16
-rw-r--r--protocols/Facebook/src/resource.h17
-rw-r--r--protocols/Facebook/src/server.cpp1
7 files changed, 180 insertions, 9 deletions
diff --git a/protocols/Facebook/facebook.vcxproj b/protocols/Facebook/facebook.vcxproj
index 25c2fbe25a..ab578823ab 100644
--- a/protocols/Facebook/facebook.vcxproj
+++ b/protocols/Facebook/facebook.vcxproj
@@ -33,4 +33,7 @@
<Project>{e2a369cd-eda3-414f-8ad0-e732cd7ee68c}</Project>
</ProjectReference>
</ItemGroup>
+ <ItemGroup>
+ <Image Include="res\facebook.ico" />
+ </ItemGroup>
</Project> \ No newline at end of file
diff --git a/protocols/Facebook/res/facebook.rc b/protocols/Facebook/res/facebook.rc
index 38a251d644..41d5e87fb3 100644
--- a/protocols/Facebook/res/facebook.rc
+++ b/protocols/Facebook/res/facebook.rc
@@ -35,6 +35,12 @@ BEGIN
"winres.h\0"
END
+3 TEXTINCLUDE
+BEGIN
+ "\r\n"
+ "\0"
+END
+
#endif // APSTUDIO_INVOKED
@@ -45,7 +51,6 @@ END
// Icon with lowest ID value placed first to ensure application icon
// remains consistent on all systems.
-
IDI_FACEBOOK ICON "facebook.ico"
@@ -54,16 +59,72 @@ IDI_FACEBOOK ICON "facebook.ico"
// Dialog
//
-IDD_FACEBOOKACCOUNT DIALOGEX 0, 0, 186, 134
+IDD_FACEBOOKACCOUNT DIALOGEX 0, 0, 186, 52
STYLE DS_SETFONT | DS_FIXEDSYS | WS_CHILD
EXSTYLE WS_EX_CONTROLPARENT
FONT 8, "MS Shell Dlg", 0, 0, 0x0
BEGIN
- LTEXT "E-mail:",IDC_STATIC,6,0,46,12,0,WS_EX_RIGHT
+ LTEXT "E-mail:",IDC_STATIC,6,2,46,9,0,WS_EX_RIGHT
EDITTEXT IDC_UN,56,0,122,12,ES_AUTOHSCROLL
- LTEXT "Password:",IDC_STATIC,6,16,46,12,0,WS_EX_RIGHT
+ LTEXT "Password:",IDC_STATIC,6,18,46,10,0,WS_EX_RIGHT
EDITTEXT IDC_PW,56,16,122,12,ES_PASSWORD | ES_AUTOHSCROLL
+ CONTROL "Create a new Facebook account", IDC_NEWACCOUNTLINK, "Hyperlink", WS_TABSTOP, 6, 40, 172, 12
+END
+
+IDD_OPTIONS DIALOGEX 0, 0, 305, 195
+STYLE DS_SETFONT | DS_FIXEDSYS | WS_CHILD
+EXSTYLE WS_EX_CONTROLPARENT
+FONT 8, "MS Shell Dlg", 0, 0, 0x1
+BEGIN
+ GROUPBOX "User details",IDC_STATIC,7,7,291,62
+ LTEXT "E-mail:",IDC_STATIC,17,20,61,8,0,WS_EX_RIGHT
+ EDITTEXT IDC_UN,84,18,123,13,ES_AUTOHSCROLL
+ LTEXT "Password:",IDC_STATIC,17,36,61,8,0,WS_EX_RIGHT
+ EDITTEXT IDC_PW,84,34,123,13,ES_PASSWORD | ES_AUTOHSCROLL
+ CONTROL "Create a new Facebook account",IDC_NEWACCOUNTLINK,
+ "Hyperlink",WS_TABSTOP,84,53,189,10
+ GROUPBOX "Contacts",IDC_STATIC,7,77,291,103
+ LTEXT "Default group:",IDC_STATIC,17,91,61,8,0,WS_EX_RIGHT
+ EDITTEXT IDC_GROUP,84,89,123,13,ES_AUTOHSCROLL
+END
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// DESIGNINFO
+//
+
+#ifdef APSTUDIO_INVOKED
+GUIDELINES DESIGNINFO
+BEGIN
+ IDD_FACEBOOKACCOUNT, DIALOG
+ BEGIN
+ END
+END
+#endif // APSTUDIO_INVOKED
+
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// AFX_DIALOG_LAYOUT
+//
+
+IDD_FACEBOOKACCOUNT AFX_DIALOG_LAYOUT
+BEGIN
+ 0
END
#endif // English (United States) resources
/////////////////////////////////////////////////////////////////////////////
+
+
+
+#ifndef APSTUDIO_INVOKED
+/////////////////////////////////////////////////////////////////////////////
+//
+// Generated from the TEXTINCLUDE 3 resource.
+//
+
+
+/////////////////////////////////////////////////////////////////////////////
+#endif // not APSTUDIO_INVOKED
+
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));
}