diff options
33 files changed, 104 insertions, 184 deletions
diff --git a/include/m_protoint.h b/include/m_protoint.h index d8367fb312..d0a40c5587 100644 --- a/include/m_protoint.h +++ b/include/m_protoint.h @@ -99,21 +99,6 @@ struct MIR_APP_EXPORT PROTO_INTERFACE : public MZeroedObject //////////////////////////////////////////////////////////////////////////////////////
// Helpers
- __inline void debugLogA(LPCSTR szFormat, ...)
- {
- va_list args;
- va_start(args, szFormat);
- ProtoLogA(this, szFormat, args);
- va_end(args);
- }
- __inline void debugLogW(LPCWSTR wszFormat, ...)
- {
- va_list args;
- va_start(args, wszFormat);
- ProtoLogW(this, wszFormat, args);
- va_end(args);
- }
-
__forceinline void WindowSubscribe(HWND hwnd) {
::ProtoWindowAdd(this, hwnd); }
__forceinline void WindowUnsubscribe(HWND hwnd) {
@@ -183,6 +168,14 @@ struct MIR_APP_EXPORT PROTO_INTERFACE : public MZeroedObject __forceinline void setWString(MCONTACT hContact, const char *name, const wchar_t* value) { db_set_ws(hContact, m_szModuleName, name, value); }
//////////////////////////////////////////////////////////////////////////////////////
+ // Service functions
+
+ void debugLogA(const char *szFormat, ...);
+ void debugLogW(const wchar_t *wszFormat, ...);
+
+ void setAllContactStatuses(int iStatus, bool bSkipChats = true);
+
+ //////////////////////////////////////////////////////////////////////////////////////
// Virtual functions
virtual MCONTACT __cdecl AddToList(int flags, PROTOSEARCHRESULT* psr);
diff --git a/libs/win32/mir_app.lib b/libs/win32/mir_app.lib Binary files differindex 1ad4944bc5..5a277efb35 100644 --- a/libs/win32/mir_app.lib +++ b/libs/win32/mir_app.lib diff --git a/libs/win64/mir_app.lib b/libs/win64/mir_app.lib Binary files differindex 3a4f05d465..1afae60c19 100644 --- a/libs/win64/mir_app.lib +++ b/libs/win64/mir_app.lib diff --git a/protocols/Discord/src/connection.cpp b/protocols/Discord/src/connection.cpp index 5d8f9677e2..9c3c36da40 100644 --- a/protocols/Discord/src/connection.cpp +++ b/protocols/Discord/src/connection.cpp @@ -87,7 +87,7 @@ void CDiscordProto::OnLoggedOut() ProtoBroadcastAck(0, ACKTYPE_STATUS, ACKRESULT_SUCCESS, (HANDLE)m_iStatus, ID_STATUS_OFFLINE); m_iStatus = m_iDesiredStatus = ID_STATUS_OFFLINE; - SetAllContactStatuses(ID_STATUS_OFFLINE); + setAllContactStatuses(ID_STATUS_OFFLINE, true); } void CDiscordProto::ShutdownSession() diff --git a/protocols/Discord/src/proto.cpp b/protocols/Discord/src/proto.cpp index e937ade657..fc935e20d0 100644 --- a/protocols/Discord/src/proto.cpp +++ b/protocols/Discord/src/proto.cpp @@ -148,7 +148,7 @@ int CDiscordProto::SetStatus(int iNewStatus) ShutdownSession(); } m_iStatus = m_iDesiredStatus; - SetAllContactStatuses(ID_STATUS_OFFLINE); + setAllContactStatuses(ID_STATUS_OFFLINE, true); ProtoBroadcastAck(0, ACKTYPE_STATUS, ACKRESULT_SUCCESS, (HANDLE)iOldStatus, m_iStatus); } diff --git a/protocols/Discord/src/proto.h b/protocols/Discord/src/proto.h index 5970ce26d3..c701a7b98a 100644 --- a/protocols/Discord/src/proto.h +++ b/protocols/Discord/src/proto.h @@ -132,7 +132,6 @@ class CDiscordProto : public PROTO<CDiscordProto> ////////////////////////////////////////////////////////////////////////////////////// // session control - void SetAllContactStatuses(int iStatus); void ConnectionFailed(int iReason); void ShutdownSession(void); diff --git a/protocols/Discord/src/utils.cpp b/protocols/Discord/src/utils.cpp index 0b37e53167..6e6d9700a7 100644 --- a/protocols/Discord/src/utils.cpp +++ b/protocols/Discord/src/utils.cpp @@ -17,16 +17,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. #include "stdafx.h" -void CDiscordProto::SetAllContactStatuses(int status) -{ - for (MCONTACT hContact = db_find_first(m_szModuleName); hContact; hContact = db_find_next(hContact, m_szModuleName)) { - if (!getByte(hContact, "ChatRoom")) - setWord(hContact, "Status", (WORD)status); - else if (status == ID_STATUS_OFFLINE) - Chat_Terminate(m_szModuleName, ptrW(getWStringA(hContact, "ChatRoomID"))); - } -} - int StrToStatus(const CMStringW &str) { if (str == L"idle") diff --git a/protocols/FacebookRM/src/connection.cpp b/protocols/FacebookRM/src/connection.cpp index c8c3bd2329..e66fb5b921 100644 --- a/protocols/FacebookRM/src/connection.cpp +++ b/protocols/FacebookRM/src/connection.cpp @@ -55,7 +55,7 @@ void FacebookProto::ChangeStatus(void*) facy.logout(); OnLeaveChat(NULL, NULL); - SetAllContactStatuses(ID_STATUS_OFFLINE); + setAllContactStatuses(ID_STATUS_OFFLINE); ToggleStatusMenuItems(false); delSetting(FACEBOOK_KEY_LOGON_TS); @@ -161,7 +161,7 @@ void FacebookProto::ChangeStatus(void*) else { // Change between online/away/invisible statuses if (new_status == ID_STATUS_INVISIBLE) // When switching to invisible (from online/away), we need to set all contacts offline as we won't receive no status updates from Facebook - SetAllContactStatuses(ID_STATUS_OFFLINE); + setAllContactStatuses(ID_STATUS_OFFLINE); } bool wasAwayOrInvisible = (old_status == ID_STATUS_AWAY || old_status == ID_STATUS_INVISIBLE); diff --git a/protocols/FacebookRM/src/contacts.cpp b/protocols/FacebookRM/src/contacts.cpp index 91d52145fd..415a6afb49 100644 --- a/protocols/FacebookRM/src/contacts.cpp +++ b/protocols/FacebookRM/src/contacts.cpp @@ -393,16 +393,6 @@ MCONTACT FacebookProto::AddToContactList(facebook_user* fbu, bool force_add, boo return hContact; } -void FacebookProto::SetAllContactStatuses(int status) -{ - for (MCONTACT hContact = db_find_first(m_szModuleName); hContact; hContact = db_find_next(hContact, m_szModuleName)) { - if (isChatRoom(hContact)) - continue; - - setWord(hContact, "Status", status); - } -} - void FacebookProto::DeleteContactFromServer(void *data) { facy.handle_entry("DeleteContactFromServer"); @@ -638,13 +628,11 @@ void FacebookProto::RefreshUserInfo(void *data) std::string homepage = FACEBOOK_URL_PROFILE + fbu.user_id; setString(hContact, "Homepage", homepage.c_str()); - if (!fbu.real_name.empty()) { + if (!fbu.real_name.empty()) SaveName(hContact, &fbu); - } - if (fbu.gender) { + if (fbu.gender) setByte(hContact, "Gender", fbu.gender); - } int oldType = getByte(hContact, FACEBOOK_KEY_CONTACT_TYPE, CONTACT_NONE); // From server we won't get request/approve types, only none, so we don't want to overwrite and lost it in that case @@ -653,9 +641,8 @@ void FacebookProto::RefreshUserInfo(void *data) } // If this contact is page, set it as invisible (if enabled in options) - if (getBool(FACEBOOK_KEY_PAGES_ALWAYS_ONLINE, DEFAULT_PAGES_ALWAYS_ONLINE) && fbu.type == CONTACT_PAGE) { + if (getBool(FACEBOOK_KEY_PAGES_ALWAYS_ONLINE, DEFAULT_PAGES_ALWAYS_ONLINE) && fbu.type == CONTACT_PAGE) setWord(hContact, "Status", ID_STATUS_INVISIBLE); - } CheckAvatarChange(hContact, fbu.image_url); @@ -686,26 +673,21 @@ void FacebookProto::RefreshUserInfo(void *data) std::string year = birthday.substr(pos2 + 2, 4); setWord(hContact, "BirthYear", atoi(year.c_str())); } - else { - // We have to set ANY year, otherwise UserInfoEx shows completely wrong date + else // We have to set ANY year, otherwise UserInfoEx shows completely wrong date setWord(hContact, "BirthYear", 1800); - } } } ProtoBroadcastAck(hContact, ACKTYPE_GETINFO, ACKRESULT_SUCCESS, (HANDLE)nullptr, 0); } - HANDLE FacebookProto::GetAwayMsg(MCONTACT) { return nullptr; // Status messages are disabled } -int FacebookProto::OnContactDeleted(WPARAM wParam, LPARAM) +int FacebookProto::OnContactDeleted(WPARAM hContact, LPARAM) { - MCONTACT hContact = (MCONTACT)wParam; - // Remove this contact from caches ptrA id(getStringA(hContact, FACEBOOK_KEY_ID)); if (id) diff --git a/protocols/FacebookRM/src/json.cpp b/protocols/FacebookRM/src/json.cpp index 01beebc0e4..c7d768c1e7 100644 --- a/protocols/FacebookRM/src/json.cpp +++ b/protocols/FacebookRM/src/json.cpp @@ -844,11 +844,10 @@ int FacebookProto::ParseMessages(std::string *pData, std::vector<facebook_messag for (auto itNodes = buddyList.begin(); itNodes != buddyList.end(); ++itNodes) { std::string id = (*itNodes).name(); + // Facebook now sends info also about some nonfriends, so we just ignore status change of contacts we don't have in list MCONTACT hContact = ContactIDToHContact(id); - if (!hContact) { - // Facebook now sends info also about some nonfriends, so we just ignore status change of contacts we don't have in list + if (!hContact) continue; - } // TODO: Check for friends existence/inexistence? Here we should get all friends (but we're already doing friendslist request, so we should have fresh data already) @@ -880,27 +879,18 @@ int FacebookProto::ParseMessages(std::string *pData, std::vector<facebook_messag delSetting(hContact, "LastActiveTS"); // Set users inactive for too long as offline - if (last_active > 0 && last_active < offlineThreshold) { + if (last_active > 0 && last_active < offlineThreshold) setWord(hContact, "Status", ID_STATUS_OFFLINE); - } } // Probably means client: guess 0 = web, 8 = messenger, 10 = something else? if (vc_) { - int vc = vc_.as_int(); wchar_t *client; - - if (vc == 0) { - client = FACEBOOK_CLIENT_WEB; - } - else if (vc == 8) { - client = FACEBOOK_CLIENT_MESSENGER; // I was online on Miranda, but when looked at myself at messenger.com I had icon of Messenger. - } - else if (vc == 10) { - client = FACEBOOK_CLIENT_MOBILE; - } - else { - client = FACEBOOK_CLIENT_OTHER; + switch (vc_.as_int()) { + case 0: client = FACEBOOK_CLIENT_WEB; break; + case 8: client = FACEBOOK_CLIENT_MESSENGER; break; + case 10: client = FACEBOOK_CLIENT_MOBILE; break; + default: client = FACEBOOK_CLIENT_OTHER; break; } setWString(hContact, "MirVer", client); } diff --git a/protocols/FacebookRM/src/proto.cpp b/protocols/FacebookRM/src/proto.cpp index 4d42208359..f365cee0ea 100644 --- a/protocols/FacebookRM/src/proto.cpp +++ b/protocols/FacebookRM/src/proto.cpp @@ -99,7 +99,7 @@ FacebookProto::FacebookProto(const char* proto_name, const wchar_t* username) : facy.set_handle(m_hNetlibUser); // Set all contacts offline -- in case we crashed - SetAllContactStatuses(ID_STATUS_OFFLINE); + setAllContactStatuses(ID_STATUS_OFFLINE); // register special type of event // there's no need to declare the special service for getting text diff --git a/protocols/FacebookRM/src/proto.h b/protocols/FacebookRM/src/proto.h index d3306433f9..779b6bc11d 100644 --- a/protocols/FacebookRM/src/proto.h +++ b/protocols/FacebookRM/src/proto.h @@ -221,7 +221,6 @@ public: std::string ThreadIDToContactID(const std::string&); void LoadContactInfo(facebook_user* fbu); MCONTACT AddToContactList(facebook_user*, bool force_add = false, bool add_temporarily = false); - void SetAllContactStatuses(int status); MCONTACT HContactFromAuthEvent(MEVENT hEvent); void StartTyping(MCONTACT hContact); void StopTyping(MCONTACT hContact); diff --git a/protocols/MSN/src/msn_auth.cpp b/protocols/MSN/src/msn_auth.cpp index 228792b274..c9a2715370 100644 --- a/protocols/MSN/src/msn_auth.cpp +++ b/protocols/MSN/src/msn_auth.cpp @@ -330,8 +330,9 @@ int debugLogSkyLoginA(void *Pproto, LPCSTR szFormat, ...) va_list args;
va_start(args, szFormat);
- ProtoLogA(pProto, szFormat, args);
+ CMStringA body; body.FormatV(szFormat, args);
va_end(args);
+ pProto->debugLogA("%s", body.c_str());
return 1;
}
diff --git a/protocols/MSN/src/msn_misc.cpp b/protocols/MSN/src/msn_misc.cpp index 9a7f7157bf..8376d8b8f4 100644 --- a/protocols/MSN/src/msn_misc.cpp +++ b/protocols/MSN/src/msn_misc.cpp @@ -368,24 +368,7 @@ void CMsnProto::MSN_GoOffline(void) int msnOldStatus = m_iStatus; m_iStatus = m_iDesiredStatus = ID_STATUS_OFFLINE;
ProtoBroadcastAck(NULL, ACKTYPE_STATUS, ACKRESULT_SUCCESS, (HANDLE)msnOldStatus, ID_STATUS_OFFLINE);
isIdle = false;
-
- MCONTACT hContact = NULL;
-
- for (hContact = db_find_first(m_szModuleName); hContact;
- hContact = db_find_next(hContact, m_szModuleName))
- {
- if (isChatRoom(hContact) != 0) {
- ptrW wszRoom(getWStringA(hContact, "ChatRoomID"));
- if (wszRoom != NULL)
- Chat_Control(m_szModuleName, wszRoom, SESSION_OFFLINE);
- }
- else {
- if (ID_STATUS_OFFLINE != getWord(hContact, "Status", ID_STATUS_OFFLINE)) {
- setWord(hContact, "Status", ID_STATUS_OFFLINE);
- setDword(hContact, "IdleTS", 0);
- }
- }
- }
+ setAllContactStatuses(ID_STATUS_OFFLINE, true);
}
}
diff --git a/protocols/MinecraftDynmap/src/communication.cpp b/protocols/MinecraftDynmap/src/communication.cpp index ccc7405596..f82f4030e4 100644 --- a/protocols/MinecraftDynmap/src/communication.cpp +++ b/protocols/MinecraftDynmap/src/communication.cpp @@ -409,9 +409,6 @@ void MinecraftDynmapProto::SignOffWorker(void*) ProtoBroadcastAck(0, ACKTYPE_STATUS, ACKRESULT_SUCCESS, (HANDLE)old_status, m_iStatus); - //SetAllContactStatuses(ID_STATUS_OFFLINE); - //ToggleStatusMenuItems(false); - if (hConnection) Netlib_CloseHandle(hConnection); hConnection = nullptr; diff --git a/protocols/SkypeWeb/src/skype_accounts.cpp b/protocols/SkypeWeb/src/skype_accounts.cpp index 1e54acb021..f5c01b0c4f 100644 --- a/protocols/SkypeWeb/src/skype_accounts.cpp +++ b/protocols/SkypeWeb/src/skype_accounts.cpp @@ -51,7 +51,7 @@ CSkypeProto* CSkypeProto::GetContactAccount(MCONTACT hContact) int CSkypeProto::OnAccountLoaded(WPARAM, LPARAM)
{
- SetAllContactsStatus(ID_STATUS_OFFLINE);
+ setAllContactStatuses(ID_STATUS_OFFLINE, true);
HookProtoEvent(ME_OPT_INITIALISE, &CSkypeProto::OnOptionsInit);
HookProtoEvent(ME_MSG_PRECREATEEVENT, &CSkypeProto::OnPreCreateMessage);
diff --git a/protocols/SkypeWeb/src/skype_chatrooms.cpp b/protocols/SkypeWeb/src/skype_chatrooms.cpp index 9dbb8032a8..78ea23d170 100644 --- a/protocols/SkypeWeb/src/skype_chatrooms.cpp +++ b/protocols/SkypeWeb/src/skype_chatrooms.cpp @@ -32,22 +32,6 @@ void CSkypeProto::InitGroupChatModule() CreateProtoService(PS_LEAVECHAT, &CSkypeProto::OnLeaveChatRoom);
}
-void CSkypeProto::CloseAllChatChatSessions()
-{
- GC_INFO gci = { 0 };
- gci.Flags = GCF_BYINDEX | GCF_ID;
- gci.pszModule = m_szModuleName;
-
- int count = pci->SM_GetCount(m_szModuleName);
- for (int i = 0; i < count; i++) {
- gci.iItem = i;
- if (!Chat_GetInfo(&gci)) {
- Chat_Control(m_szModuleName, gci.pszID, SESSION_OFFLINE);
- Chat_Terminate(m_szModuleName, gci.pszID);
- }
- }
-}
-
MCONTACT CSkypeProto::FindChatRoom(const char *chatname)
{
SESSION_INFO *si = pci->SM_FindSession(_A2T(chatname), m_szModuleName);
diff --git a/protocols/SkypeWeb/src/skype_contacts.cpp b/protocols/SkypeWeb/src/skype_contacts.cpp index 58b7f8ea82..1ee5fbe0a3 100644 --- a/protocols/SkypeWeb/src/skype_contacts.cpp +++ b/protocols/SkypeWeb/src/skype_contacts.cpp @@ -32,16 +32,6 @@ void CSkypeProto::SetContactStatus(MCONTACT hContact, WORD status) }
}
-void CSkypeProto::SetAllContactsStatus(WORD status)
-{
- for (MCONTACT hContact = db_find_first(m_szModuleName); hContact; hContact = db_find_next(hContact, m_szModuleName)) {
- if (!isChatRoom(hContact))
- SetContactStatus(hContact, status);
- }
- if (status == ID_STATUS_OFFLINE)
- CloseAllChatChatSessions();
-}
-
void CSkypeProto::SetChatStatus(MCONTACT hContact, int iStatus)
{
ptrW tszChatID(getWStringA(hContact, "ChatRoomID"));
diff --git a/protocols/SkypeWeb/src/skype_proto.cpp b/protocols/SkypeWeb/src/skype_proto.cpp index 58406f4630..8535578bde 100644 --- a/protocols/SkypeWeb/src/skype_proto.cpp +++ b/protocols/SkypeWeb/src/skype_proto.cpp @@ -261,7 +261,7 @@ int CSkypeProto::SetStatus(int iNewStatus) ProtoBroadcastAck(NULL, ACKTYPE_STATUS, ACKRESULT_SUCCESS, (HANDLE)old_status, ID_STATUS_OFFLINE); if (!Miranda_IsTerminated()) - SetAllContactsStatus(ID_STATUS_OFFLINE); + setAllContactStatuses(ID_STATUS_OFFLINE, true); return 0; } else { diff --git a/protocols/SkypeWeb/src/skype_proto.h b/protocols/SkypeWeb/src/skype_proto.h index cc70467445..21a14c69c1 100644 --- a/protocols/SkypeWeb/src/skype_proto.h +++ b/protocols/SkypeWeb/src/skype_proto.h @@ -279,7 +279,6 @@ private: // contacts
WORD GetContactStatus(MCONTACT hContact);
void SetContactStatus(MCONTACT hContact, WORD status);
- void SetAllContactsStatus(WORD status);
void SetAvatarUrl(MCONTACT hContact, CMStringW &tszUrl);
void ReloadAvatarInfo(MCONTACT hContact);
@@ -325,15 +324,12 @@ private: // sync
void OnGetServerHistory(const NETLIBHTTPREQUEST *response);
void OnSyncHistory(const NETLIBHTTPREQUEST *response);
- void SyncHistory();
//chats
void InitGroupChatModule();
- void CloseAllChatChatSessions();
MCONTACT FindChatRoom(const char *chatname);
- MCONTACT AddChatRoom(const char *chatname);
int __cdecl OnGroupChatEventHook(WPARAM, LPARAM lParam);
int __cdecl OnGroupChatMenuHook(WPARAM, LPARAM lParam);
diff --git a/protocols/Steam/src/steam_contacts.cpp b/protocols/Steam/src/steam_contacts.cpp index fddad8a4a5..98f06662de 100644 --- a/protocols/Steam/src/steam_contacts.cpp +++ b/protocols/Steam/src/steam_contacts.cpp @@ -48,12 +48,6 @@ void CSteamProto::SetContactStatus(MCONTACT hContact, WORD status) } } -void CSteamProto::SetAllContactsStatus(WORD status) -{ - for (MCONTACT hContact = db_find_first(m_szModuleName); hContact; hContact = db_find_next(hContact, m_szModuleName)) - SetContactStatus(hContact, status); -} - MCONTACT CSteamProto::GetContactFromAuthEvent(MEVENT hEvent) { DWORD body[3]; diff --git a/protocols/Steam/src/steam_polling.cpp b/protocols/Steam/src/steam_polling.cpp index 78ffd06c8b..2397b7531c 100644 --- a/protocols/Steam/src/steam_polling.cpp +++ b/protocols/Steam/src/steam_polling.cpp @@ -11,8 +11,7 @@ void CSteamProto::ParsePollData(const JSONNode &data) time_t timestamp = _wtol(item["utc_timestamp"].as_mstring()); MCONTACT hContact = NULL; - if (!IsMe(steamId.c_str()) && - !(hContact = FindContact(steamId.c_str()))) + if (!IsMe(steamId.c_str()) && !(hContact = FindContact(steamId.c_str()))) // probably this is info about random player playing on same server, so we ignore it continue; @@ -79,35 +78,30 @@ void CSteamProto::ParsePollData(const JSONNode &data) switch (state) { case 0: - {// removed - MCONTACT hContact = FindContact(steamId.c_str()); - if (hContact) - ContactIsRemoved(hContact); - } + hContact = FindContact(steamId.c_str()); + if (hContact) + ContactIsRemoved(hContact); break; case 1: - {// ignored - MCONTACT hContact = FindContact(steamId.c_str()); - if (hContact) - ContactIsIgnored(hContact); - } + hContact = FindContact(steamId.c_str()); + if (hContact) + ContactIsIgnored(hContact); break; case 2: - {// auth request - MCONTACT hContact = FindContact(steamId.c_str()); - if (hContact) - ContactIsAskingAuth(hContact); - else - { - // load info about this user from server - ptrA token(getStringA("TokenSecret")); - - PushRequest( - new GetUserSummariesRequest(token, steamId.c_str()), - &CSteamProto::OnAuthRequested); - } + // auth request + hContact = FindContact(steamId.c_str()); + if (hContact) + ContactIsAskingAuth(hContact); + else + { + // load info about this user from server + ptrA token(getStringA("TokenSecret")); + + PushRequest( + new GetUserSummariesRequest(token, steamId.c_str()), + &CSteamProto::OnAuthRequested); } break; diff --git a/protocols/Steam/src/steam_proto.cpp b/protocols/Steam/src/steam_proto.cpp index fd7d5cf9d8..52022b10d5 100644 --- a/protocols/Steam/src/steam_proto.cpp +++ b/protocols/Steam/src/steam_proto.cpp @@ -46,7 +46,7 @@ CSteamProto::CSteamProto(const char* protoName, const wchar_t* userName) db_set_resident(m_szModuleName, "ServerIP"); db_set_resident(m_szModuleName, "ServerID"); - SetAllContactsStatus(ID_STATUS_OFFLINE); + setAllContactStatuses(ID_STATUS_OFFLINE); // services CreateServiceFunction(MODULE"/MenuChoose", CSteamProto::MenuChooseService); @@ -318,7 +318,7 @@ int CSteamProto::SetStatus(int new_status) m_iStatus = m_iDesiredStatus = ID_STATUS_OFFLINE; if (!Miranda_IsTerminated()) - SetAllContactsStatus(ID_STATUS_OFFLINE); + setAllContactStatuses(ID_STATUS_OFFLINE); LogOut(); } diff --git a/protocols/Steam/src/steam_proto.h b/protocols/Steam/src/steam_proto.h index fee78f4b02..d53e21b009 100644 --- a/protocols/Steam/src/steam_proto.h +++ b/protocols/Steam/src/steam_proto.h @@ -147,7 +147,6 @@ protected: // contacts
void SetContactStatus(MCONTACT hContact, WORD status);
- void SetAllContactsStatus(WORD status);
MCONTACT GetContactFromAuthEvent(MEVENT hEvent);
diff --git a/protocols/Twitter/src/connection.cpp b/protocols/Twitter/src/connection.cpp index 95e83c0a47..98928756ca 100644 --- a/protocols/Twitter/src/connection.cpp +++ b/protocols/Twitter/src/connection.cpp @@ -67,7 +67,8 @@ void TwitterProto::SignOn(void*) if (!in_chat_ && getByte(TWITTER_KEY_CHATFEED))
OnJoinChat(0, true);
- SetAllContactStatuses(ID_STATUS_ONLINE);
+ setAllContactStatuses(ID_STATUS_ONLINE);
+ SetChatStatus(ID_STATUS_ONLINE);
hMsgLoop_ = ForkThreadEx(&TwitterProto::MessageLoop, nullptr, nullptr);
}
diff --git a/protocols/Twitter/src/contacts.cpp b/protocols/Twitter/src/contacts.cpp index ea8d299c22..b71f6a011f 100644 --- a/protocols/Twitter/src/contacts.cpp +++ b/protocols/Twitter/src/contacts.cpp @@ -263,12 +263,3 @@ MCONTACT TwitterProto::AddToClientList(const char *name, const char *status) return 0;
}
-
-void TwitterProto::SetAllContactStatuses(int status)
-{
- for (MCONTACT hContact = db_find_first(m_szModuleName); hContact; hContact = db_find_next(hContact, m_szModuleName))
- if (!getByte(hContact, "ChatRoom"))
- setWord(hContact, "Status", (WORD)status);
-
- SetChatStatus(status);
-}
diff --git a/protocols/Twitter/src/proto.cpp b/protocols/Twitter/src/proto.cpp index ccb1132806..5db294c884 100644 --- a/protocols/Twitter/src/proto.cpp +++ b/protocols/Twitter/src/proto.cpp @@ -177,7 +177,8 @@ int TwitterProto::SetStatus(int new_status) else if (new_status == ID_STATUS_OFFLINE) {
twit_.Disconnect();
m_iStatus = m_iDesiredStatus;
- SetAllContactStatuses(ID_STATUS_OFFLINE);
+ setAllContactStatuses(ID_STATUS_OFFLINE);
+ SetChatStatus(ID_STATUS_OFFLINE);
ProtoBroadcastAck(0, ACKTYPE_STATUS, ACKRESULT_SUCCESS, (HANDLE)old_status, m_iStatus);
}
@@ -342,7 +343,8 @@ int TwitterProto::OnModulesLoaded(WPARAM, LPARAM) evt.flags = DETF_HISTORY | DETF_MSGWINDOW;
DbEvent_RegisterType(&evt);
- SetAllContactStatuses(ID_STATUS_OFFLINE); // In case we crashed last time
+ setAllContactStatuses(ID_STATUS_OFFLINE); // In case we crashed last time
+ SetChatStatus(ID_STATUS_OFFLINE);
return 0;
}
diff --git a/protocols/Twitter/src/proto.h b/protocols/Twitter/src/proto.h index 8484917775..6ebf15a124 100644 --- a/protocols/Twitter/src/proto.h +++ b/protocols/Twitter/src/proto.h @@ -95,7 +95,6 @@ private: bool IsMyContact(MCONTACT, bool include_chat = false);
MCONTACT UsernameToHContact(const char *);
MCONTACT AddToClientList(const char *, const char *);
- void SetAllContactStatuses(int);
static void CALLBACK APC_callback(ULONG_PTR p);
diff --git a/src/mir_app/src/mir_app.def b/src/mir_app/src/mir_app.def index 73fd746295..304f189b4f 100644 --- a/src/mir_app/src/mir_app.def +++ b/src/mir_app/src/mir_app.def @@ -122,8 +122,6 @@ ProtoGetAvatarFileFormat @120 ProtoGetAvatarFormat @121
ProtoGetBufferFormat @122
ProtoHookEvent @123
-ProtoLogA @124
-ProtoLogW @125
ProtoWindowAdd @126
ProtoWindowRemove @127
Proto_IsProtocolLoaded @128
@@ -492,3 +490,4 @@ Srmm_GetColorTable @496 Contact_Add @497
Contact_AddByEvent @498
Contact_AddBySearch @499
+?setAllContactStatuses@PROTO_INTERFACE@@QAEXH_N@Z @500 NONAME
diff --git a/src/mir_app/src/mir_app64.def b/src/mir_app/src/mir_app64.def index defbe2c365..93bdf48d98 100644 --- a/src/mir_app/src/mir_app64.def +++ b/src/mir_app/src/mir_app64.def @@ -122,8 +122,6 @@ ProtoGetAvatarFileFormat @120 ProtoGetAvatarFormat @121
ProtoGetBufferFormat @122
ProtoHookEvent @123
-ProtoLogA @124
-ProtoLogW @125
ProtoWindowAdd @126
ProtoWindowRemove @127
Proto_IsProtocolLoaded @128
@@ -492,3 +490,4 @@ Srmm_GetColorTable @496 Contact_Add @497
Contact_AddByEvent @498
Contact_AddBySearch @499
+?setAllContactStatuses@PROTO_INTERFACE@@QEAAXH_N@Z @500 NONAME
diff --git a/src/mir_app/src/netliblog.cpp b/src/mir_app/src/netliblog.cpp index 09c08b9f67..0e34498d99 100644 --- a/src/mir_app/src/netliblog.cpp +++ b/src/mir_app/src/netliblog.cpp @@ -352,18 +352,26 @@ int NetlibLog_Worker(NetlibUser *nlu, const char *pszMsg, int flags) /////////////////////////////////////////////////////////////////////////////////////////
-MIR_APP_DLL(void) ProtoLogA(PROTO_INTERFACE *pThis, LPCSTR szFormat, va_list args)
+void PROTO_INTERFACE::debugLogA(const char *szFormat, ...)
{
char buf[4096];
+ va_list args;
+ va_start(args, szFormat);
int res = _vsnprintf(buf, _countof(buf), szFormat, args);
- NetlibLog_Worker(pThis ? pThis->m_hNetlibUser : nullptr, (res != -1) ? buf : CMStringA().FormatV(szFormat, args), 0);
+ va_end(args);
+
+ NetlibLog_Worker(m_hNetlibUser, (res != -1) ? buf : CMStringA().FormatV(szFormat, args), 0);
}
-MIR_APP_DLL(void) ProtoLogW(PROTO_INTERFACE *pThis, LPCWSTR wszFormat, va_list args)
+void PROTO_INTERFACE::debugLogW(const wchar_t *wszFormat, ...)
{
WCHAR buf[4096];
+ va_list args;
+ va_start(args, wszFormat);
int res = _vsnwprintf(buf, _countof(buf), wszFormat, args);
- NetlibLog_Worker(pThis ? pThis->m_hNetlibUser : nullptr, ptrA(Utf8EncodeW((res != -1) ? buf : CMStringW().FormatV(wszFormat, args))), 0);
+ va_end(args);
+
+ NetlibLog_Worker(m_hNetlibUser, ptrA(Utf8EncodeW((res != -1) ? buf : CMStringW().FormatV(wszFormat, args))), 0);
}
/////////////////////////////////////////////////////////////////////////////////////////
diff --git a/src/mir_app/src/netlibsecurity.cpp b/src/mir_app/src/netlibsecurity.cpp index 0c678ea6b7..de31d4e74f 100644 --- a/src/mir_app/src/netlibsecurity.cpp +++ b/src/mir_app/src/netlibsecurity.cpp @@ -224,13 +224,13 @@ char* NtlmCreateResponseFromChallenge(HANDLE hSecurity, const char *szChallenge, return nullptr;
if (isGSSAPI && complete)
- return CompleteGssapi(hSecurity, token, tokenLen);
+ return CompleteGssapi(hSecurity, token, (unsigned)tokenLen);
inputBufferDescriptor.cBuffers = 1;
inputBufferDescriptor.pBuffers = &inputSecurityToken;
inputBufferDescriptor.ulVersion = SECBUFFER_VERSION;
inputSecurityToken.BufferType = SECBUFFER_TOKEN;
- inputSecurityToken.cbBuffer = tokenLen;
+ inputSecurityToken.cbBuffer = (unsigned)tokenLen;
inputSecurityToken.pvBuffer = token;
// try to decode the domain name from the NTLM challenge
diff --git a/src/mir_app/src/proto_utils.cpp b/src/mir_app/src/proto_utils.cpp index b68942c8ea..13b4a14e52 100644 --- a/src/mir_app/src/proto_utils.cpp +++ b/src/mir_app/src/proto_utils.cpp @@ -62,6 +62,23 @@ MIR_APP_DLL(INT_PTR) ProtoBroadcastAck(const char *szModule, MCONTACT hContact, /////////////////////////////////////////////////////////////////////////////////////////
+void PROTO_INTERFACE::setAllContactStatuses(int iStatus, bool bSkipChats)
+{
+ for (MCONTACT hContact = db_find_first(m_szModuleName); hContact; hContact = db_find_next(hContact, m_szModuleName)) {
+ if (isChatRoom(hContact)) {
+ if (!bSkipChats && iStatus == ID_STATUS_OFFLINE) {
+ ptrW wszRoom(getWStringA(hContact, "ChatRoomID"));
+ if (wszRoom != nullptr)
+ Chat_Control(m_szModuleName, wszRoom, SESSION_OFFLINE);
+ }
+ }
+ else setWord(hContact, "Status", iStatus);
+ }
+}
+
+/////////////////////////////////////////////////////////////////////////////////////////
+// protocol constructor & destructor
+
MIR_APP_DLL(void) ProtoConstructor(PROTO_INTERFACE *pThis, LPCSTR pszModuleName, LPCTSTR ptszUserName)
{
pThis->m_iVersion = 2;
@@ -80,6 +97,9 @@ MIR_APP_DLL(void) ProtoDestructor(PROTO_INTERFACE *pThis) WindowList_Destroy(pThis->m_hWindowList);
}
+/////////////////////////////////////////////////////////////////////////////////////////
+// protocol services
+
MIR_APP_DLL(void) ProtoCreateService(PROTO_INTERFACE *pThis, const char* szService, ProtoServiceFunc serviceProc)
{
char str[MAXMODULELABELLENGTH * 2];
@@ -96,6 +116,9 @@ MIR_APP_DLL(void) ProtoCreateServiceParam(PROTO_INTERFACE *pThis, const char* sz ::CreateServiceFunctionObjParam(str, (MIRANDASERVICEOBJPARAM)*(void**)&serviceProc, pThis, lParam);
}
+/////////////////////////////////////////////////////////////////////////////////////////
+// protocol events
+
MIR_APP_DLL(void) ProtoHookEvent(PROTO_INTERFACE *pThis, const char* szEvent, ProtoEventFunc handler)
{
::HookEventObj(szEvent, (MIRANDAHOOKOBJ)*(void**)&handler, pThis);
@@ -109,6 +132,9 @@ MIR_APP_DLL(HANDLE) ProtoCreateHookableEvent(PROTO_INTERFACE *pThis, const char* return CreateHookableEvent(str);
}
+/////////////////////////////////////////////////////////////////////////////////////////
+// protocol threads
+
MIR_APP_DLL(void) ProtoForkThread(PROTO_INTERFACE *pThis, ProtoThreadFunc pFunc, void *param)
{
UINT threadID;
@@ -121,6 +147,9 @@ MIR_APP_DLL(HANDLE) ProtoForkThreadEx(PROTO_INTERFACE *pThis, ProtoThreadFunc pF return (HANDLE)::mir_forkthreadowner((pThreadFuncOwner)*(void**)&pFunc, pThis, param, threadID ? threadID : <hreadID);
}
+/////////////////////////////////////////////////////////////////////////////////////////
+// protocol windows
+
MIR_APP_DLL(void) ProtoWindowAdd(PROTO_INTERFACE *pThis, HWND hwnd)
{
if (pThis->m_hWindowList == nullptr)
@@ -135,6 +164,7 @@ MIR_APP_DLL(void) ProtoWindowRemove(PROTO_INTERFACE *pThis, HWND hwnd) }
/////////////////////////////////////////////////////////////////////////////////////////
+// avatar support
MIR_APP_DLL(LPCTSTR) ProtoGetAvatarExtension(int format)
{
|