summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--protocols/WhatsApp/res/whatsapp.rc54
-rw-r--r--protocols/WhatsApp/src/dialogs.cpp52
-rw-r--r--protocols/WhatsApp/src/proto.cpp4
-rw-r--r--protocols/WhatsApp/src/proto.h2
-rw-r--r--protocols/WhatsApp/src/resource.h6
5 files changed, 80 insertions, 38 deletions
diff --git a/protocols/WhatsApp/res/whatsapp.rc b/protocols/WhatsApp/res/whatsapp.rc
index cf57963b54..020effc39e 100644
--- a/protocols/WhatsApp/res/whatsapp.rc
+++ b/protocols/WhatsApp/res/whatsapp.rc
@@ -68,25 +68,51 @@ END
// Dialog
//
-IDD_WHATSAPOPTIONS DIALOGEX 0, 0, 185, 136
+IDD_ACCMGRUI DIALOGEX 0, 0, 188, 144
STYLE DS_SETFONT | DS_FIXEDSYS | WS_CHILD
EXSTYLE WS_EX_CONTROLPARENT
FONT 8, "MS Shell Dlg", 400, 0, 0x0
BEGIN
- LTEXT "Phone number",IDC_STATIC,6,8,47,8
+ LTEXT "Phone number",IDC_STATIC,4,7,55,10
EDITTEXT IDC_CC,60,6,24,12,ES_AUTOHSCROLL
- EDITTEXT IDC_LOGIN,84,6,95,12,ES_AUTOHSCROLL
- LTEXT "Including country code, without '+' or '00'",IDC_STATIC,60,21,118,17
- LTEXT "Nickname",IDC_STATIC,6,43,48,12
- EDITTEXT IDC_NICK,60,42,119,12,ES_AUTOHSCROLL
- LTEXT "SMS code",IDC_STATIC,6,62,47,8
- EDITTEXT IDC_PW,60,60,20,12,ES_AUTOHSCROLL | ES_NUMBER
- EDITTEXT IDC_PW2,92,60,20,12,ES_AUTOHSCROLL | ES_NUMBER
- PUSHBUTTON "Request code",IDC_BUTTON_REQUEST_CODE,13,80,81,18
- PUSHBUTTON "Register code",IDC_BUTTON_REGISTER,98,80,81,18
- CONTROL "Use SSL connection (port 443)",IDC_SSL,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,5,108,173,10
- CTEXT "-",IDC_STATIC,82,62,8,8
- CONTROL "Automatically open group chats",IDC_AUTORUN,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,5,120,173,10
+ EDITTEXT IDC_LOGIN,84,6,100,12,ES_AUTOHSCROLL
+ LTEXT "Nickname",IDC_STATIC,4,23,55,10
+ EDITTEXT IDC_NICK,60,22,124,12,ES_AUTOHSCROLL
+ LTEXT "Default group",IDC_STATIC,4,37,55,10
+ EDITTEXT IDC_DEFGROUP,60,36,124,12,ES_AUTOHSCROLL
+ CONTROL "Use SSL connection (port 443)",IDC_SSL,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,4,52,180,10
+ CONTROL "Automatically open group chats",IDC_AUTORUN,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,4,64,180,10
+ GROUPBOX "Registration",IDC_STATIC,4,80,184,48
+ LTEXT "SMS code",IDC_STATIC,8,93,47,10
+ EDITTEXT IDC_PW,64,92,20,12,ES_AUTOHSCROLL | ES_NUMBER
+ CTEXT "-",IDC_STATIC,86,93,8,10
+ EDITTEXT IDC_PW2,96,92,20,12,ES_AUTOHSCROLL | ES_NUMBER
+ PUSHBUTTON "Request code",IDC_BUTTON_REQUEST_CODE,12,108,80,14
+ PUSHBUTTON "Register code",IDC_BUTTON_REGISTER,100,108,80,14
+END
+
+IDD_OPTIONS DIALOGEX 0, 0, 188, 164
+STYLE DS_SETFONT | DS_FIXEDSYS | WS_CHILD
+EXSTYLE WS_EX_CONTROLPARENT
+FONT 8, "MS Shell Dlg", 400, 0, 0x0
+BEGIN
+ LTEXT "Phone number",IDC_STATIC,4,7,55,10
+ EDITTEXT IDC_CC,60,6,24,12,ES_AUTOHSCROLL
+ EDITTEXT IDC_LOGIN,84,6,100,12,ES_AUTOHSCROLL
+ LTEXT "Including country code, without '+' or '00'",IDC_STATIC,60,22,118,18
+ LTEXT "Nickname",IDC_STATIC,4,43,55,10
+ EDITTEXT IDC_NICK,60,42,124,12,ES_AUTOHSCROLL
+ LTEXT "Default group",IDC_STATIC,4,57,55,10
+ EDITTEXT IDC_DEFGROUP,60,56,124,12,ES_AUTOHSCROLL
+ CONTROL "Use SSL connection (port 443)",IDC_SSL,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,4,72,180,10
+ CONTROL "Automatically open group chats",IDC_AUTORUN,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,4,84,180,10
+ GROUPBOX "Registration",IDC_STATIC,4,100,184,48
+ LTEXT "SMS code",IDC_STATIC,8,113,47,10
+ EDITTEXT IDC_PW,64,112,20,12,ES_AUTOHSCROLL | ES_NUMBER
+ CTEXT "-",IDC_STATIC,86,113,8,10
+ EDITTEXT IDC_PW2,96,112,20,12,ES_AUTOHSCROLL | ES_NUMBER
+ PUSHBUTTON "Request code",IDC_BUTTON_REQUEST_CODE,12,128,80,14
+ PUSHBUTTON "Register code",IDC_BUTTON_REGISTER,100,128,80,14
END
IDD_GROUPCHAT_INVITE DIALOGEX 0, 0, 215, 170
diff --git a/protocols/WhatsApp/src/dialogs.cpp b/protocols/WhatsApp/src/dialogs.cpp
index 67c12c7475..17048df398 100644
--- a/protocols/WhatsApp/src/dialogs.cpp
+++ b/protocols/WhatsApp/src/dialogs.cpp
@@ -15,7 +15,9 @@ INT_PTR CALLBACK WhatsAppAccountProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPA
SetWindowLongPtr(hwndDlg, GWLP_USERDATA, lParam);
SendDlgItemMessage(hwndDlg, IDC_PW, EM_LIMITTEXT, 3, 0);
SendDlgItemMessage(hwndDlg, IDC_PW2, EM_LIMITTEXT, 3, 0);
+
CheckDlgButton(hwndDlg, IDC_SSL, db_get_b(NULL, proto->m_szModuleName, WHATSAPP_KEY_SSL, 0) ? BST_CHECKED : BST_UNCHECKED);
+ CheckDlgButton(hwndDlg, IDC_AUTORUN, proto->getBool(WHATSAPP_KEY_AUTORUNCHATS, true) ? BST_CHECKED : BST_UNCHECKED);
{
ptrA szStr(proto->getStringA(WHATSAPP_KEY_CC));
if (szStr != NULL)
@@ -27,18 +29,10 @@ INT_PTR CALLBACK WhatsAppAccountProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPA
if ((szStr = proto->getStringA(WHATSAPP_KEY_NICK)) != NULL)
SetDlgItemTextA(hwndDlg, IDC_NICK, szStr);
}
+ SetDlgItemText(hwndDlg, IDC_DEFGROUP, proto->m_tszDefaultGroup);
EnableWindow(GetDlgItem(hwndDlg, IDC_PW), FALSE);
EnableWindow(GetDlgItem(hwndDlg, IDC_PW2), FALSE);
-
- if (!proto->isOffline()) {
- SendDlgItemMessage(hwndDlg, IDC_CC, EM_SETREADONLY, 1, 0);
- SendDlgItemMessage(hwndDlg, IDC_LOGIN, EM_SETREADONLY, 1, 0);
- SendDlgItemMessage(hwndDlg, IDC_NICK, EM_SETREADONLY, 1, 0);
- SendDlgItemMessage(hwndDlg, IDC_PW, EM_SETREADONLY, 1, 0);
- SendDlgItemMessage(hwndDlg, IDC_PW2, EM_SETREADONLY, 1, 0);
- EnableWindow(GetDlgItem(hwndDlg, IDC_SSL), FALSE);
- }
return TRUE;
case WM_COMMAND:
@@ -81,15 +75,24 @@ INT_PTR CALLBACK WhatsAppAccountProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPA
}
}
- if (HIWORD(wParam) == EN_CHANGE && reinterpret_cast<HWND>(lParam) == GetFocus()) {
- switch (LOWORD(wParam)) {
- case IDC_CC:
- case IDC_LOGIN:
- case IDC_NICK:
- case IDC_SSL:
- case IDC_PW:
- case IDC_PW2:
- SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
+ if (HWND(lParam) == GetFocus()) {
+ if (HIWORD(wParam) == EN_CHANGE) {
+ switch (LOWORD(wParam)) {
+ case IDC_CC:
+ case IDC_LOGIN:
+ case IDC_NICK:
+ case IDC_DEFGROUP:
+ case IDC_PW:
+ case IDC_PW2:
+ SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
+ }
+ }
+ else if (HIWORD(wParam) == BN_CLICKED) {
+ switch (LOWORD(wParam)) {
+ case IDC_AUTORUN:
+ case IDC_SSL:
+ SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
+ }
}
}
break;
@@ -97,7 +100,6 @@ INT_PTR CALLBACK WhatsAppAccountProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPA
case WM_NOTIFY:
if (reinterpret_cast<NMHDR *>(lParam)->code == PSN_APPLY) {
char str[128];
-
GetDlgItemTextA(hwndDlg, IDC_CC, str, SIZEOF(str));
proto->setString(WHATSAPP_KEY_CC, str);
@@ -107,7 +109,19 @@ INT_PTR CALLBACK WhatsAppAccountProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPA
GetDlgItemTextA(hwndDlg, IDC_NICK, str, SIZEOF(str));
proto->setString(WHATSAPP_KEY_NICK, str);
+ TCHAR tstr[100];
+ GetDlgItemText(hwndDlg, IDC_DEFGROUP, tstr, SIZEOF(tstr));
+ if (mir_tstrcmp(proto->m_tszDefaultGroup, tstr)) {
+ proto->m_tszDefaultGroup = mir_tstrdup(tstr);
+ proto->setTString(WHATSAPP_KEY_DEF_GROUP, tstr);
+ }
+
proto->setByte(WHATSAPP_KEY_SSL, IsDlgButtonChecked(hwndDlg, IDC_SSL));
+ proto->setByte(WHATSAPP_KEY_AUTORUNCHATS, IsDlgButtonChecked(hwndDlg, IDC_AUTORUN));
+
+ if (proto->isOnline())
+ MessageBox(NULL, TranslateT("Changes will be applied after protocol restart"), proto->m_tszUserName, MB_OK);
+
return TRUE;
}
break;
diff --git a/protocols/WhatsApp/src/proto.cpp b/protocols/WhatsApp/src/proto.cpp
index ba47afa2e6..93847e1747 100644
--- a/protocols/WhatsApp/src/proto.cpp
+++ b/protocols/WhatsApp/src/proto.cpp
@@ -329,7 +329,7 @@ bool WhatsAppProto::Register(int state, const string &cc, const string &number,
INT_PTR WhatsAppProto::SvcCreateAccMgrUI(WPARAM wParam, LPARAM lParam)
{
- return (INT_PTR)CreateDialogParam(g_hInstance, MAKEINTRESOURCE(IDD_WHATSAPOPTIONS),
+ return (INT_PTR)CreateDialogParam(g_hInstance, MAKEINTRESOURCE(IDD_ACCMGRUI),
(HWND)lParam, WhatsAppAccountProc, (LPARAM)this);
}
@@ -344,7 +344,7 @@ int WhatsAppProto::OnOptionsInit(WPARAM wParam, LPARAM lParam)
odp.position = 1;
odp.ptszGroup = LPGENT("Network");
odp.ptszTab = LPGENT("Account");
- odp.pszTemplate = MAKEINTRESOURCEA(IDD_WHATSAPOPTIONS);
+ odp.pszTemplate = MAKEINTRESOURCEA(IDD_OPTIONS);
odp.pfnDlgProc = WhatsAppAccountProc;
Options_AddPage(wParam, &odp);
return 0;
diff --git a/protocols/WhatsApp/src/proto.h b/protocols/WhatsApp/src/proto.h
index a74ed810a3..1c1ddb3192 100644
--- a/protocols/WhatsApp/src/proto.h
+++ b/protocols/WhatsApp/src/proto.h
@@ -118,6 +118,7 @@ public:
std::vector<string> m_szInviteJids;
map<std::string, WAChatInfo*> m_chats;
mir_cs m_csChats;
+ ptrT m_tszDefaultGroup;
void ChatLogMenuHook(WAChatInfo *pInfo, GCHOOK *gch);
void NickListMenuHook(WAChatInfo *pInfo, GCHOOK *gch);
@@ -175,7 +176,6 @@ private:
WAConnection *m_pConnection;
Mutex connMutex;
time_t m_tLastWriteTime;
- ptrT m_tszDefaultGroup;
std::vector<unsigned char> m_Challenge;
std::string m_szPhoneNumber;
diff --git a/protocols/WhatsApp/src/resource.h b/protocols/WhatsApp/src/resource.h
index 64b7b1359a..7558d8f549 100644
--- a/protocols/WhatsApp/src/resource.h
+++ b/protocols/WhatsApp/src/resource.h
@@ -4,8 +4,9 @@
//
#define IDD_INPUTBOX 102
#define IDR_REGISTERUTILITY 103
-#define IDD_WHATSAPOPTIONS 104
+#define IDD_ACCMGRUI 104
#define IDD_GROUPCHAT_INVITE 105
+#define IDD_OPTIONS 106
#define IDI_WHATSAPP 203
#define IDI_ADD_GROUP 206
#define IDI_RENAME_GROUP 208
@@ -26,6 +27,7 @@
#define IDC_TEXT 1014
#define IDC_INVITE 1015
#define IDC_AUTORUN 1016
+#define IDC_DEFGROUP 1017
// Next default values for new objects
//
@@ -33,7 +35,7 @@
#ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_NEXT_RESOURCE_VALUE 106
#define _APS_NEXT_COMMAND_VALUE 40001
-#define _APS_NEXT_CONTROL_VALUE 1017
+#define _APS_NEXT_CONTROL_VALUE 1018
#define _APS_NEXT_SYMED_VALUE 101
#endif
#endif