diff options
Diffstat (limited to 'protocols/VKontakte')
-rw-r--r-- | protocols/VKontakte/src/misc.cpp | 32 | ||||
-rw-r--r-- | protocols/VKontakte/src/vk.h | 2 | ||||
-rw-r--r-- | protocols/VKontakte/src/vk_proto.cpp | 16 | ||||
-rw-r--r-- | protocols/VKontakte/src/vk_proto.h | 5 | ||||
-rw-r--r-- | protocols/VKontakte/src/vk_struct.h | 6 | ||||
-rw-r--r-- | protocols/VKontakte/src/vk_thread.cpp | 13 |
6 files changed, 72 insertions, 2 deletions
diff --git a/protocols/VKontakte/src/misc.cpp b/protocols/VKontakte/src/misc.cpp index 3691ae82ff..d078df244c 100644 --- a/protocols/VKontakte/src/misc.cpp +++ b/protocols/VKontakte/src/misc.cpp @@ -1451,4 +1451,34 @@ void CVkProto::ShowCaptchaInBrowser(HBITMAP hBitmap) wszHTMLPath = L"file://" + wszHTMLPath;
Utils_OpenUrlW(wszHTMLPath);
-}
\ No newline at end of file +}
+
+void CVkProto::AddVkDeactivateEvent(MCONTACT hContact, CMStringW& wszType)
+{
+ CVKDeactivateEvent vkDeactivateEvent[] = {
+ { L"", Translate("User restored control over own page") },
+ { L"deleted", Translate("User was deactivated (deleted)") },
+ { L"banned", Translate("User was deactivated (banned)") }
+ };
+
+ int iDEIdx = -1;
+ for (int i = 0; i < _countof(vkDeactivateEvent); i++)
+ if (wszType == vkDeactivateEvent[i].wszType) {
+ iDEIdx = i;
+ break;
+ }
+
+ if (iDEIdx == -1)
+ return;
+
+ DBEVENTINFO dbei;
+ dbei.cbSize = sizeof(dbei);
+ dbei.szModule = m_szModuleName;
+ dbei.timestamp = time(NULL);
+ dbei.eventType = VK_USER_DEACTIVATE_ACTION;
+ dbei.cbBlob = mir_strlen(vkDeactivateEvent[iDEIdx].szDescription) + 1;
+ dbei.pBlob = (PBYTE)mir_strdup(vkDeactivateEvent[iDEIdx].szDescription);
+ dbei.flags = DBEF_UTF;
+ db_event_add(hContact, &dbei);
+}
+
diff --git a/protocols/VKontakte/src/vk.h b/protocols/VKontakte/src/vk.h index d7329b27ac..509ff56ff2 100644 --- a/protocols/VKontakte/src/vk.h +++ b/protocols/VKontakte/src/vk.h @@ -80,6 +80,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. #define VKERR_INVALID_URL 10106 // Upload server returned empty URL
#define VKERR_INVALID_USER 10107 // Invalid or unknown recipient user ID
+#define VK_USER_DEACTIVATE_ACTION 9321
+
#define VK_API_VER "5.59"
#define VER_API CHAR_PARAM("v", VK_API_VER)
diff --git a/protocols/VKontakte/src/vk_proto.cpp b/protocols/VKontakte/src/vk_proto.cpp index e45cbede37..c50f2559a1 100644 --- a/protocols/VKontakte/src/vk_proto.cpp +++ b/protocols/VKontakte/src/vk_proto.cpp @@ -124,6 +124,7 @@ int CVkProto::OnModulesLoaded(WPARAM, LPARAM) InitPopups();
InitMenus();
+ InitDBCustomEvents();
return 0;
}
@@ -470,6 +471,21 @@ void CVkProto::MsgPopup(MCONTACT hContact, const wchar_t *wszMsg, const wchar_t //////////////////////////////////////////////////////////////////////////////
+void CVkProto::InitDBCustomEvents()
+{
+ // custom event
+ DBEVENTTYPEDESCR dbEventType = { sizeof(dbEventType) };
+ dbEventType.module = m_szModuleName;
+ dbEventType.flags = DETF_HISTORY | DETF_MSGWINDOW;
+
+ dbEventType.eventType = VK_USER_DEACTIVATE_ACTION;
+ dbEventType.descr = Translate("VK user activate/deactivate action");
+ DbEvent_RegisterType(&dbEventType);
+
+}
+
+//////////////////////////////////////////////////////////////////////////////
+
int CVkProto::OnPreShutdown(WPARAM, LPARAM)
{
debugLogA("CVkProto::OnPreShutdown");
diff --git a/protocols/VKontakte/src/vk_proto.h b/protocols/VKontakte/src/vk_proto.h index 81fb1db44a..96bcf10ed2 100644 --- a/protocols/VKontakte/src/vk_proto.h +++ b/protocols/VKontakte/src/vk_proto.h @@ -120,7 +120,7 @@ struct CVkProto : public PROTO<CVkProto> void ClearAccessToken();
wchar_t* GetUserStoredPassword(void);
void ShowCaptchaInBrowser(HBITMAP hBitmap);
-
+
static mir_cs m_csTimer;
static UINT_PTR m_timer;
CVKOptions m_vkOptions;
@@ -234,6 +234,8 @@ private: void InitPopups(void);
void MsgPopup(MCONTACT hContact, const wchar_t *wszMsg, const wchar_t *wszTitle, bool err = false);
+ void InitDBCustomEvents();
+
//==== Hooks =========================================================================
int __cdecl OnProcessSrmmEvent(WPARAM, LPARAM);
@@ -350,6 +352,7 @@ private: CMStringW GetFwdMessages(const JSONNode &jnMessages, const JSONNode &jnFUsers, BBCSupport iBBC = bbcNo);
void SetInvisible(MCONTACT hContact);
CMStringW RemoveBBC(CMStringW& wszSrc);
+ void AddVkDeactivateEvent(MCONTACT hContact, CMStringW & wszType);
void InitQueue();
void UninitQueue();
void ExecuteRequest(AsyncHttpRequest*);
diff --git a/protocols/VKontakte/src/vk_struct.h b/protocols/VKontakte/src/vk_struct.h index 8d787a6101..a17d056278 100644 --- a/protocols/VKontakte/src/vk_struct.h +++ b/protocols/VKontakte/src/vk_struct.h @@ -360,4 +360,10 @@ struct CVKOptions { __forceinline BBCSupport BBCForNews() { return (BBCSupport)(BYTE)iBBCForNews; };
__forceinline BBCSupport BBCForAttachments() { return (BBCSupport)(BYTE)iBBCForAttachments; };
+};
+
+
+struct CVKDeactivateEvent {
+ wchar_t *wszType;
+ char *szDescription;
};
\ No newline at end of file diff --git a/protocols/VKontakte/src/vk_thread.cpp b/protocols/VKontakte/src/vk_thread.cpp index b546761193..38fad14848 100644 --- a/protocols/VKontakte/src/vk_thread.cpp +++ b/protocols/VKontakte/src/vk_thread.cpp @@ -298,6 +298,19 @@ MCONTACT CVkProto::SetContactInfo(const JSONNode &jnItem, bool flag, bool self) if (!wszNick.IsEmpty())
setWString(hContact, "Nick", wszNick);
+ wszValue = jnItem["deactivated"].as_mstring();
+ CMStringW wszOldDeactivated(ptrW(db_get_wsa(hContact, m_szModuleName, "Deactivated")));
+ if (wszValue != wszOldDeactivated) {
+ AddVkDeactivateEvent(hContact, wszValue);
+ if (wszValue.IsEmpty())
+ db_unset(hContact, m_szModuleName, "Deactivated");
+ else
+ setWString(hContact, "Deactivated", wszValue);
+ }
+
+ if (!wszValue.IsEmpty())
+ return hContact;
+
int sex = jnItem["sex"].as_int();
if (sex)
setByte(hContact, "Gender", sex == 2 ? 'M' : 'F');
|