summaryrefslogtreecommitdiff
path: root/protocols/VKontakte/src
diff options
context:
space:
mode:
Diffstat (limited to 'protocols/VKontakte/src')
-rw-r--r--protocols/VKontakte/src/resource.h3
-rw-r--r--protocols/VKontakte/src/vk_options.cpp77
-rw-r--r--protocols/VKontakte/src/vk_queue.cpp10
-rw-r--r--protocols/VKontakte/src/vk_struct.cpp14
-rw-r--r--protocols/VKontakte/src/vk_struct.h7
5 files changed, 56 insertions, 55 deletions
diff --git a/protocols/VKontakte/src/resource.h b/protocols/VKontakte/src/resource.h
index f387c18e32..c56f5cce12 100644
--- a/protocols/VKontakte/src/resource.h
+++ b/protocols/VKontakte/src/resource.h
@@ -113,6 +113,7 @@
#define IDC_N_INVITES 1097
#define IDC_USENOSTDPOPUPS 1098
#define IDC_RET_CHAT_MES 1099
+#define IDC_COMBO_LANGUAGE 1100
// Next default values for new objects
//
@@ -121,7 +122,7 @@
#define _APS_NO_MFC 1
#define _APS_NEXT_RESOURCE_VALUE 122
#define _APS_NEXT_COMMAND_VALUE 40001
-#define _APS_NEXT_CONTROL_VALUE 1100
+#define _APS_NEXT_CONTROL_VALUE 1101
#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 92537b1474..223df9ce21 100644
--- a/protocols/VKontakte/src/vk_options.cpp
+++ b/protocols/VKontakte/src/vk_options.cpp
@@ -17,6 +17,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "stdafx.h"
+
+
//////////////////////////////////////////////////////////////////////////////
// Account manager dialog
@@ -31,8 +33,6 @@ INT_PTR CALLBACK VKAccountProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lP
ppro = (CVkProto*)lParam;
SetWindowLongPtr(hwndDlg, GWLP_USERDATA, lParam);
- SendMessage(hwndDlg, WM_SETICON, ICON_BIG, (LPARAM)IcoLib_GetIconByHandle(ppro->m_hProtoIcon, 1));
- SendMessage(hwndDlg, WM_SETICON, ICON_SMALL, (LPARAM)IcoLib_GetIconByHandle(ppro->m_hProtoIcon));
{
ptrT ptszLogin(ppro->getTStringA("Login"));
if (ptszLogin != NULL)
@@ -90,11 +90,6 @@ INT_PTR CALLBACK VKAccountProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lP
case WM_CLOSE:
EndDialog(hwndDlg, 0);
break;
-
- case WM_DESTROY:
- IcoLib_ReleaseIcon((HICON)SendMessage(hwndDlg, WM_GETICON, ICON_BIG, 0));
- IcoLib_ReleaseIcon((HICON)SendMessage(hwndDlg, WM_GETICON, ICON_SMALL, 0));
- break;
}
return FALSE;
@@ -112,6 +107,20 @@ INT_PTR CALLBACK CVkProto::OptionsProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, L
{
CVkProto *ppro = (CVkProto*)GetWindowLongPtr(hwndDlg, GWLP_USERDATA);
+ CVKLang vkLangCodes[] = {
+ { NULL, LPGENT("Account language") },
+ { _T("en"), LPGENT("English") },
+ { _T("ru"), LPGENT("Russian") },
+ { _T("be"), LPGENT("Belarusian") },
+ { _T("ua"), LPGENT("Ukrainian") },
+ { _T("es"), LPGENT("Spanish") },
+ { _T("fi"), LPGENT("Finnish") },
+ { _T("de"), LPGENT("German") },
+ { _T("it"), LPGENT("Italian") },
+ };
+
+ HWND hWndCombo = GetDlgItem(hwndDlg, IDC_COMBO_LANGUAGE);
+
switch (uMsg) {
case WM_INITDIALOG:
TranslateDialogDefault(hwndDlg);
@@ -119,8 +128,6 @@ INT_PTR CALLBACK CVkProto::OptionsProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, L
ppro = (CVkProto*)lParam;
SetWindowLongPtr(hwndDlg, GWLP_USERDATA, lParam);
- SendMessage(hwndDlg, WM_SETICON, ICON_BIG, (LPARAM)IcoLib_GetIconByHandle(ppro->m_hProtoIcon, 1));
- SendMessage(hwndDlg, WM_SETICON, ICON_SMALL, (LPARAM)IcoLib_GetIconByHandle(ppro->m_hProtoIcon));
{
ptrT ptszLogin(ppro->getTStringA("Login"));
if (ptszLogin != NULL)
@@ -128,9 +135,16 @@ INT_PTR CALLBACK CVkProto::OptionsProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, L
ptrT ptszPassw(ppro->GetUserStoredPassword());
if (ptszPassw != NULL)
- SetDlgItemText(hwndDlg, IDC_PASSWORD, ptszPassw);
+ SetDlgItemText(hwndDlg, IDC_PASSWORD, ptszPassw);
+ }
+
+ SetDlgItemText(hwndDlg, IDC_GROUPNAME, ppro->getGroup());
- SetDlgItemText(hwndDlg, IDC_GROUPNAME, ppro->getGroup());
+ for (size_t i = 0; i < _countof(vkLangCodes); i++) {
+ LRESULT iItem = SendMessage(hWndCombo, CB_ADDSTRING, 0, (LPARAM)TranslateTS(vkLangCodes[i].szDescription));
+ SendMessage(hWndCombo, CB_SETITEMDATA, iItem, (LPARAM)vkLangCodes[i].szCode);
+ if (!mir_tstrcmpi(vkLangCodes[i].szCode, ppro->m_VKLang))
+ SendMessage(hWndCombo, CB_SETCURSEL, i, 0);
}
CheckDlgButton(hwndDlg, IDC_DELIVERY, ppro->m_bServerDelivery ? BST_CHECKED : BST_UNCHECKED);
@@ -161,6 +175,10 @@ INT_PTR CALLBACK CVkProto::OptionsProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, L
if (HIWORD(wParam) == EN_CHANGE && (HWND)lParam == GetFocus())
SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
break;
+
+ case IDC_COMBO_LANGUAGE:
+ if (HIWORD(wParam) == CBN_SELCHANGE && (HWND)lParam == GetFocus())
+ SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
case IDC_DELIVERY:
case IDC_USE_LOCAL_TIME:
@@ -207,7 +225,13 @@ INT_PTR CALLBACK CVkProto::OptionsProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, L
ppro->setGroup(str);
ppro->setTString("ProtoGroup", str);
}
-
+
+ ppro->m_VKLang = mir_tstrdup((TCHAR*)SendMessage(hWndCombo, CB_GETITEMDATA, SendMessage(hWndCombo, CB_GETCURSEL, 0, 0), 0));
+ if (!IsEmpty(ppro->m_VKLang))
+ ppro->setTString("VKLang", ppro->m_VKLang);
+ else
+ ppro->delSetting("VKLang");
+
ppro->m_bServerDelivery = IsDlgButtonChecked(hwndDlg, IDC_DELIVERY) == BST_CHECKED;
ppro->setByte("ServerDelivery", ppro->m_bServerDelivery);
@@ -245,11 +269,6 @@ INT_PTR CALLBACK CVkProto::OptionsProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, L
case WM_CLOSE:
EndDialog(hwndDlg, 0);
break;
-
- case WM_DESTROY:
- IcoLib_ReleaseIcon((HICON)SendMessage(hwndDlg, WM_GETICON, ICON_BIG, 0));
- IcoLib_ReleaseIcon((HICON)SendMessage(hwndDlg, WM_GETICON, ICON_SMALL, 0));
- break;
}
return FALSE;
@@ -266,9 +285,6 @@ INT_PTR CALLBACK CVkProto::OptionsAdvProc(HWND hwndDlg, UINT uMsg, WPARAM wParam
ppro = (CVkProto*)lParam;
SetWindowLongPtr(hwndDlg, GWLP_USERDATA, lParam);
- SendMessage(hwndDlg, WM_SETICON, ICON_BIG, (LPARAM)IcoLib_GetIconByHandle(ppro->m_hProtoIcon, 1));
- SendMessage(hwndDlg, WM_SETICON, ICON_SMALL, (LPARAM)IcoLib_GetIconByHandle(ppro->m_hProtoIcon));
-
CheckDlgButton(hwndDlg, IDC_HIDECHATS, ppro->m_bHideChats ? BST_CHECKED : BST_UNCHECKED);
CheckDlgButton(hwndDlg, IDC_SYNC_MSG_STATUS, ppro->m_bSyncReadMessageStatusFromServer ? BST_CHECKED : BST_UNCHECKED);
@@ -400,11 +416,6 @@ INT_PTR CALLBACK CVkProto::OptionsAdvProc(HWND hwndDlg, UINT uMsg, WPARAM wParam
case WM_CLOSE:
EndDialog(hwndDlg, 0);
break;
-
- case WM_DESTROY:
- IcoLib_ReleaseIcon((HICON)SendMessage(hwndDlg, WM_GETICON, ICON_BIG, 0));
- IcoLib_ReleaseIcon((HICON)SendMessage(hwndDlg, WM_GETICON, ICON_SMALL, 0));
- break;
}
return FALSE;
@@ -421,9 +432,6 @@ INT_PTR CALLBACK CVkProto::OptionsFeedsProc(HWND hwndDlg, UINT uMsg, WPARAM wPar
ppro = (CVkProto*)lParam;
SetWindowLongPtr(hwndDlg, GWLP_USERDATA, lParam);
- SendMessage(hwndDlg, WM_SETICON, ICON_BIG, (LPARAM)IcoLib_GetIconByHandle(ppro->m_hProtoIcon, 1));
- SendMessage(hwndDlg, WM_SETICON, ICON_SMALL, (LPARAM)IcoLib_GetIconByHandle(ppro->m_hProtoIcon));
-
CheckDlgButton(hwndDlg, IDC_NEWS_ENBL, ppro->m_bNewsEnabled ? BST_CHECKED : BST_UNCHECKED);
CheckDlgButton(hwndDlg, IDC_NOTIF_ENBL, ppro->m_bNotificationsEnabled ? BST_CHECKED : BST_UNCHECKED);
CheckDlgButton(hwndDlg, IDC_NOTIF_MARK_VIEWED, ppro->m_bNotificationsMarkAsViewed ? BST_CHECKED : BST_UNCHECKED);
@@ -568,11 +576,6 @@ INT_PTR CALLBACK CVkProto::OptionsFeedsProc(HWND hwndDlg, UINT uMsg, WPARAM wPar
case WM_CLOSE:
EndDialog(hwndDlg, 0);
break;
-
- case WM_DESTROY:
- IcoLib_ReleaseIcon((HICON)SendMessage(hwndDlg, WM_GETICON, ICON_BIG, 0));
- IcoLib_ReleaseIcon((HICON)SendMessage(hwndDlg, WM_GETICON, ICON_SMALL, 0));
- break;
}
return FALSE;
@@ -589,9 +592,6 @@ INT_PTR CALLBACK CVkProto::OptionsViewProc(HWND hwndDlg, UINT uMsg, WPARAM wPara
ppro = (CVkProto*)lParam;
SetWindowLongPtr(hwndDlg, GWLP_USERDATA, lParam);
- SendMessage(hwndDlg, WM_SETICON, ICON_BIG, (LPARAM)IcoLib_GetIconByHandle(ppro->m_hProtoIcon, 1));
- SendMessage(hwndDlg, WM_SETICON, ICON_SMALL, (LPARAM)IcoLib_GetIconByHandle(ppro->m_hProtoIcon));
-
CheckDlgButton(hwndDlg, IDC_IMG_OFF, (ppro->m_iIMGBBCSupport == imgNo) ? BST_CHECKED : BST_UNCHECKED);
CheckDlgButton(hwndDlg, IDC_IMG_FULLSIZE, (ppro->m_iIMGBBCSupport == imgFullSize) ? BST_CHECKED : BST_UNCHECKED);
CheckDlgButton(hwndDlg, IDC_IMG_130, (ppro->m_iIMGBBCSupport == imgPreview130) ? BST_CHECKED : BST_UNCHECKED);
@@ -675,11 +675,6 @@ INT_PTR CALLBACK CVkProto::OptionsViewProc(HWND hwndDlg, UINT uMsg, WPARAM wPara
case WM_CLOSE:
EndDialog(hwndDlg, 0);
break;
-
- case WM_DESTROY:
- IcoLib_ReleaseIcon((HICON)SendMessage(hwndDlg, WM_GETICON, ICON_BIG, 0));
- IcoLib_ReleaseIcon((HICON)SendMessage(hwndDlg, WM_GETICON, ICON_SMALL, 0));
- break;
}
return FALSE;
diff --git a/protocols/VKontakte/src/vk_queue.cpp b/protocols/VKontakte/src/vk_queue.cpp
index 2f969937fc..a89f69ced3 100644
--- a/protocols/VKontakte/src/vk_queue.cpp
+++ b/protocols/VKontakte/src/vk_queue.cpp
@@ -81,7 +81,7 @@ void CVkProto::ExecuteRequest(AsyncHttpRequest *pReq)
}
debugLogA("CVkProto::ExecuteRequest pReq->bNeedsRestart = %d", (int)pReq->bNeedsRestart);
- if (!reply)
+ if (!reply && pReq->m_bApiReq)
m_hAPIConnection = NULL;
} while (pReq->bNeedsRestart && !m_bTerminated);
@@ -94,11 +94,12 @@ AsyncHttpRequest* CVkProto::Push(AsyncHttpRequest *pReq, int iTimeout)
{
debugLogA("CVkProto::Push");
pReq->timeout = iTimeout;
- if (pReq->m_bApiReq)
- {
- if (m_VKLang != nullptr) pReq << TCHAR_PARAM("lang", m_VKLang);
+ if (pReq->m_bApiReq) {
pReq << VER_API;
+ if (!IsEmpty(m_VKLang))
+ pReq << TCHAR_PARAM("lang", m_VKLang);
}
+
{
mir_cslock lck(m_csRequestsQueue);
m_arRequestsQueue.insert(pReq);
@@ -124,7 +125,6 @@ void CVkProto::WorkerThread(void*)
m_szAccessToken = NULL;
}
-
if (m_szAccessToken != NULL)
// try to receive a response from server
RetrieveMyInfo();
diff --git a/protocols/VKontakte/src/vk_struct.cpp b/protocols/VKontakte/src/vk_struct.cpp
index 6637e910d0..3568d8515c 100644
--- a/protocols/VKontakte/src/vk_struct.cpp
+++ b/protocols/VKontakte/src/vk_struct.cpp
@@ -44,20 +44,20 @@ AsyncHttpRequest::AsyncHttpRequest(CVkProto *ppro, int iRequestType, LPCSTR _url
bIsMainConn = false;
bExpUrlEncode = ppro->m_bUseNonStandardUrlEncode;
AddHeader("Connection", "keep-alive");
-
- flags = VK_NODUMPHEADERS | NLHRF_DUMPASTEXT | NLHRF_HTTP11 | NLHRF_REDIRECT;
- if (bSecure)
- flags |= NLHRF_SSL;
-
+
if (*_url == '/') { // relative url leads to a site
m_szUrl = ((bSecure) ? "https://" : "http://") + CMStringA("api.vk.com");
m_szUrl += _url;
bIsMainConn = true;
}
- else m_szUrl = _url;
+ else
+ m_szUrl = _url;
- if (bSecure)
+ flags = VK_NODUMPHEADERS | NLHRF_DUMPASTEXT | NLHRF_HTTP11 | NLHRF_REDIRECT;
+ if (bSecure) {
+ flags |= NLHRF_SSL;
this << CHAR_PARAM("access_token", ppro->m_szAccessToken);
+ }
requestType = iRequestType;
m_pFunc = pFunc;
diff --git a/protocols/VKontakte/src/vk_struct.h b/protocols/VKontakte/src/vk_struct.h
index d90d2c452d..c2fe4e50be 100644
--- a/protocols/VKontakte/src/vk_struct.h
+++ b/protocols/VKontakte/src/vk_struct.h
@@ -242,4 +242,9 @@ struct CVKChatContactTypingParam {
struct CVKInteres {
const char *szField;
TCHAR *ptszTranslate;
-}; \ No newline at end of file
+};
+
+struct CVKLang {
+ TCHAR *szCode;
+ TCHAR *szDescription;
+}; \ No newline at end of file