diff options
-rw-r--r-- | protocols/ICQ-WIM/src/http.cpp | 4 | ||||
-rw-r--r-- | protocols/ICQ-WIM/src/poll.cpp | 7 | ||||
-rw-r--r-- | protocols/ICQ-WIM/src/proto.cpp | 17 | ||||
-rw-r--r-- | protocols/ICQ-WIM/src/proto.h | 4 | ||||
-rw-r--r-- | protocols/ICQ-WIM/src/server.cpp | 39 | ||||
-rw-r--r-- | protocols/ICQ-WIM/src/stdafx.h | 1 | ||||
-rw-r--r-- | protocols/ICQ-WIM/src/version.h | 2 |
7 files changed, 53 insertions, 21 deletions
diff --git a/protocols/ICQ-WIM/src/http.cpp b/protocols/ICQ-WIM/src/http.cpp index 0ebbabe950..abc2af5996 100644 --- a/protocols/ICQ-WIM/src/http.cpp +++ b/protocols/ICQ-WIM/src/http.cpp @@ -240,7 +240,9 @@ void CIcqProto::Push(MHttpRequest *p) AsyncHttpRequest* operator<<(AsyncHttpRequest *pReq, const AIMSID ¶m) { pReq << CHAR_PARAM("f", "json") << CHAR_PARAM("aimsid", param.m_ppro->m_aimsid) << CHAR_PARAM("r", pReq->m_reqId); - pReq->flags |= NLHRF_NODUMPSEND; + #ifndef _DEBUG + pReq->flags |= NLHRF_NODUMPSEND; + #endif return pReq; } diff --git a/protocols/ICQ-WIM/src/poll.cpp b/protocols/ICQ-WIM/src/poll.cpp index f3fb53db7f..f14e30ba95 100644 --- a/protocols/ICQ-WIM/src/poll.cpp +++ b/protocols/ICQ-WIM/src/poll.cpp @@ -198,15 +198,18 @@ void CIcqProto::ProcessHistData(const JSONNode &ev) setId(hContact, DB_KEY_LASTMSGID, lastMsgId); } + __int64 patchVersion = _wtoi64(ev["patchVersion"].as_mstring()); + setId(hContact, DB_KEY_PATCHVER, patchVersion); + // we load history in the very beginning or if the previous message if (m_bFirstBos) { __int64 srvLastId = _wtoi64(ev["lastMsgId"].as_mstring()); if (srvLastId > lastMsgId) - RetrieveUserHistory(hContact, lastMsgId); + RetrieveUserHistory(hContact, lastMsgId, false); } else { for (auto &it : ev["tail"]["messages"]) - ParseMessage(hContact, lastMsgId, it, true); + ParseMessage(hContact, lastMsgId, it, false); setId(hContact, DB_KEY_LASTMSGID, lastMsgId); } diff --git a/protocols/ICQ-WIM/src/proto.cpp b/protocols/ICQ-WIM/src/proto.cpp index 9999c6a3c4..433b086bf5 100644 --- a/protocols/ICQ-WIM/src/proto.cpp +++ b/protocols/ICQ-WIM/src/proto.cpp @@ -125,6 +125,15 @@ void CIcqProto::OnModulesLoaded() gcr.pszModule = m_szModuleName; Chat_Register(&gcr); + CMenuItem mi(&g_plugin); + SET_UID(mi, 0xffe2c8fc, 0x9c4d, 0x4faf, 0xa2, 0x34, 0x3d, 0x19, 0x43, 0x0d, 0x31, 0x04); + mi.pszService = "/LoadHistory"; + mi.name.a = LPGEN("Load server history"); + mi.position = -200001004; + mi.hIcolibItem = Skin_GetIconHandle(SKINICON_OTHER_HISTORY); + Menu_AddContactMenuItem(&mi, m_szModuleName); + CreateProtoService(mi.pszService, &CIcqProto::OnMenuLoadHistory); + HookProtoEvent(ME_USERINFO_INITIALISE, &CIcqProto::OnUserInfoInit); } @@ -143,6 +152,14 @@ void CIcqProto::OnContactDeleted(MCONTACT hContact) << AIMSID(this) << WCHAR_PARAM("buddy", szId) << INT_PARAM("allGroups", 1)); } +INT_PTR CIcqProto::OnMenuLoadHistory(WPARAM hContact, LPARAM) +{ + delSetting(hContact, DB_KEY_LASTMSGID); + + RetrieveUserHistory(hContact, 1, true); + return 0; +} + ///////////////////////////////////////////////////////////////////////////////////////// void CIcqProto::OnBuildProtoMenu() diff --git a/protocols/ICQ-WIM/src/proto.h b/protocols/ICQ-WIM/src/proto.h index 6a06db66db..3caad36b20 100644 --- a/protocols/ICQ-WIM/src/proto.h +++ b/protocols/ICQ-WIM/src/proto.h @@ -243,7 +243,7 @@ class CIcqProto : public PROTO<CIcqProto> void MarkAsRead(MCONTACT hContact); void MoveContactToGroup(MCONTACT hContact, const wchar_t *pwszGroup, const wchar_t *pwszNewGroup); bool RetrievePassword(); - void RetrieveUserHistory(MCONTACT, __int64 startMsgId, __int64 endMsgId = -1); + void RetrieveUserHistory(MCONTACT, __int64 startMsgId, bool bFromHistory); void RetrieveUserInfo(MCONTACT = INVALID_CONTACT_ID); void SetServerStatus(int iNewStatus); void ShutdownSession(void); @@ -387,6 +387,8 @@ class CIcqProto : public PROTO<CIcqProto> INT_PTR __cdecl GotoInbox(WPARAM, LPARAM); INT_PTR __cdecl UploadGroups(WPARAM, LPARAM); + INT_PTR __cdecl OnMenuLoadHistory(WPARAM, LPARAM); + //////////////////////////////////////////////////////////////////////////////////////// // events diff --git a/protocols/ICQ-WIM/src/server.cpp b/protocols/ICQ-WIM/src/server.cpp index e88f38e96e..70f0bfe786 100644 --- a/protocols/ICQ-WIM/src/server.cpp +++ b/protocols/ICQ-WIM/src/server.cpp @@ -98,7 +98,9 @@ void CIcqProto::CheckPassword() auto *pReq = new AsyncHttpRequest(CONN_MAIN, REQUEST_POST, "https://api.login.icq.net/auth/clientLogin", &CIcqProto::OnCheckPassword); pReq << CHAR_PARAM("clientName", "Miranda NG") << CHAR_PARAM("clientVersion", mirVer) << CHAR_PARAM("devId", ICQ_APP_ID) << CHAR_PARAM("f", "json") << CHAR_PARAM("tokenType", "longTerm") << WCHAR_PARAM("s", m_szOwnId) << CHAR_PARAM("pwd", m_szPassword); - pReq->flags |= NLHRF_NODUMPSEND; + #ifndef _DEBUG + pReq->flags |= NLHRF_NODUMPSEND; + #endif Push(pReq); } else StartSession(); @@ -418,7 +420,7 @@ void CIcqProto::ParseMessage(MCONTACT hContact, __int64 &lastMsgId, const JSONNo return; bool bIsOutgoing = it["outgoing"].as_bool(); - if (!bIsOutgoing && wszText.Left(26) == L"https://files.icq.net/get/") { + if (!bFromHistory && !bIsOutgoing && wszText.Left(26) == L"https://files.icq.net/get/") { CMStringW wszUrl(wszText.Mid(26)); int idx = wszUrl.Find(' '); if (idx != -1) @@ -439,7 +441,8 @@ void CIcqProto::ParseMessage(MCONTACT hContact, __int64 &lastMsgId, const JSONNo ptrA szUtf(mir_utf8encodeW(wszText)); PROTORECVEVENT pre = {}; - pre.flags = (bIsOutgoing) ? PREF_SENT : 0; + if (bIsOutgoing) pre.flags |= PREF_SENT; + if (bFromHistory) pre.flags |= PREF_CREATEREAD; pre.szMsgId = szMsgId; pre.timestamp = iMsgTime; pre.szMessage = szUtf; @@ -453,7 +456,9 @@ bool CIcqProto::RefreshRobustToken() return true; auto *pReq = new AsyncHttpRequest(CONN_RAPI, REQUEST_POST, ICQ_ROBUST_SERVER "/genToken", &CIcqProto::OnGenToken); - pReq->flags |= NLHRF_NODUMPSEND; + #ifndef _DEBUG + pReq->flags |= NLHRF_NODUMPSEND; + #endif int ts = TS(); pReq << CHAR_PARAM("a", m_szAToken) << CHAR_PARAM("k", ICQ_APP_ID) << CHAR_PARAM("nonce", CMStringA(FORMAT, "%d-%d", ts, rand() % 10)) << INT_PARAM("ts", ts); @@ -467,7 +472,9 @@ bool CIcqProto::RefreshRobustToken() // now add this token bool bRet = false; pReq = new AsyncHttpRequest(CONN_RAPI, REQUEST_POST, ICQ_ROBUST_SERVER "/addClient", &CIcqProto::OnAddClient); - pReq->flags |= NLHRF_NODUMPSEND; + #ifndef _DEBUG + pReq->flags |= NLHRF_NODUMPSEND; + #endif pReq << CHAR_PARAM("a", m_szAToken) << CHAR_PARAM("f", "json") << CHAR_PARAM("k", ICQ_APP_ID) << INT_PARAM("ts", ts) << CHAR_PARAM("client", "icq") << CHAR_PARAM("reqId", pReq->m_reqId) << CHAR_PARAM("authToken", m_szRToken); pReq->pUserInfo = &bRet; @@ -510,25 +517,25 @@ AsyncHttpRequest* CIcqProto::UserInfoRequest(MCONTACT hContact) return pReq; } -void CIcqProto::RetrieveUserHistory(MCONTACT hContact, __int64 startMsgId, __int64 endMsgId) +void CIcqProto::RetrieveUserHistory(MCONTACT hContact, __int64 startMsgId, bool bFromHistory) { if (startMsgId == 0) startMsgId = -1; - if (endMsgId == 0) - endMsgId = -1; - - if (endMsgId != -1 && startMsgId >= endMsgId) - return; auto *pReq = new AsyncHttpRequest(CONN_RAPI, REQUEST_POST, ICQ_ROBUST_SERVER, &CIcqProto::OnGetUserHistory); - pReq->flags |= NLHRF_NODUMPSEND; + #ifndef _DEBUG + pReq->flags |= NLHRF_NODUMPSEND; + #endif pReq->hContact = hContact; + pReq->pUserInfo = (bFromHistory) ? pReq : nullptr; + + __int64 patchVer = getId(hContact, DB_KEY_PATCHVER); + if (patchVer == 0) + patchVer = 1; JSONNode request, params; params.set_name("params"); params << WCHAR_PARAM("sn", GetUserId(hContact)) << INT64_PARAM("fromMsgId", startMsgId); - if (endMsgId != -1) - params << INT64_PARAM("tillMsgId", endMsgId); - params << INT_PARAM("count", 1000) << CHAR_PARAM("aimSid", m_aimsid) << CHAR_PARAM("patchVersion", "1") << CHAR_PARAM("language", "ru-ru"); + params << INT_PARAM("count", 1000) << CHAR_PARAM("aimSid", m_aimsid) << SINT64_PARAM("patchVersion", patchVer) << CHAR_PARAM("language", "ru-ru"); request << CHAR_PARAM("method", "getHistory") << CHAR_PARAM("reqId", pReq->m_reqId) << params; pReq->m_szParam = ptrW(json_write(&request)); Push(pReq); @@ -896,7 +903,7 @@ void CIcqProto::OnGetUserHistory(NETLIBHTTPREQUEST *pReply, AsyncHttpRequest *pR auto &results = root.results(); for (auto &it : results["messages"]) - ParseMessage(pReq->hContact, lastMsgId, it, true); + ParseMessage(pReq->hContact, lastMsgId, it, pReq->pUserInfo != nullptr); setId(pReq->hContact, DB_KEY_LASTMSGID, lastMsgId); } diff --git a/protocols/ICQ-WIM/src/stdafx.h b/protocols/ICQ-WIM/src/stdafx.h index 66fe049022..6fba501966 100644 --- a/protocols/ICQ-WIM/src/stdafx.h +++ b/protocols/ICQ-WIM/src/stdafx.h @@ -89,6 +89,7 @@ #define DB_KEY_PHONEREG "PhoneReg" #define DB_KEY_LASTSEEN "LastSeen" #define DB_KEY_ONLINETS "OnlineTS" +#define DB_KEY_PATCHVER "PatchVersion" #define DB_KEY_RCLIENTID "RClientID" #define DB_KEY_LASTMSGID "LastMsgId" #define DB_KEY_REMOTEREAD "RemoteReadId" diff --git a/protocols/ICQ-WIM/src/version.h b/protocols/ICQ-WIM/src/version.h index e5a6a0cc92..e4e541daf0 100644 --- a/protocols/ICQ-WIM/src/version.h +++ b/protocols/ICQ-WIM/src/version.h @@ -1,7 +1,7 @@ #define __MAJOR_VERSION 0 #define __MINOR_VERSION 95 #define __RELEASE_NUM 11 -#define __BUILD_NUM 8 +#define __BUILD_NUM 9 #include <stdver.h> |