summaryrefslogtreecommitdiff
path: root/protocols/VKontakte
diff options
context:
space:
mode:
Diffstat (limited to 'protocols/VKontakte')
-rw-r--r--protocols/VKontakte/res/resource.rc43
-rw-r--r--protocols/VKontakte/src/misc.cpp11
-rw-r--r--protocols/VKontakte/src/resource.h4
-rw-r--r--protocols/VKontakte/src/version.h2
-rw-r--r--protocols/VKontakte/src/vk_options.cpp15
-rw-r--r--protocols/VKontakte/src/vk_proto.cpp1
-rw-r--r--protocols/VKontakte/src/vk_proto.h5
-rw-r--r--protocols/VKontakte/src/vk_thread.cpp25
8 files changed, 75 insertions, 31 deletions
diff --git a/protocols/VKontakte/res/resource.rc b/protocols/VKontakte/res/resource.rc
index f8458123cd..81d766ca73 100644
--- a/protocols/VKontakte/res/resource.rc
+++ b/protocols/VKontakte/res/resource.rc
@@ -71,7 +71,7 @@ BEGIN
LEFTMARGIN, 4
RIGHTMARGIN, 297
TOPMARGIN, 7
- BOTTOMMARGIN, 169
+ BOTTOMMARGIN, 187
END
IDD_OPT_MAIN, DIALOG
@@ -189,31 +189,34 @@ BEGIN
CONTROL "Open VKontakte site",IDC_URL,"Hyperlink",WS_TABSTOP,0,49,174,12
END
-IDD_OPT_ADV DIALOGEX 0, 0, 304, 179
+IDD_OPT_ADV DIALOGEX 0, 0, 304, 197
STYLE DS_SETFONT | DS_FIXEDSYS | WS_CHILD
EXSTYLE WS_EX_CONTROLPARENT
FONT 8, "MS Shell Dlg", 0, 0, 0x1
BEGIN
- GROUPBOX "Advanced",IDC_STATIC,4,8,293,57
+ GROUPBOX "Advanced",IDC_STATIC,4,8,293,75
CONTROL "Hide chats on startup",IDC_HIDECHATS,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,12,19,278,10
CONTROL "Always notify as unread for all incoming message",IDC_MESASUREAD,
"Button",BS_AUTOCHECKBOX | WS_TABSTOP,12,30,278,10
- CONTROL "Force online status upon user activity",IDC_FORCE_ONLINE_ON_ACT,
+ CONTROL "Force ivisible status upon user activity",IDC_FORCE_ONLINE_ON_ACT,
"Button",BS_AUTOCHECKBOX | WS_TABSTOP,12,41,278,10
+ LTEXT "Invisible interval timeout (min):",IDC_STATIC,16,56,184,8
+ EDITTEXT IDC_ED_INT_INVIS,204,52,40,14,ES_RIGHT | ES_AUTOHSCROLL | ES_NUMBER
+ CONTROL "",IDC_SPIN_INT_INVIS,"msctls_updown32",UDS_SETBUDDYINT | UDS_ALIGNRIGHT | UDS_AUTOBUDDY | UDS_ARROWKEYS,244,52,14,14
CONTROL "Use non-standard urlEncode for sent messages (less traffic)",IDC_USENOSTDURLENCODE,
- "Button",BS_AUTOCHECKBOX | WS_TABSTOP,12,52,278,10
- GROUPBOX "When I ban user...",IDC_STATIC,4,66,293,33
- CONTROL "Report abuse",IDC_REPORT_ABUSE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,12,76,129,10
- CONTROL "Clear server history",IDC_CLEAR_SERVER_HISTORY,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,12,87,129,10
+ "Button",BS_AUTOCHECKBOX | WS_TABSTOP,12,67,278,10
+ GROUPBOX "When I ban user...",IDC_STATIC,4,84,293,33
+ CONTROL "Report abuse",IDC_REPORT_ABUSE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,12,94,129,10
+ CONTROL "Clear server history",IDC_CLEAR_SERVER_HISTORY,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,12,105,129,10
CONTROL "Remove from friend list",IDC_REMOVE_FROM_FRENDLIST,
- "Button",BS_AUTOCHECKBOX | WS_TABSTOP,148,76,141,10
- CONTROL "Remove from contact list",IDC_REMOVE_FROM_CLIST,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,148,87,141,10
- GROUPBOX "Broadcast music...",IDC_STATIC_SEND_MUSIC_METOD,4,102,293,58,WS_GROUP
- CONTROL "off",IDC_SEND_MUSIC_NONE,"Button",BS_AUTORADIOBUTTON | WS_TABSTOP,12,113,278,10
+ "Button",BS_AUTOCHECKBOX | WS_TABSTOP,148,94,141,10
+ CONTROL "Remove from contact list",IDC_REMOVE_FROM_CLIST,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,148,105,141,10
+ GROUPBOX "Broadcast music...",IDC_STATIC_SEND_MUSIC_METOD,4,120,293,58,WS_GROUP
+ CONTROL "off",IDC_SEND_MUSIC_NONE,"Button",BS_AUTORADIOBUTTON | WS_TABSTOP,12,131,278,10
CONTROL "as regular status for unknown music and audio status otherwise",IDC_SEND_MUSIC_BROADCAST_AND_STATUS,
- "Button",BS_AUTORADIOBUTTON | WS_TABSTOP,12,124,278,11
- CONTROL "as audio status only",IDC_SEND_MUSIC_BROADCAST,"Button",BS_AUTORADIOBUTTON | WS_TABSTOP,12,135,278,10
- CONTROL "as regular status only",IDC_SEND_MUSIC_STATUS,"Button",BS_AUTORADIOBUTTON | WS_TABSTOP,12,146,278,10
+ "Button",BS_AUTORADIOBUTTON | WS_TABSTOP,12,142,278,10
+ CONTROL "as audio status only",IDC_SEND_MUSIC_BROADCAST,"Button",BS_AUTORADIOBUTTON | WS_TABSTOP,12,153,278,10
+ CONTROL "as regular status only",IDC_SEND_MUSIC_STATUS,"Button",BS_AUTORADIOBUTTON | WS_TABSTOP,12,164,278,10
END
IDD_OPT_MAIN DIALOGEX 0, 0, 304, 213
@@ -222,11 +225,11 @@ EXSTYLE WS_EX_CONTROLPARENT
FONT 8, "MS Shell Dlg", 0, 0, 0x1
BEGIN
GROUPBOX "Login settings",IDC_STATIC,4,8,293,50
- RTEXT "E-mail or phone number:",IDC_STATIC,12,16,150,10
- EDITTEXT IDC_LOGIN,167,15,121,12,ES_AUTOHSCROLL
- RTEXT "Password:",IDC_STATIC,12,28,150,10
- EDITTEXT IDC_PASSWORD,167,28,121,12,ES_PASSWORD | ES_AUTOHSCROLL
- CONTROL "Open VKontakte site",IDC_URL,"Hyperlink",WS_TABSTOP,59,43,174,11
+ RTEXT "E-mail or phone number:",IDC_STATIC,12,17,150,10
+ EDITTEXT IDC_LOGIN,167,16,121,12,ES_AUTOHSCROLL
+ RTEXT "Password:",IDC_STATIC,12,29,150,10
+ EDITTEXT IDC_PASSWORD,167,29,121,12,ES_PASSWORD | ES_AUTOHSCROLL
+ CONTROL "Open VKontakte site",IDC_URL,"Hyperlink",WS_TABSTOP,59,44,174,11
GROUPBOX "Local settings",IDC_STATIC,4,59,293,65
RTEXT "Contact list group:",IDC_STATIC,12,71,150,8
EDITTEXT IDC_GROUPNAME,167,69,121,12,ES_AUTOHSCROLL
diff --git a/protocols/VKontakte/src/misc.cpp b/protocols/VKontakte/src/misc.cpp
index f29488d1a2..71c109a042 100644
--- a/protocols/VKontakte/src/misc.cpp
+++ b/protocols/VKontakte/src/misc.cpp
@@ -1136,4 +1136,15 @@ CMString CVkProto::GetFwdMessages(JSONNODE *pMessages, BBCSupport iBBC)
}
return res;
+}
+
+/////////////////////////////////////////////////////////////////////////////////////////
+
+void CVkProto::SetInvisible(MCONTACT hContact)
+{
+ if (getWord(hContact, "Status", ID_STATUS_OFFLINE) == ID_STATUS_OFFLINE) {
+ setWord(hContact, "Status", ID_STATUS_INVISIBLE);
+ SetMirVer(hContact, 1);
+ }
+ setDword(hContact, "InvisibleTS", time(NULL));
} \ No newline at end of file
diff --git a/protocols/VKontakte/src/resource.h b/protocols/VKontakte/src/resource.h
index bba391dc78..3d12fda3a5 100644
--- a/protocols/VKontakte/src/resource.h
+++ b/protocols/VKontakte/src/resource.h
@@ -94,6 +94,8 @@
#define IDC_ATTBBC_ADV 1086
#define IDC_BBC_ATT_NEWS 1087
#define IDC_USENOSTDURLENCODE 1088
+#define IDC_ED_INT_INVIS 1089
+#define IDC_SPIN_INT_INVIS 1090
// Next default values for new objects
//
@@ -102,7 +104,7 @@
#define _APS_NO_MFC 1
#define _APS_NEXT_RESOURCE_VALUE 119
#define _APS_NEXT_COMMAND_VALUE 40001
-#define _APS_NEXT_CONTROL_VALUE 1089
+#define _APS_NEXT_CONTROL_VALUE 1091
#define _APS_NEXT_SYMED_VALUE 101
#endif
#endif
diff --git a/protocols/VKontakte/src/version.h b/protocols/VKontakte/src/version.h
index 297890e4f4..12403c908a 100644
--- a/protocols/VKontakte/src/version.h
+++ b/protocols/VKontakte/src/version.h
@@ -1,7 +1,7 @@
#define __MAJOR_VERSION 0
#define __MINOR_VERSION 1
#define __RELEASE_NUM 0
-#define __BUILD_NUM 46
+#define __BUILD_NUM 47
#include <stdver.h>
diff --git a/protocols/VKontakte/src/vk_options.cpp b/protocols/VKontakte/src/vk_options.cpp
index 7ec03871e3..9ab932541a 100644
--- a/protocols/VKontakte/src/vk_options.cpp
+++ b/protocols/VKontakte/src/vk_options.cpp
@@ -257,10 +257,18 @@ INT_PTR CALLBACK CVkProto::OptionsAdvProc(HWND hwndDlg, UINT uMsg, WPARAM wParam
CheckDlgButton(hwndDlg, IDC_SEND_MUSIC_STATUS, (ppro->m_iMusicSendMetod == sendStatusOnly) ? BST_CHECKED : BST_UNCHECKED);
CheckDlgButton(hwndDlg, IDC_SEND_MUSIC_BROADCAST_AND_STATUS, (ppro->m_iMusicSendMetod == sendBroadcastAndStatus) ? BST_CHECKED : BST_UNCHECKED);
+ SendDlgItemMessage(hwndDlg, IDC_SPIN_INT_INVIS, UDM_SETRANGE, 0, MAKELONG(60, 0));
+ SendDlgItemMessage(hwndDlg, IDC_SPIN_INT_INVIS, UDM_SETPOS, 0, ppro->m_iInvisibleInterval);
+
return TRUE;
case WM_COMMAND:
switch (LOWORD(wParam)) {
+ case IDC_ED_INT_INVIS:
+ if ((HWND)lParam == GetFocus() && (HIWORD(wParam) == EN_CHANGE))
+ SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
+ break;
+
case IDC_HIDECHATS:
case IDC_MESASUREAD:
case IDC_FORCE_ONLINE_ON_ACT:
@@ -280,6 +288,9 @@ INT_PTR CALLBACK CVkProto::OptionsAdvProc(HWND hwndDlg, UINT uMsg, WPARAM wParam
break;
case WM_NOTIFY:
+ if (((LPNMHDR)lParam)->code == UDN_DELTAPOS)
+ SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
+
if (((LPNMHDR)lParam)->code == PSN_APPLY) {
ppro->m_bHideChats = IsDlgButtonChecked(hwndDlg, IDC_HIDECHATS) == BST_CHECKED;
ppro->setByte("HideChats", ppro->m_bHideChats);
@@ -317,6 +328,10 @@ INT_PTR CALLBACK CVkProto::OptionsAdvProc(HWND hwndDlg, UINT uMsg, WPARAM wParam
CMStringA szListeningTo(ppro->m_szModuleName);
szListeningTo += "Enabled";
db_set_b(NULL, "ListeningTo", szListeningTo.GetBuffer(), ppro->m_iMusicSendMetod == 0 ? 0 : 1);
+
+ TCHAR buffer[5] = { 0 };
+ GetDlgItemText(hwndDlg, IDC_ED_INT_INVIS, buffer, SIZEOF(buffer));
+ ppro->setDword("InvisibleInterval", ppro->m_iInvisibleInterval = _ttoi(buffer));
}
break;
diff --git a/protocols/VKontakte/src/vk_proto.cpp b/protocols/VKontakte/src/vk_proto.cpp
index 633056f5b0..eb156680b4 100644
--- a/protocols/VKontakte/src/vk_proto.cpp
+++ b/protocols/VKontakte/src/vk_proto.cpp
@@ -108,6 +108,7 @@ CVkProto::CVkProto(const char *szModuleName, const TCHAR *ptszUserName) :
m_bNotificationFilterMentions = getBool("NotificationFilterMentions", true);
m_bUseNonStandardUrlEncode = getBool("UseNonStandardUrlEncode", true);
+ m_iInvisibleInterval = getDword("InvisibleInterval", 10);
m_bSetBroadcast = false;
// Set all contacts offline -- in case we crashed
diff --git a/protocols/VKontakte/src/vk_proto.h b/protocols/VKontakte/src/vk_proto.h
index e70d399565..8bd95bdc02 100644
--- a/protocols/VKontakte/src/vk_proto.h
+++ b/protocols/VKontakte/src/vk_proto.h
@@ -423,6 +423,8 @@ struct CVkProto : public PROTO<CVkProto>
CMString GetAttachmentDescr(JSONNODE*, BBCSupport iBBC = bbcNo);
CMString GetFwdMessages(JSONNODE *pMessages, BBCSupport iBBC = bbcNo);
+ void SetInvisible(MCONTACT hContact);
+
//====================================================================================
void RetrieveStatusMsg(const CMString &StatusMsg);
@@ -592,7 +594,8 @@ private:
int m_iNewsInterval,
m_iNotificationsInterval,
m_iNewsAutoClearHistoryInterval,
- m_iMaxLoadNewsPhoto;
+ m_iMaxLoadNewsPhoto,
+ m_iInvisibleInterval;
enum MarkMsgReadOn { markOnRead, markOnReceive, markOnReply, markOnTyping };
MarkMsgReadOn m_iMarkMessageReadOn;
diff --git a/protocols/VKontakte/src/vk_thread.cpp b/protocols/VKontakte/src/vk_thread.cpp
index 034cecd7e3..a0aadbfbdd 100644
--- a/protocols/VKontakte/src/vk_thread.cpp
+++ b/protocols/VKontakte/src/vk_thread.cpp
@@ -114,8 +114,10 @@ void CVkProto::SetServerStatus(int iNewStatus)
ptrT ptszListeningToMsg(db_get_tsa(NULL, m_szModuleName, "ListeningTo"));
if (iNewStatus == ID_STATUS_OFFLINE) {
- if (!IsEmpty(ptszListeningToMsg) && m_bSetBroadcast)
+ if (!IsEmpty(ptszListeningToMsg) && m_bSetBroadcast) {
RetrieveStatusMsg(oldStatusMsg);
+ m_bSetBroadcast = false;
+ }
m_iStatus = ID_STATUS_OFFLINE;
if (iOldStatus != ID_STATUS_OFFLINE && iOldStatus != ID_STATUS_INVISIBLE)
Push(new AsyncHttpRequest(this, REQUEST_GET, "/method/account.setOffline.json", true, &CVkProto::OnReceiveSmth)
@@ -127,8 +129,10 @@ void CVkProto::SetServerStatus(int iNewStatus)
<< VER_API);
}
else {
- if (!IsEmpty(ptszListeningToMsg) && m_bSetBroadcast)
+ if (!IsEmpty(ptszListeningToMsg) && m_bSetBroadcast) {
RetrieveStatusMsg(oldStatusMsg);
+ m_bSetBroadcast = false;
+ }
m_iStatus = ID_STATUS_INVISIBLE;
if (iOldStatus == ID_STATUS_ONLINE)
Push(new AsyncHttpRequest(this, REQUEST_GET, "/method/account.setOffline.json", true, &CVkProto::OnReceiveSmth)
@@ -467,9 +471,14 @@ void CVkProto::OnReceiveUserInfo(NETLIBHTTPREQUEST *reply, AsyncHttpRequest *pRe
LONG userID = getDword(hContact, "ID", -1);
if (userID == m_myUserId || userID == VK_FEED_USER)
continue;
- if (getWord(hContact, "Status", ID_STATUS_OFFLINE) != ID_STATUS_OFFLINE)
+
+ int iContactStatus = getWord(hContact, "Status", ID_STATUS_OFFLINE);
+
+ if ((iContactStatus == ID_STATUS_ONLINE)
+ || (iContactStatus == ID_STATUS_INVISIBLE && time(NULL) - getDword(hContact, "InvisibleTS", 0) >= m_iInvisibleInterval * 60)) {
setWord(hContact, "Status", ID_STATUS_OFFLINE);
- SetMirVer(hContact, -1);
+ SetMirVer(hContact, -1);
+ }
db_unset(hContact, m_szModuleName, "ListeningTo");
}
arContacts.destroy();
@@ -695,7 +704,7 @@ void CVkProto::OnReceiveMessages(NETLIBHTTPREQUEST *reply, AsyncHttpRequest *pRe
if (isOut)
recv.flags |= PREF_SENT;
else if (m_bUserForceOnlineOnActivity)
- setWord(hContact, "Status", ID_STATUS_ONLINE);
+ SetInvisible(hContact);
recv.timestamp = m_bUseLocalTime ? time(NULL) : datetime;
recv.tszMessage = ptszBody;
@@ -843,7 +852,7 @@ void CVkProto::PollUpdates(JSONNODE *pUpdates)
SetSrmmReadStatus(hContact);
}
if (m_bUserForceOnlineOnActivity)
- setWord(hContact, "Status", ID_STATUS_ONLINE);
+ SetInvisible(hContact);
}
break;
@@ -868,7 +877,7 @@ void CVkProto::PollUpdates(JSONNODE *pUpdates)
setDword(hContact, "LastMsgReadTime", time(NULL));
SetSrmmReadStatus(hContact);
if (m_bUserForceOnlineOnActivity)
- setWord(hContact, "Status", ID_STATUS_ONLINE);
+ SetInvisible(hContact);
}
break;
@@ -892,7 +901,7 @@ void CVkProto::PollUpdates(JSONNODE *pUpdates)
if (hContact != NULL) {
ForkThread(&CVkProto::ContactTypingThread, (void *)hContact);
if (m_bUserForceOnlineOnActivity)
- setWord(hContact, "Status", ID_STATUS_ONLINE);
+ SetInvisible(hContact);
}
break;