summaryrefslogtreecommitdiff
path: root/protocols
diff options
context:
space:
mode:
authorGeorge Hazan <ghazan@miranda.im>2016-12-27 20:40:35 +0300
committerGeorge Hazan <ghazan@miranda.im>2016-12-27 20:40:35 +0300
commit3c0c4ec799f35eb99215758f99491583033c5741 (patch)
tree465e516f7dc5aa6ba7b8f952601b44c967c68d14 /protocols
parente191ad15875a046f7a243596fe92e99f88cea072 (diff)
first version of options dialog
Diffstat (limited to 'protocols')
-rw-r--r--protocols/Discord/res/discord.rc22
-rw-r--r--protocols/Discord/src/main.cpp2
-rw-r--r--protocols/Discord/src/options.cpp72
-rw-r--r--protocols/Discord/src/proto.cpp65
-rw-r--r--protocols/Discord/src/proto.h16
-rw-r--r--protocols/Discord/src/resource.h7
-rw-r--r--protocols/Discord/src/stdafx.h9
7 files changed, 178 insertions, 15 deletions
diff --git a/protocols/Discord/res/discord.rc b/protocols/Discord/res/discord.rc
index 75f3bfe2e9..41366bcd7b 100644
--- a/protocols/Discord/res/discord.rc
+++ b/protocols/Discord/res/discord.rc
@@ -55,5 +55,27 @@ END
IDI_MAIN ICON "discord.ico"
IDI_OFFLINE ICON "offline.ico"
+/////////////////////////////////////////////////////////////////////////////
+//
+// Dialog
+//
+
+IDD_OPTIONS_ACCOUNT DIALOGEX 0, 0, 305, 190
+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_USERNAME,84,18,123,13,ES_AUTOHSCROLL
+ LTEXT "Password:",IDC_STATIC,17,36,61,8,0,WS_EX_RIGHT
+ EDITTEXT IDC_PASSWORD,84,34,123,13,ES_PASSWORD | ES_AUTOHSCROLL
+
+ GROUPBOX "Contacts",IDC_STATIC,7,77,291,88
+ LTEXT "Default group:",IDC_STATIC,17,91,61,8,0,WS_EX_RIGHT
+ EDITTEXT IDC_GROUP,84,89,123,13,ES_AUTOHSCROLL
+END
+
#endif // English (United States) resources
+
/////////////////////////////////////////////////////////////////////////////
diff --git a/protocols/Discord/src/main.cpp b/protocols/Discord/src/main.cpp
index 06e922e49d..9779dd8817 100644
--- a/protocols/Discord/src/main.cpp
+++ b/protocols/Discord/src/main.cpp
@@ -55,7 +55,7 @@ extern "C" __declspec(dllexport) const MUUID MirandaInterfaces[] = { MIID_PROTOC
static PROTO_INTERFACE* protoInit(const char *proto_name, const wchar_t *username)
{
- return new DiscordProto(proto_name, username);
+ return new ÑDiscordProto(proto_name, username);
}
static int protoUninit(PROTO_INTERFACE *proto)
diff --git a/protocols/Discord/src/options.cpp b/protocols/Discord/src/options.cpp
new file mode 100644
index 0000000000..6b9fe9b497
--- /dev/null
+++ b/protocols/Discord/src/options.cpp
@@ -0,0 +1,72 @@
+/*
+Copyright © 2016 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"
+
+class CDiscardAccountOptions : public CProtoDlgBase<ÑDiscordProto>
+{
+ CCtrlEdit m_edGroup, m_edUserName, m_edPassword;
+
+public:
+ CDiscardAccountOptions(ÑDiscordProto *ppro) :
+ CProtoDlgBase<ÑDiscordProto>(ppro, IDD_OPTIONS_ACCOUNT),
+ m_edGroup(this, IDC_GROUP),
+ m_edUserName(this, IDC_USERNAME),
+ m_edPassword(this, IDC_PASSWORD)
+ {}
+
+ virtual void OnInitDialog() override
+ {
+ ptrW buf(m_proto->getWStringA(DB_KEY_EMAIL));
+ if (buf)
+ m_edUserName.SetText(buf);
+
+ buf = m_proto->getWStringA(DB_KEY_PASSWORD);
+ if (buf)
+ m_edPassword.SetText(buf);
+
+ buf = m_proto->getWStringA(DB_KEY_GROUP);
+ m_edGroup.SetText(buf ? buf : DB_KEYVAL_GROUP);
+ }
+
+ virtual void OnApply() override
+ {
+ ptrW buf(m_edUserName.GetText());
+ m_proto->setWString(DB_KEY_EMAIL, buf);
+
+ buf = m_edPassword.GetText();
+ m_proto->setWString(DB_KEY_PASSWORD, buf);
+
+ buf = m_edGroup.GetText();
+ m_proto->setWString(DB_KEY_GROUP, buf);
+ }
+};
+
+int ÑDiscordProto::OnOptionsInit(WPARAM wParam, LPARAM)
+{
+ OPTIONSDIALOGPAGE odp = { 0 };
+ odp.hInstance = g_hInstance;
+ odp.szTitle.w = m_tszUserName;
+ odp.flags = ODPF_UNICODE;
+ odp.szGroup.w = LPGENW("Network");
+
+ odp.position = 1;
+ odp.szTab.w = LPGENW("Account");
+ odp.pDialog = new CDiscardAccountOptions(this);
+ Options_AddPage(wParam, &odp);
+ return 0;
+}
diff --git a/protocols/Discord/src/proto.cpp b/protocols/Discord/src/proto.cpp
index 73651f7b7f..c0af3fe2bd 100644
--- a/protocols/Discord/src/proto.cpp
+++ b/protocols/Discord/src/proto.cpp
@@ -1,6 +1,5 @@
/*
-Copyright © 2012-16 Miranda NG team
-Copyright © 2009 Jim Porter
+Copyright © 2016 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
@@ -18,24 +17,72 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "stdafx.h"
-DiscordProto::DiscordProto(const char *proto_name, const wchar_t *username) :
- PROTO<DiscordProto>(proto_name, username)
+ÑDiscordProto::ÑDiscordProto(const char *proto_name, const wchar_t *username) :
+ PROTO<ÑDiscordProto>(proto_name, username)
{
- CreateProtoService(PS_GETNAME, &DiscordProto::GetName);
- CreateProtoService(PS_GETSTATUS, &DiscordProto::GetStatus);
+ // Services
+ CreateProtoService(PS_GETNAME, &ÑDiscordProto::GetName);
+ CreateProtoService(PS_GETSTATUS, &ÑDiscordProto::GetStatus);
+
+ // Events
+ HookProtoEvent(ME_OPT_INITIALISE, &ÑDiscordProto::OnOptionsInit);
}
-DiscordProto::~DiscordProto()
+ÑDiscordProto::~ÑDiscordProto()
{
}
-INT_PTR DiscordProto::GetName(WPARAM wParam, LPARAM lParam)
+DWORD_PTR ÑDiscordProto::GetCaps(int type, MCONTACT)
+{
+ switch (type) {
+ case PFLAGNUM_1:
+ return PF1_IM | PF1_MODEMSGRECV | PF1_SERVERCLIST;
+ case PFLAGNUM_2:
+ return PF2_ONLINE;
+ case PFLAGNUM_3:
+ return PF2_ONLINE;
+ case PFLAGNUM_4:
+ return PF4_NOCUSTOMAUTH | PF4_AVATARS;
+ case PFLAG_UNIQUEIDTEXT:
+ return (DWORD_PTR)"E-mail";
+ case PFLAG_UNIQUEIDSETTING:
+ return (DWORD_PTR)DB_KEY_EMAIL;
+ }
+ return 0;
+}
+
+INT_PTR ÑDiscordProto::GetName(WPARAM wParam, LPARAM lParam)
{
mir_strncpy((char*)lParam, m_szModuleName, (int)wParam);
return 0;
}
-INT_PTR DiscordProto::GetStatus(WPARAM, LPARAM)
+INT_PTR ÑDiscordProto::GetStatus(WPARAM, LPARAM)
{
return m_iStatus;
}
+
+/////////////////////////////////////////////////////////////////////////////////////////
+
+int ÑDiscordProto::OnModulesLoaded(WPARAM, LPARAM)
+{
+ return 0;
+}
+
+int ÑDiscordProto::OnPreShutdown(WPARAM, LPARAM)
+{
+ return 0;
+}
+
+/////////////////////////////////////////////////////////////////////////////////////////
+
+int ÑDiscordProto::OnEvent(PROTOEVENTTYPE event, WPARAM wParam, LPARAM lParam)
+{
+ switch (event) {
+ case EV_PROTO_ONLOAD: return OnModulesLoaded(wParam, lParam);
+ case EV_PROTO_ONEXIT: return OnPreShutdown(wParam, lParam);
+ case EV_PROTO_ONOPTIONS: return OnOptionsInit(wParam, lParam);
+ }
+
+ return 1;
+}
diff --git a/protocols/Discord/src/proto.h b/protocols/Discord/src/proto.h
index 1da95e1c3d..e0c7e2c073 100644
--- a/protocols/Discord/src/proto.h
+++ b/protocols/Discord/src/proto.h
@@ -1,12 +1,22 @@
-class DiscordProto : public PROTO<DiscordProto>
+class ÑDiscordProto : public PROTO<ÑDiscordProto>
{
public:
- DiscordProto(const char*,const wchar_t*);
- ~DiscordProto();
+ ÑDiscordProto(const char*,const wchar_t*);
+ ~ÑDiscordProto();
+
+ // PROTO_INTERFACE
+ virtual DWORD_PTR __cdecl GetCaps(int, MCONTACT = 0) override;
+
+ virtual int __cdecl OnEvent(PROTOEVENTTYPE, WPARAM, LPARAM) override;
// Services
INT_PTR __cdecl GetName(WPARAM, LPARAM);
INT_PTR __cdecl GetStatus(WPARAM, LPARAM);
+
+ // Events
+ int __cdecl OnModulesLoaded(WPARAM, LPARAM);
+ int __cdecl OnPreShutdown(WPARAM, LPARAM);
+ int __cdecl OnOptionsInit(WPARAM, LPARAM);
};
diff --git a/protocols/Discord/src/resource.h b/protocols/Discord/src/resource.h
index f1e2a41867..44d79b91ae 100644
--- a/protocols/Discord/src/resource.h
+++ b/protocols/Discord/src/resource.h
@@ -5,6 +5,11 @@
#define IDI_MAIN 101
#define IDI_OFFLINE 102
+#define IDD_OPTIONS_ACCOUNT 103
+
+#define IDC_PASSWORD 1001
+#define IDC_USERNAME 1002
+#define IDC_GROUP 1003
// Next default values for new objects
//
@@ -12,7 +17,7 @@
#ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_NEXT_RESOURCE_VALUE 103
#define _APS_NEXT_COMMAND_VALUE 40001
-#define _APS_NEXT_CONTROL_VALUE 1001
+#define _APS_NEXT_CONTROL_VALUE 1004
#define _APS_NEXT_SYMED_VALUE 101
#endif
#endif
diff --git a/protocols/Discord/src/stdafx.h b/protocols/Discord/src/stdafx.h
index 0289445912..414b542c0f 100644
--- a/protocols/Discord/src/stdafx.h
+++ b/protocols/Discord/src/stdafx.h
@@ -30,6 +30,7 @@
#include <m_protosvc.h>
#include <m_protoint.h>
#include <m_skin.h>
+#include <m_gui.h>
#include <m_system.h>
#include <m_userinfo.h>
#include <m_icolib.h>
@@ -41,4 +42,10 @@
extern HINSTANCE g_hInstance;
#include "version.h"
-#include "proto.h" \ No newline at end of file
+#include "proto.h"
+
+#define DB_KEY_EMAIL "Email"
+#define DB_KEY_PASSWORD "Password"
+
+#define DB_KEY_GROUP "GroupName"
+#define DB_KEYVAL_GROUP L"Discord"