summaryrefslogtreecommitdiff
path: root/protocols/VKontakte/src
diff options
context:
space:
mode:
authorGeorge Hazan <george.hazan@gmail.com>2013-10-05 21:20:12 +0000
committerGeorge Hazan <george.hazan@gmail.com>2013-10-05 21:20:12 +0000
commit3a686f86c91cb428e6c8f4534f7d2b72054ecf38 (patch)
treea544928d00c91b5f8a3cb6d2de5662dd4c36fda3 /protocols/VKontakte/src
parentaa31874392c484ccc7d8dc7d87f88e013c031219 (diff)
VK: password dialog
git-svn-id: http://svn.miranda-ng.org/main/trunk@6359 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'protocols/VKontakte/src')
-rw-r--r--protocols/VKontakte/src/misc.cpp28
-rw-r--r--protocols/VKontakte/src/resource.h8
-rw-r--r--protocols/VKontakte/src/vk_options.cpp69
-rw-r--r--protocols/VKontakte/src/vk_proto.cpp1
-rw-r--r--protocols/VKontakte/src/vk_proto.h4
5 files changed, 106 insertions, 4 deletions
diff --git a/protocols/VKontakte/src/misc.cpp b/protocols/VKontakte/src/misc.cpp
new file mode 100644
index 0000000000..dba3de5535
--- /dev/null
+++ b/protocols/VKontakte/src/misc.cpp
@@ -0,0 +1,28 @@
+/*
+Copyright (C) 2013 Miranda NG Project (http://miranda-ng.org)
+
+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 version 2
+of the License.
+
+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"
+
+TCHAR* CVkProto::GetUserStoredPassword()
+{
+ ptrA szRawPass( getStringA("Password"));
+ if (szRawPass != NULL) {
+ CallService(MS_DB_CRYPT_DECODESTRING, strlen(szRawPass), szRawPass);
+ return mir_utf8decodeT(szRawPass);
+ }
+ return NULL;
+}
diff --git a/protocols/VKontakte/src/resource.h b/protocols/VKontakte/src/resource.h
index dc2b908493..3060905969 100644
--- a/protocols/VKontakte/src/resource.h
+++ b/protocols/VKontakte/src/resource.h
@@ -1,16 +1,20 @@
//{{NO_DEPENDENCIES}}
// Microsoft Visual C++ generated include file.
+// Used by D:\Myranda\protocols\VKontakte\res\resource.rc
//
#define IDD_ACCMGRUI 101
+#define IDC_LOGIN 1001
+#define IDC_PASSWORD 1002
+#define IDC_URL 1003
// Next default values for new objects
-//
+//
#ifdef APSTUDIO_INVOKED
#ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_NO_MFC 1
#define _APS_NEXT_RESOURCE_VALUE 101
#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/VKontakte/src/vk_options.cpp b/protocols/VKontakte/src/vk_options.cpp
index a854a9f335..27d4a902f4 100644
--- a/protocols/VKontakte/src/vk_options.cpp
+++ b/protocols/VKontakte/src/vk_options.cpp
@@ -22,8 +22,73 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
INT_PTR CALLBACK VKAccountProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
- return 0;
-};
+ CVkProto* ppro = (CVkProto*)GetWindowLongPtr(hwndDlg, GWLP_USERDATA);
+
+ switch (uMsg) {
+ case WM_INITDIALOG:
+ TranslateDialogDefault(hwndDlg);
+
+ ppro = (CVkProto*)lParam;
+ SetWindowLongPtr( hwndDlg, GWLP_USERDATA, lParam );
+
+ SendMessage(hwndDlg, WM_SETICON, ICON_BIG, (LPARAM)Skin_GetIconByHandle(ppro->m_hProtoIcon, true));
+ SendMessage(hwndDlg, WM_SETICON, ICON_SMALL, (LPARAM)Skin_GetIconByHandle(ppro->m_hProtoIcon));
+
+ SendDlgItemMessage(hwndDlg, IDC_PASSWORD, EM_LIMITTEXT, 30, 0);
+ {
+ ptrT tszLogin( ppro->getTStringA("Login"));
+ if (tszLogin != NULL)
+ SetDlgItemText(hwndDlg, IDC_LOGIN, tszLogin);
+
+ ptrT tszPassw( ppro->GetUserStoredPassword());
+ if (tszPassw != NULL)
+ SetDlgItemText(hwndDlg, IDC_PASSWORD, tszPassw);
+ }
+ return TRUE;
+
+ case WM_COMMAND:
+ switch (LOWORD(wParam)) {
+ case IDC_URL:
+ CallService(MS_UTILS_OPENURL, 1, (LPARAM)"http://www.vk.com");
+ break;
+
+ case IDC_LOGIN:
+ case IDC_PASSWORD:
+ if (HIWORD(wParam) == EN_CHANGE && (HWND)lParam == GetFocus()) {
+ SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
+ break;
+ }
+ }
+ break;
+
+ case WM_NOTIFY:
+ switch (((LPNMHDR)lParam)->code) {
+ case PSN_APPLY:
+ TCHAR str[128];
+ GetDlgItemText(hwndDlg, IDC_LOGIN, str, SIZEOF(str));
+ ppro->setTString("Login", str);
+
+ GetDlgItemText(hwndDlg, IDC_PASSWORD, str, SIZEOF(str));
+ ptrA szRawPasswd( mir_utf8encodeT(str));
+ if (szRawPasswd != NULL) {
+ CallService(MS_DB_CRYPT_ENCODESTRING, strlen(szRawPasswd), szRawPasswd);
+ ppro->setString("Password", szRawPasswd);
+ }
+ }
+ break;
+
+ case WM_CLOSE:
+ EndDialog(hwndDlg, 0);
+ break;
+
+ case WM_DESTROY:
+ Skin_ReleaseIcon((HICON)SendMessage(hwndDlg, WM_GETICON, ICON_BIG, 0));
+ Skin_ReleaseIcon((HICON)SendMessage(hwndDlg, WM_GETICON, ICON_SMALL, 0));
+ break;
+ }
+
+ return FALSE;
+}
INT_PTR CVkProto::SvcCreateAccMgrUI(WPARAM wParam, LPARAM lParam)
{
diff --git a/protocols/VKontakte/src/vk_proto.cpp b/protocols/VKontakte/src/vk_proto.cpp
index ca1e8193fd..ebc47f8516 100644
--- a/protocols/VKontakte/src/vk_proto.cpp
+++ b/protocols/VKontakte/src/vk_proto.cpp
@@ -20,6 +20,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
CVkProto::CVkProto(const char *szModuleName, const TCHAR *ptszUserName) :
PROTO<CVkProto>(szModuleName, ptszUserName)
{
+ CreateProtoService(PS_CREATEACCMGRUI, &CVkProto::SvcCreateAccMgrUI);
}
CVkProto::~CVkProto()
diff --git a/protocols/VKontakte/src/vk_proto.h b/protocols/VKontakte/src/vk_proto.h
index ffb92c5990..9000017dee 100644
--- a/protocols/VKontakte/src/vk_proto.h
+++ b/protocols/VKontakte/src/vk_proto.h
@@ -78,4 +78,8 @@ struct CVkProto : public PROTO<CVkProto>
//==== Services ======================================================================
INT_PTR __cdecl SvcCreateAccMgrUI(WPARAM, LPARAM);
+
+ //==== Misc ==========================================================================
+
+ TCHAR* GetUserStoredPassword(void);
};