diff options
author | George Hazan <george.hazan@gmail.com> | 2015-02-06 23:36:02 +0000 |
---|---|---|
committer | George Hazan <george.hazan@gmail.com> | 2015-02-06 23:36:02 +0000 |
commit | b2f86045d3b3dc2a454f127f186429b60e493072 (patch) | |
tree | f56c5696ef3ebf62b1a97e4abbfcbc332adbbd28 /protocols/WhatsApp/src/dialogs.cpp | |
parent | 8c6ce1ceb218db86d059372e18277c16b1ab20cb (diff) |
merge from branch
git-svn-id: http://svn.miranda-ng.org/main/trunk@12029 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'protocols/WhatsApp/src/dialogs.cpp')
-rw-r--r-- | protocols/WhatsApp/src/dialogs.cpp | 141 |
1 files changed, 79 insertions, 62 deletions
diff --git a/protocols/WhatsApp/src/dialogs.cpp b/protocols/WhatsApp/src/dialogs.cpp index 0550dc4102..0d93fd2afd 100644 --- a/protocols/WhatsApp/src/dialogs.cpp +++ b/protocols/WhatsApp/src/dialogs.cpp @@ -3,16 +3,16 @@ #define szAskSendSms LPGEN("An SMS with registration code will be sent to your mobile phone.\nNotice that you are not able to use the real WhatsApp and this plugin simultaneously!\nContinue?")
#define szPasswordSet LPGEN("Your password has been set automatically. You can proceed with login now")
-INT_PTR CALLBACK WhatsAppAccountProc(HWND hwndDlg, UINT message, WPARAM wparam, LPARAM lparam)
+INT_PTR CALLBACK WhatsAppAccountProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
- WhatsAppProto *proto;
+ WhatsAppProto *proto = (WhatsAppProto*)GetWindowLongPtr(hwndDlg, GWLP_USERDATA);
- switch (message) {
+ switch (uMsg) {
case WM_INITDIALOG:
TranslateDialogDefault(hwndDlg);
- proto = reinterpret_cast<WhatsAppProto*>(lparam);
- SetWindowLongPtr(hwndDlg, GWLP_USERDATA, lparam);
+ proto = (WhatsAppProto*)lParam;
+ 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);
@@ -42,16 +42,14 @@ INT_PTR CALLBACK WhatsAppAccountProc(HWND hwndDlg, UINT message, WPARAM wparam, return TRUE;
case WM_COMMAND:
- if (LOWORD(wparam) == IDC_BUTTON_REQUEST_CODE || LOWORD(wparam) == IDC_BUTTON_REGISTER) {
- proto = reinterpret_cast<WhatsAppProto*>(GetWindowLongPtr(hwndDlg, GWLP_USERDATA));
-
+ if (LOWORD(wParam) == IDC_BUTTON_REQUEST_CODE || LOWORD(wParam) == IDC_BUTTON_REGISTER) {
string password;
char cc[5];
char number[128];
GetDlgItemTextA(hwndDlg, IDC_CC, cc, SIZEOF(cc));
GetDlgItemTextA(hwndDlg, IDC_LOGIN, number, SIZEOF(number));
- if (LOWORD(wparam) == IDC_BUTTON_REQUEST_CODE) {
+ if (LOWORD(wParam) == IDC_BUTTON_REQUEST_CODE) {
if (IDYES == MessageBox(NULL, TranslateT(szAskSendSms), PRODUCT_NAME, MB_YESNO)) {
if (proto->Register(REG_STATE_REQ_CODE, string(cc), string(number), string(), password)) {
if (!password.empty()) {
@@ -65,7 +63,7 @@ INT_PTR CALLBACK WhatsAppAccountProc(HWND hwndDlg, UINT message, WPARAM wparam, }
}
}
- else if (LOWORD(wparam) == IDC_BUTTON_REGISTER) {
+ else if (LOWORD(wParam) == IDC_BUTTON_REGISTER) {
HWND hwnd1 = GetDlgItem(hwndDlg, IDC_PW), hwnd2 = GetDlgItem(hwndDlg, IDC_PW2);
if (GetWindowTextLength(hwnd1) != 3 || GetWindowTextLength(hwnd2) != 3) {
MessageBox(NULL, TranslateT("Please correctly specify your registration code received by SMS"), PRODUCT_NAME, MB_ICONEXCLAMATION);
@@ -83,8 +81,8 @@ INT_PTR CALLBACK WhatsAppAccountProc(HWND hwndDlg, UINT message, WPARAM wparam, }
}
- if (HIWORD(wparam) == EN_CHANGE && reinterpret_cast<HWND>(lparam) == GetFocus()) {
- switch (LOWORD(wparam)) {
+ if (HIWORD(wParam) == EN_CHANGE && reinterpret_cast<HWND>(lParam) == GetFocus()) {
+ switch (LOWORD(wParam)) {
case IDC_CC:
case IDC_LOGIN:
case IDC_NICK:
@@ -97,8 +95,7 @@ INT_PTR CALLBACK WhatsAppAccountProc(HWND hwndDlg, UINT message, WPARAM wparam, break;
case WM_NOTIFY:
- if (reinterpret_cast<NMHDR *>(lparam)->code == PSN_APPLY) {
- proto = reinterpret_cast<WhatsAppProto *>(GetWindowLongPtr(hwndDlg, GWLP_USERDATA));
+ if (reinterpret_cast<NMHDR *>(lParam)->code == PSN_APPLY) {
char str[128];
GetDlgItemTextA(hwndDlg, IDC_CC, str, SIZEOF(str));
@@ -114,68 +111,88 @@ INT_PTR CALLBACK WhatsAppAccountProc(HWND hwndDlg, UINT message, WPARAM wparam, return TRUE;
}
break;
-
}
return FALSE;
}
-INT_PTR CALLBACK WhatsAppInputBoxProc(HWND hwndDlg, UINT message, WPARAM wparam, LPARAM lparam)
+/////////////////////////////////////////////////////////////////////////////////////////
+// Invite dialog
+
+static void InitList(HWND hwndClist, WhatsAppProto *ppro)
+{
+ SetWindowLongPtr(hwndClist, GWL_STYLE,
+ GetWindowLongPtr(hwndClist, GWL_STYLE) | CLS_CHECKBOXES | CLS_HIDEEMPTYGROUPS | CLS_USEGROUPS | CLS_GREYALTERNATE);
+ SendMessage(hwndClist, CLM_SETEXSTYLE, CLS_EX_DISABLEDRAGDROP | CLS_EX_TRACKSELECT, 0);
+ SendMessage(hwndClist, CLM_SETBKBITMAP, 0, 0);
+ SendMessage(hwndClist, CLM_SETBKCOLOR, GetSysColor(COLOR_WINDOW), 0);
+ SendMessage(hwndClist, CLM_SETGREYOUTFLAGS, 0, 0);
+ SendMessage(hwndClist, CLM_SETLEFTMARGIN, 4, 0);
+ SendMessage(hwndClist, CLM_SETINDENT, 10, 0);
+ SendMessage(hwndClist, CLM_SETBKBITMAP, 0, 0);
+ SendMessage(hwndClist, CLM_SETHIDEEMPTYGROUPS, TRUE, 0);
+ SendMessage(hwndClist, CLM_SETHIDEOFFLINEROOT, TRUE, 0);
+
+ for (int i = 0; i <= FONTID_MAX; i++)
+ SendMessage(hwndClist, CLM_SETTEXTCOLOR, i, GetSysColor(COLOR_WINDOWTEXT));
+
+ for (MCONTACT hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) {
+ char *proto = GetContactProto(hContact);
+ if (mir_strcmp(proto, ppro->m_szModuleName) || ppro->isChatRoom(hContact))
+ if (MCONTACT hItem = SendMessage(hwndClist, CLM_FINDCONTACT, hContact, 0))
+ SendMessage(hwndClist, CLM_DELETEITEM, hItem, 0);
+ }
+}
+
+INT_PTR CALLBACK InviteDialogProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
- input_box* ib;
+ WhatsAppProto *proto = (WhatsAppProto*)GetWindowLongPtr(hwndDlg, GWLP_USERDATA);
- switch (message) {
+ switch (uMsg) {
case WM_INITDIALOG:
TranslateDialogDefault(hwndDlg);
- ib = reinterpret_cast<input_box*>(lparam);
- SetWindowLongPtr(hwndDlg, GWLP_USERDATA, lparam);
- SendDlgItemMessage(hwndDlg, IDC_VALUE, EM_LIMITTEXT, ib->limit, 0);
- SetDlgItemText(hwndDlg, IDC_VALUE, ib->defaultValue.c_str());
- SetDlgItemText(hwndDlg, IDC_TEXT, ib->text.c_str());
-
- SetWindowText(hwndDlg, ib->title.c_str());
-
- EnableWindow(GetDlgItem(hwndDlg, IDC_OK), FALSE);
- return TRUE;
+ proto = (WhatsAppProto*)lParam;
+ SetWindowLongPtr(hwndDlg, GWLP_USERDATA, lParam);
+ InitList(GetDlgItem(hwndDlg, IDC_CLIST), proto);
+ return 1;
+
case WM_COMMAND:
- if (LOWORD(wparam) == IDC_VALUE && HIWORD(wparam) == EN_CHANGE) {
- ib = reinterpret_cast<input_box*>(GetWindowLongPtr(hwndDlg, GWLP_USERDATA));
- size_t len = SendDlgItemMessage(hwndDlg, IDC_VALUE, WM_GETTEXTLENGTH, 0, 0);
- TCHAR str[4];
- mir_sntprintf(str, SIZEOF(str), TEXT("%d"), ib->limit - len);
- //SetDlgItemText(hwndDlg,IDC_CHARACTERS,str);
-
- EnableWindow(GetDlgItem(hwndDlg, IDC_OK), len > 0);
- return TRUE;
- }
-
- if (LOWORD(wparam) == IDC_OK) {
- ib = reinterpret_cast<input_box*>(GetWindowLongPtr(hwndDlg, GWLP_USERDATA));
- TCHAR* value = new TCHAR[ib->limit + 1];
-
- GetDlgItemText(hwndDlg, IDC_VALUE, value, ib->limit + 1);
- ShowWindow(hwndDlg, SW_HIDE);
+ switch (LOWORD(wParam)) {
+ case IDCANCEL:
+ EndDialog(hwndDlg, 0);
+ break;
+
+ case IDOK:
+ proto->m_szInviteJids.clear();
+
+ // invite users from clist
+ for (MCONTACT hContact = db_find_first(proto->m_szModuleName); hContact; hContact = db_find_next(hContact, proto->m_szModuleName)) {
+ if (proto->isChatRoom(hContact))
+ continue;
+
+ HWND hwndList = GetDlgItem(hwndDlg, IDC_CLIST);
+ if (int hItem = SendMessage(hwndList, CLM_FINDCONTACT, hContact, 0)) {
+ if (SendMessage(hwndList, CLM_GETCHECKMARK, (WPARAM)hItem, 0)) {
+ ptrA jid(proto->getStringA(hContact, "ID"));
+ if (jid != NULL)
+ proto->m_szInviteJids.push_back((char*)jid);
+ }
+ }
+ }
- input_box_ret* ret = new input_box_ret;
- ret->userData = ib->userData;
- ret->value = mir_utf8encodeT(value);
- delete value;
- ib->proto->ForkThread(ib->thread, ret);
- EndDialog(hwndDlg, wparam);
- delete ib;
- return TRUE;
- }
+ HWND hwndEntry = GetDlgItem(hwndDlg, IDC_NEWJID);
+ int len = GetWindowTextLength(hwndEntry);
+ if (len > 0) {
+ std::string szOther; szOther.resize(len + 1);
+ GetWindowTextA(hwndEntry, (char*)szOther.data(), len);
+ proto->m_szInviteJids.push_back(szOther);
+ }
- if (LOWORD(wparam) == IDC_CANCEL) {
- EndDialog(hwndDlg, wparam);
- ib = reinterpret_cast<input_box*>(GetWindowLongPtr(hwndDlg, GWLP_USERDATA));
- delete ib;
- return TRUE;
+ EndDialog(hwndDlg, 1);
}
- break;
}
- return FALSE;
-}
\ No newline at end of file + return 0;
+}
|