From e5d58fc3bbbce2773b7c6c3f8b7da6faa66b672e Mon Sep 17 00:00:00 2001 From: George Hazan Date: Sat, 17 Sep 2016 16:37:24 +0000 Subject: chats: more functions, less structures git-svn-id: http://svn.miranda-ng.org/main/trunk@17309 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- protocols/JabberG/src/jabber_chat.cpp | 37 ++++++++++++------------------ protocols/JabberG/src/jabber_groupchat.cpp | 24 ++++++++----------- protocols/JabberG/src/jabber_iqid.cpp | 2 +- protocols/JabberG/src/jabber_proto.cpp | 2 +- 4 files changed, 26 insertions(+), 39 deletions(-) (limited to 'protocols/JabberG/src') diff --git a/protocols/JabberG/src/jabber_chat.cpp b/protocols/JabberG/src/jabber_chat.cpp index 32e353d586..61dff34c3d 100644 --- a/protocols/JabberG/src/jabber_chat.cpp +++ b/protocols/JabberG/src/jabber_chat.cpp @@ -128,7 +128,7 @@ int CJabberProto::GcInit(JABBER_LIST_ITEM *item) ptrW szNick(JabberNickFromJID(item->jid)); - GCSESSION gcw = { sizeof(GCSESSION) }; + GCSESSION gcw = {}; gcw.iType = GCW_CHATROOM; gcw.pszModule = m_szModuleName; gcw.ptszName = szNick; @@ -168,15 +168,14 @@ int CJabberProto::GcInit(JABBER_LIST_ITEM *item) item->bChatActive = true; GCDEST gcd = { m_szModuleName, item->jid, GC_EVENT_ADDGROUP }; - GCEVENT gce = { sizeof(gce), &gcd }; + GCEVENT gce = { &gcd }; for (int i = _countof(sttStatuses) - 1; i >= 0; i--) { gce.ptszStatus = TranslateW(sttStatuses[i]); - Chat_Event(0, &gce); + Chat_Event(&gce); } - gcd.iType = GC_EVENT_CONTROL; - Chat_Event((item->bAutoJoin && m_options.AutoJoinHidden) ? WINDOW_HIDDEN : SESSION_INITDONE, &gce); - Chat_Event(SESSION_ONLINE, &gce); + Chat_Control(m_szModuleName, item->jid, (item->bAutoJoin && m_options.AutoJoinHidden) ? WINDOW_HIDDEN : SESSION_INITDONE); + Chat_Control(m_szModuleName, item->jid, SESSION_ONLINE); return 0; } @@ -243,13 +242,13 @@ void CJabberProto::GcLogShowInformation(JABBER_LIST_ITEM *item, pResourceStatus buf.Replace(L"%", L"%%"); GCDEST gcd = { m_szModuleName, item->jid, GC_EVENT_INFORMATION }; - GCEVENT gce = { sizeof(gce), &gcd }; + GCEVENT gce = { &gcd }; gce.ptszNick = user->m_tszResourceName; gce.ptszUID = user->m_tszResourceName; gce.ptszText = buf; gce.dwFlags = GCEF_ADDTOLOG; gce.time = time(0); - Chat_Event(0, &gce); + Chat_Event(&gce); } } @@ -270,7 +269,7 @@ void CJabberProto::GcLogUpdateMemberStatus(JABBER_LIST_ITEM *item, const wchar_t myNick = JabberNickFromJID(m_szJabberJID); GCDEST gcd = { m_szModuleName, item->jid }; - GCEVENT gce = { sizeof(gce), &gcd }; + GCEVENT gce = { &gcd }; gce.ptszNick = nick; gce.ptszUID = resource; if (jid != NULL) @@ -308,21 +307,19 @@ void CJabberProto::GcLogUpdateMemberStatus(JABBER_LIST_ITEM *item, const wchar_t } } - Chat_Event(0, &gce); + Chat_Event(&gce); if (statusToSet != 0) { - gce.ptszText = nick; + int flags = GC_SSE_ONLYLISTED; if (statusToSet == ID_STATUS_AWAY || statusToSet == ID_STATUS_NA || statusToSet == ID_STATUS_DND) - gce.dwItemData = 3; - else - gce.dwItemData = 1; - gcd.iType = GC_EVENT_SETSTATUSEX; - Chat_Event(0, &gce); + flags += GC_SSE_ONLINE; + Chat_SetStatusEx(m_szModuleName, item->jid, flags, nick); + gce.ptszText = nick; gce.ptszUID = resource; gce.dwItemData = statusToSet; gcd.iType = GC_EVENT_SETCONTACTSTATUS; - Chat_Event(0, &gce); + Chat_Event(&gce); } } @@ -342,11 +339,7 @@ void CJabberProto::GcQuit(JABBER_LIST_ITEM *item, int code, HXML reason) GcLogUpdateMemberStatus(item, myNick, myNick, NULL, GC_EVENT_KICK, reason); } - GCDEST gcd = { m_szModuleName, item->jid, GC_EVENT_CONTROL }; - GCEVENT gce = { sizeof(gce), &gcd }; - gce.ptszUID = item->jid; - gce.ptszText = XmlGetText(reason); - Chat_Event((code == 200) ? SESSION_TERMINATE : SESSION_OFFLINE, &gce); + Chat_Control(m_szModuleName, item->jid, (code == 200) ? SESSION_TERMINATE : SESSION_OFFLINE); db_unset(item->hContact, "CList", "Hidden"); item->bChatActive = false; diff --git a/protocols/JabberG/src/jabber_groupchat.cpp b/protocols/JabberG/src/jabber_groupchat.cpp index 6e6306ab66..a690f4f8ff 100644 --- a/protocols/JabberG/src/jabber_groupchat.cpp +++ b/protocols/JabberG/src/jabber_groupchat.cpp @@ -795,20 +795,17 @@ void CJabberProto::RenameParticipantNick(JABBER_LIST_ITEM *item, const wchar_t * setWString(hContact, "MyNick", newNick); } - GCDEST gcd = { m_szModuleName, item->jid, GC_EVENT_CHUID }; - GCEVENT gce = { sizeof(gce), &gcd }; - gce.ptszNick = oldNick; - gce.ptszText = newNick; + Chat_ChangeUserId(m_szModuleName, item->jid, oldNick, newNick); + + GCDEST gcd = { m_szModuleName, item->jid, GC_EVENT_NICK }; + GCEVENT gce = { &gcd }; if (jid != NULL) gce.ptszUserInfo = jid; gce.time = time(0); - Chat_Event(0, &gce); - - gcd.iType = GC_EVENT_NICK; gce.ptszNick = oldNick; gce.ptszUID = newNick; gce.ptszText = newNick; - Chat_Event(0, &gce); + Chat_Event(&gce); } void CJabberProto::GroupchatProcessPresence(HXML node) @@ -1110,7 +1107,7 @@ void CJabberProto::GroupchatProcessMessage(HXML node) tszText.Replace(L"%", L"%%"); tszText += imgLink; - GCEVENT gce = { sizeof(gce), &gcd }; + GCEVENT gce = { &gcd }; gce.ptszUID = resource; gce.ptszNick = nick; gce.time = msgTime; @@ -1123,15 +1120,12 @@ void CJabberProto::GroupchatProcessMessage(HXML node) if (m_options.GcLogChatHistory && isHistory) gce.dwFlags |= GCEF_NOTNOTIFY; - Chat_Event(0, &gce); + Chat_Event(&gce); item->bChatActive = 2; - if (gcd.iType == GC_EVENT_TOPIC) { - gce.dwFlags &= ~GCEF_ADDTOLOG; - gcd.iType = GC_EVENT_SETSBTEXT; - Chat_Event(0, &gce); - } + if (gcd.iType == GC_EVENT_TOPIC) + Chat_SetStatusbarText(m_szModuleName, item->jid, tszText); } ///////////////////////////////////////////////////////////////////////////////////////// diff --git a/protocols/JabberG/src/jabber_iqid.cpp b/protocols/JabberG/src/jabber_iqid.cpp index 597c513f64..bbf2407010 100644 --- a/protocols/JabberG/src/jabber_iqid.cpp +++ b/protocols/JabberG/src/jabber_iqid.cpp @@ -440,7 +440,7 @@ void CJabberProto::OnIqResultGetRoster(HXML iqNode, CJabberIqInfo *pInfo) else db_unset(hContact, "CList", "MyHandle"); if (isChatRoom(hContact)) { - GCSESSION gcw = { sizeof(gcw) }; + GCSESSION gcw = {}; gcw.iType = GCW_CHATROOM; gcw.pszModule = m_szModuleName; gcw.ptszID = jid; diff --git a/protocols/JabberG/src/jabber_proto.cpp b/protocols/JabberG/src/jabber_proto.cpp index b97423b7dc..bd9ad50656 100755 --- a/protocols/JabberG/src/jabber_proto.cpp +++ b/protocols/JabberG/src/jabber_proto.cpp @@ -217,7 +217,7 @@ int CJabberProto::OnModulesLoadedEx(WPARAM, LPARAM) InitInfoFrame(); - GCREGISTER gcr = { sizeof(gcr) }; + GCREGISTER gcr = {}; gcr.dwFlags = GC_TYPNOTIF | GC_CHANMGR; gcr.nColors = 16; gcr.pColors = &crCols[0]; -- cgit v1.2.3