diff options
author | George Hazan <george.hazan@gmail.com> | 2016-09-19 11:25:57 +0000 |
---|---|---|
committer | George Hazan <george.hazan@gmail.com> | 2016-09-19 11:25:57 +0000 |
commit | 8fbb710f69be547c9a1fb45346bbd01db9d23bee (patch) | |
tree | b49bf9e58c0aa7fdfd49bce0170062454bee4d9e | |
parent | f76565d65450fe2f60913b93938c9a770e8caf4b (diff) |
Chat_AddGroup - even less structures
git-svn-id: http://svn.miranda-ng.org/main/trunk@17316 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
26 files changed, 78 insertions, 173 deletions
diff --git a/bin10/lib/mir_app.lib b/bin10/lib/mir_app.lib Binary files differindex 86cc9f3453..9ad4aba990 100644 --- a/bin10/lib/mir_app.lib +++ b/bin10/lib/mir_app.lib diff --git a/bin10/lib/mir_app64.lib b/bin10/lib/mir_app64.lib Binary files differindex f610c28d22..4730119b90 100644 --- a/bin10/lib/mir_app64.lib +++ b/bin10/lib/mir_app64.lib diff --git a/bin12/lib/mir_app.lib b/bin12/lib/mir_app.lib Binary files differindex 86cc9f3453..9ad4aba990 100644 --- a/bin12/lib/mir_app.lib +++ b/bin12/lib/mir_app.lib diff --git a/bin12/lib/mir_app64.lib b/bin12/lib/mir_app64.lib Binary files differindex f610c28d22..4730119b90 100644 --- a/bin12/lib/mir_app64.lib +++ b/bin12/lib/mir_app64.lib diff --git a/bin14/lib/mir_app.lib b/bin14/lib/mir_app.lib Binary files differindex 86cc9f3453..9ad4aba990 100644 --- a/bin14/lib/mir_app.lib +++ b/bin14/lib/mir_app.lib diff --git a/bin14/lib/mir_app64.lib b/bin14/lib/mir_app64.lib Binary files differindex f610c28d22..4730119b90 100644 --- a/bin14/lib/mir_app64.lib +++ b/bin14/lib/mir_app64.lib diff --git a/include/m_chat.h b/include/m_chat.h index 54fc11805c..d8236f3971 100644 --- a/include/m_chat.h +++ b/include/m_chat.h @@ -350,12 +350,6 @@ EXTERN_C MIR_APP_DLL(int) Chat_NewSession(const GCSESSION *); // registered with GC_EVENT_ADDGROUP. Ex "Voice" in IRC
#define GC_EVENT_REMOVESTATUS 0x0800
-// GC_EVENT_ADDGROUP - not shown in the log (Add a possible status mode to the nicklist, ex IRC uses "Op", "Voice", "Normal" etc )
-// NOTE. When adding several statuses, start with the highest status
-// pszStatus - The new group name
-// dwItemData - Optional HICON handle to a 10x10 icon. Set to NULL to use the built in icons.
-#define GC_EVENT_ADDGROUP 0x1002
-
// GC_EVENT_SETCONTACTSTATUS - sets status icon for contact
// pszUID - Unique identifier of the one who receives a new status
// dwItemData - (DWORD)ID_STATUS_* or zero to remove status icon
@@ -398,6 +392,7 @@ EXTERN_C MIR_APP_DLL(int) Chat_Event(GCEVENT*); EXTERN_C MIR_APP_DLL(void*) Chat_GetUserInfo(const char *szModule, const wchar_t *wszId);
EXTERN_C MIR_APP_DLL(int) Chat_SetUserInfo(const char *szModule, const wchar_t *wszId, void *pItemData);
+EXTERN_C MIR_APP_DLL(int) Chat_AddGroup(const char *szModule, const wchar_t *wszId, const wchar_t *wszText, HICON hIcon = NULL);
EXTERN_C MIR_APP_DLL(int) Chat_ChangeSessionName(const char *szModule, const wchar_t *wszId, const wchar_t *wszNewName);
EXTERN_C MIR_APP_DLL(int) Chat_ChangeUserId(const char *szModule, const wchar_t *wszId, const wchar_t *wszOldId, const wchar_t *wszNewId);
EXTERN_C MIR_APP_DLL(int) Chat_SendUserMessage(const char *szModule, const wchar_t *wszId, const wchar_t *wszText);
diff --git a/protocols/AimOscar/src/chat.cpp b/protocols/AimOscar/src/chat.cpp index c88354a8db..be48243644 100644 --- a/protocols/AimOscar/src/chat.cpp +++ b/protocols/AimOscar/src/chat.cpp @@ -45,14 +45,8 @@ void CAimProto::chat_start(const char *id, unsigned short exchange) gcw.ptszID = idt;
Chat_NewSession(&gcw);
- GCDEST gcd = { m_szModuleName, idt, GC_EVENT_ADDGROUP };
- GCEVENT gce = { &gcd };
- gce.ptszStatus = TranslateT("Me");
- Chat_Event(&gce);
-
- gcd.iType = GC_EVENT_ADDGROUP;
- gce.ptszStatus = TranslateT("Others");
- Chat_Event(&gce);
+ Chat_AddGroup(m_szModuleName, idt, TranslateT("Me"));
+ Chat_AddGroup(m_szModuleName, idt, TranslateT("Others"));
Chat_Control(m_szModuleName, idt, SESSION_INITDONE);
Chat_Control(m_szModuleName, idt, SESSION_ONLINE);
diff --git a/protocols/FacebookRM/src/chat.cpp b/protocols/FacebookRM/src/chat.cpp index ce9e7a4512..5f46bfd42a 100644 --- a/protocols/FacebookRM/src/chat.cpp +++ b/protocols/FacebookRM/src/chat.cpp @@ -253,18 +253,10 @@ void FacebookProto::AddChat(const char *id, const wchar_t *tname) Chat_NewSession(&gcw); // Send setting events - GCDEST gcd = { m_szModuleName, tid, GC_EVENT_ADDGROUP }; - GCEVENT gce = { &gcd }; - - // Create a user statuses - gce.ptszStatus = TranslateT("Myself"); - Chat_Event(&gce); - gce.ptszStatus = TranslateT("Friend"); - Chat_Event(&gce); - gce.ptszStatus = TranslateT("User"); - Chat_Event(&gce); - gce.ptszStatus = TranslateT("Former"); - Chat_Event(&gce); + Chat_AddGroup(m_szModuleName, tid, TranslateT("Myself")); + Chat_AddGroup(m_szModuleName, tid, TranslateT("Friend")); + Chat_AddGroup(m_szModuleName, tid, TranslateT("User")); + Chat_AddGroup(m_szModuleName, tid, TranslateT("Former")); // Finish initialization bool hideChats = getBool(FACEBOOK_KEY_HIDE_CHATS, DEFAULT_HIDE_CHATS); diff --git a/protocols/Gadu-Gadu/src/groupchat.cpp b/protocols/Gadu-Gadu/src/groupchat.cpp index b26c271602..8e36822a05 100644 --- a/protocols/Gadu-Gadu/src/groupchat.cpp +++ b/protocols/Gadu-Gadu/src/groupchat.cpp @@ -209,9 +209,6 @@ wchar_t* GGPROTO::gc_getchat(uin_t sender, uin_t *recipients, int recipients_cou GGGC *chat;
wchar_t id[32];
uin_t uin;
- DBVARIANT dbv;
- GCDEST gcd = { m_szModuleName, 0, GC_EVENT_ADDGROUP };
- GCEVENT gce = { &gcd };
debugLogA("gc_getchat(): Count %d.", recipients_count);
if (!recipients) return NULL;
@@ -333,30 +330,24 @@ wchar_t* GGPROTO::gc_getchat(uin_t sender, uin_t *recipients, int recipients_cou }
free(name);
- gcd.ptszID = chat->id;
+ // Add normal group
+ Chat_AddGroup(m_szModuleName, chat->id, TranslateT("Participants"));
+
+ GCDEST gcd = { m_szModuleName, chat->id, GC_EVENT_JOIN };
+ GCEVENT gce = { &gcd };
gce.ptszUID = id;
gce.dwFlags = GCEF_ADDTOLOG;
- gce.time = 0;
-
- // Add normal group
- gce.ptszStatus = TranslateT("Participants");
- Chat_Event(&gce);
- gcd.iType = GC_EVENT_JOIN;
// Add myself
if (uin = getDword(GG_KEY_UIN, 0))
{
UIN2IDT(uin, id);
- wchar_t* nickT;
- if (!getWString(GG_KEY_NICK, &dbv)) {
- nickT = mir_wstrdup(dbv.ptszVal);
- db_free(&dbv);
- } else {
+ ptrW nickT(getWStringA(GG_KEY_NICK));
+ if (nickT == NULL)
nickT = mir_wstrdup(TranslateT("Me"));
- }
- gce.ptszNick = nickT;
+ gce.ptszNick = nickT;
gce.bIsMe = 1;
Chat_Event(&gce);
mir_free(nickT);
diff --git a/protocols/IRCG/src/commandmonitor.cpp b/protocols/IRCG/src/commandmonitor.cpp index 9adb247adb..72788f322b 100644 --- a/protocols/IRCG/src/commandmonitor.cpp +++ b/protocols/IRCG/src/commandmonitor.cpp @@ -1277,20 +1277,12 @@ bool CIrcProto::OnIrc_ENDNAMES(const CIrcMessage* pmsg) PostIrcMessage(L"/MODE %s", sChanName);
// register the statuses
- GCDEST gcd = { m_szModuleName, sID, GC_EVENT_ADDGROUP };
- GCEVENT gce = { &gcd };
- gce.ptszStatus = L"Owner";
- Chat_Event(&gce);
- gce.ptszStatus = L"Admin";
- Chat_Event(&gce);
- gce.ptszStatus = L"Op";
- Chat_Event(&gce);
- gce.ptszStatus = L"Halfop";
- Chat_Event(&gce);
- gce.ptszStatus = L"Voice";
- Chat_Event(&gce);
- gce.ptszStatus = L"Normal";
- Chat_Event(&gce);
+ Chat_AddGroup(m_szModuleName, sID, L"Owner");
+ Chat_AddGroup(m_szModuleName, sID, L"Admin");
+ Chat_AddGroup(m_szModuleName, sID, L"Op");
+ Chat_AddGroup(m_szModuleName, sID, L"Halfop");
+ Chat_AddGroup(m_szModuleName, sID, L"Voice");
+ Chat_AddGroup(m_szModuleName, sID, L"Normal");
{
int k = 0;
CMStringW sTemp = GetWord(sNamesList, k);
@@ -1305,7 +1297,8 @@ bool CIrcProto::OnIrc_ENDNAMES(const CIrcMessage* pmsg) while (PrefixToStatus(sTemp[0]) != L"Normal")
sTemp.Delete(0, 1);
- gcd.iType = GC_EVENT_JOIN;
+ GCDEST gcd = { m_szModuleName, sID, GC_EVENT_JOIN };
+ GCEVENT gce = { &gcd };
gce.ptszUID = sTemp;
gce.ptszNick = sTemp;
gce.ptszStatus = sStat;
@@ -2336,8 +2329,7 @@ bool CIrcProto::DoOnConnect(const CIrcMessage*) }
}
- DoEvent(GC_EVENT_ADDGROUP, SERVERWINDOW, NULL, NULL, L"Normal", NULL, NULL, FALSE, TRUE);
-
+ Chat_AddGroup(m_szModuleName, SERVERWINDOW, L"Normal");
Chat_Control(m_szModuleName, SERVERWINDOW, SESSION_ONLINE);
CallFunctionAsync(sttMainThrdOnConnect, this);
diff --git a/protocols/JabberG/src/jabber_chat.cpp b/protocols/JabberG/src/jabber_chat.cpp index 61dff34c3d..0f405da76c 100644 --- a/protocols/JabberG/src/jabber_chat.cpp +++ b/protocols/JabberG/src/jabber_chat.cpp @@ -167,12 +167,8 @@ int CJabberProto::GcInit(JABBER_LIST_ITEM *item) item->bChatActive = true;
- GCDEST gcd = { m_szModuleName, item->jid, GC_EVENT_ADDGROUP };
- GCEVENT gce = { &gcd };
- for (int i = _countof(sttStatuses) - 1; i >= 0; i--) {
- gce.ptszStatus = TranslateW(sttStatuses[i]);
- Chat_Event(&gce);
- }
+ for (int i = _countof(sttStatuses) - 1; i >= 0; i--)
+ Chat_AddGroup(m_szModuleName, item->jid, TranslateW(sttStatuses[i]));
Chat_Control(m_szModuleName, item->jid, (item->bAutoJoin && m_options.AutoJoinHidden) ? WINDOW_HIDDEN : SESSION_INITDONE);
Chat_Control(m_szModuleName, item->jid, SESSION_ONLINE);
diff --git a/protocols/MRA/src/MraChat.cpp b/protocols/MRA/src/MraChat.cpp index e09a76c374..046093d84c 100644 --- a/protocols/MRA/src/MraChat.cpp +++ b/protocols/MRA/src/MraChat.cpp @@ -39,12 +39,8 @@ INT_PTR CMraProto::MraChatSessionNew(MCONTACT hContact) gcw.ptszStatusbarText = L"status bar";
gcw.pItemData = (void*)hContact;
if (!Chat_NewSession(&gcw)) {
- GCDEST gcd = { m_szModuleName, wszEMail.c_str(), GC_EVENT_ADDGROUP };
- GCEVENT gce = { &gcd };
- for (int i = 0; i < _countof(lpwszStatuses); i++) {
- gce.ptszStatus = TranslateW(lpwszStatuses[i]);
- Chat_Event(&gce);
- }
+ for (int i = 0; i < _countof(lpwszStatuses); i++)
+ Chat_AddGroup(m_szModuleName, wszEMail, TranslateW(lpwszStatuses[i]));
Chat_Control(m_szModuleName, wszEMail, SESSION_INITDONE);
Chat_Control(m_szModuleName, wszEMail, SESSION_ONLINE);
diff --git a/protocols/MSN/src/msn_chat.cpp b/protocols/MSN/src/msn_chat.cpp index 86a0967aaf..a2a62abeea 100644 --- a/protocols/MSN/src/msn_chat.cpp +++ b/protocols/MSN/src/msn_chat.cpp @@ -65,18 +65,12 @@ int CMsnProto::MSN_ChatInit(GCThreadData *info, const char *pszID, const char *p gcw.ptszID = info->mChatID;
Chat_NewSession(&gcw);
- GCDEST gcd = { m_szModuleName, info->mChatID, GC_EVENT_ADDGROUP };
- GCEVENT gce = { &gcd };
- for (int j = 0; j < _countof(m_ptszRoles); j++) {
- gce.ptszStatus = m_ptszRoles[j];
- Chat_Event(&gce);
- }
+ for (int j = 0; j < _countof(m_ptszRoles); j++)
+ Chat_AddGroup(m_szModuleName, info->mChatID, m_ptszRoles[j]);
Chat_Control(m_szModuleName, info->mChatID, SESSION_INITDONE);
Chat_Control(m_szModuleName, info->mChatID, SESSION_ONLINE);
Chat_Control(m_szModuleName, info->mChatID, WINDOW_VISIBLE);
-
- mir_free((wchar_t*)gce.ptszUID);
return 0;
}
diff --git a/protocols/MinecraftDynmap/src/chat.cpp b/protocols/MinecraftDynmap/src/chat.cpp index a2aa6f0e6b..2261c4e867 100644 --- a/protocols/MinecraftDynmap/src/chat.cpp +++ b/protocols/MinecraftDynmap/src/chat.cpp @@ -137,14 +137,8 @@ INT_PTR MinecraftDynmapProto::OnJoinChat(WPARAM,LPARAM suppress) return 0; // Create a group - GCDEST gcd = { m_szModuleName, m_tszUserName, GC_EVENT_ADDGROUP }; - GCEVENT gce = { &gcd }; - - gce.ptszStatus = L"Admin"; - Chat_Event(&gce); - - gce.ptszStatus = L"Normal"; - Chat_Event(&gce); + Chat_AddGroup(m_szModuleName, m_tszUserName, L"Admin"); + Chat_AddGroup(m_szModuleName, m_tszUserName, L"Normal"); // Note: Initialization will finish up in SetChatStatus, called separately if (!suppress) diff --git a/protocols/Omegle/src/chat.cpp b/protocols/Omegle/src/chat.cpp index fb6bed05a2..bab1fee7e9 100644 --- a/protocols/Omegle/src/chat.cpp +++ b/protocols/Omegle/src/chat.cpp @@ -278,14 +278,8 @@ INT_PTR OmegleProto::OnJoinChat(WPARAM, LPARAM suppress) return 0;
// Create a group
- GCDEST gcd = { m_szModuleName, m_tszUserName, GC_EVENT_ADDGROUP };
- GCEVENT gce = { &gcd };
-
- gce.ptszStatus = L"Admin";
- Chat_Event(&gce);
-
- gce.ptszStatus = L"Normal";
- Chat_Event(&gce);
+ Chat_AddGroup(m_szModuleName, m_tszUserName, L"Admin");
+ Chat_AddGroup(m_szModuleName, m_tszUserName, L"Normal");
SetTopic();
diff --git a/protocols/Sametime/src/conference.cpp b/protocols/Sametime/src/conference.cpp index 66444363b8..9c2fac9b59 100644 --- a/protocols/Sametime/src/conference.cpp +++ b/protocols/Sametime/src/conference.cpp @@ -109,47 +109,34 @@ void mwServiceConf_conf_opened(mwConference* conf, GList* members) proto->debugLogW(L"mwServiceConf_conf_opened() start");
ptrW tszConfId(mir_utf8decodeW(mwConference_getName(conf)));
+ ptrW tszConfTitle(mir_utf8decodeW(mwConference_getTitle(conf)));
// create new chat session
- {
- ptrW tszConfTitle(mir_utf8decodeW(mwConference_getTitle(conf)));
-
- GCSESSION gcs = {};
- gcs.iType = GCW_CHATROOM;
- gcs.pszModule = proto->m_szModuleName;
- gcs.ptszID = tszConfId;
- gcs.ptszName = tszConfTitle;
- Chat_NewSession(&gcs);
- }
-
- //add a group
- GCDEST gcd = { proto->m_szModuleName, 0 };
- gcd.iType = GC_EVENT_ADDGROUP;
- gcd.ptszID = tszConfId;
+ GCSESSION gcs = {};
+ gcs.iType = GCW_CHATROOM;
+ gcs.pszModule = proto->m_szModuleName;
+ gcs.ptszID = tszConfId;
+ gcs.ptszName = tszConfTitle;
+ Chat_NewSession(&gcs);
- GCEVENT gce = { &gcd };
- gce.dwFlags = GCEF_ADDTOLOG;
- gce.ptszStatus = TranslateT("Normal");
-
- Chat_Event(&gce);
+ // add a group
+ Chat_AddGroup(proto->m_szModuleName, tszConfId, TranslateT("Normal"));
// add users
- gcd.iType = GC_EVENT_JOIN;
+ GCDEST gcd = { proto->m_szModuleName, tszConfId, GC_EVENT_JOIN };
+ GCEVENT gce = { &gcd };
GList *user = members;
for (;user; user=user->next) {
proto->debugLogW(L"mwServiceConf_conf_opened() add user");
- wchar_t* tszUserName = mir_utf8decodeW(((mwLoginInfo*)user->data)->user_name);
- wchar_t* tszUserId = mir_utf8decodeW(((mwLoginInfo*)user->data)->login_id);
+ ptrW tszUserName(mir_utf8decodeW(((mwLoginInfo*)user->data)->user_name));
+ ptrW tszUserId(mir_utf8decodeW(((mwLoginInfo*)user->data)->login_id));
+ gce.dwFlags = GCEF_ADDTOLOG;
gce.ptszNick = tszUserName;
gce.ptszUID = tszUserId;
gce.bIsMe = (strcmp(((mwLoginInfo*)user->data)->login_id, proto->my_login_info->login_id) == 0);
-
Chat_Event( &gce);
-
- mir_free(tszUserName);
- mir_free(tszUserId);
}
// finalize setup (show window)
diff --git a/protocols/SkypeWeb/src/skype_chatrooms.cpp b/protocols/SkypeWeb/src/skype_chatrooms.cpp index 782b1501a3..bcdbdc1db1 100644 --- a/protocols/SkypeWeb/src/skype_chatrooms.cpp +++ b/protocols/SkypeWeb/src/skype_chatrooms.cpp @@ -66,20 +66,12 @@ void CSkypeProto::StartChatRoom(const wchar_t *tid, const wchar_t *tname) gcw.ptszName = tname;
Chat_NewSession(&gcw);
- // Send setting events
- GCDEST gcd = { m_szModuleName, tid, GC_EVENT_ADDGROUP };
- GCEVENT gce = { &gcd };
-
// Create a user statuses
- gce.ptszStatus = TranslateT("Admin");
- Chat_Event(&gce);
- gce.ptszStatus = TranslateT("User");
- Chat_Event(&gce);
+ Chat_AddGroup(m_szModuleName, tid, TranslateT("Admin"));
+ Chat_AddGroup(m_szModuleName, tid, TranslateT("User"));
// Finish initialization
- bool hideChats = getBool("HideChats", 1);
-
- Chat_Control(m_szModuleName, tid, (hideChats ? WINDOW_HIDDEN : SESSION_INITDONE));
+ Chat_Control(m_szModuleName, tid, (getBool("HideChats", 1) ? WINDOW_HIDDEN : SESSION_INITDONE));
Chat_Control(m_szModuleName, tid, SESSION_ONLINE);
}
diff --git a/protocols/Twitter/src/chat.cpp b/protocols/Twitter/src/chat.cpp index fc4274835a..59e41b9d0c 100644 --- a/protocols/Twitter/src/chat.cpp +++ b/protocols/Twitter/src/chat.cpp @@ -128,10 +128,7 @@ INT_PTR TwitterProto::OnJoinChat(WPARAM, LPARAM suppress) return 0;
// ***** Create a group
- GCDEST gcd = { m_szModuleName, m_tszUserName, GC_EVENT_ADDGROUP };
- GCEVENT gce = { &gcd };
- gce.ptszStatus = L"Normal";
- Chat_Event(&gce);
+ Chat_AddGroup(m_szModuleName, m_tszUserName, TranslateT("Normal"));
// ***** Hook events
HookProtoEvent(ME_GC_EVENT, &TwitterProto::OnChatOutgoing);
diff --git a/protocols/VKontakte/src/vk_chats.cpp b/protocols/VKontakte/src/vk_chats.cpp index f09904cba2..a8b95dbc1e 100644 --- a/protocols/VKontakte/src/vk_chats.cpp +++ b/protocols/VKontakte/src/vk_chats.cpp @@ -77,12 +77,8 @@ CVkChatInfo* CVkProto::AppendChat(int id, const JSONNode &jnDlg) setWString(gci.hContact, "Nick", wszTitle);
m_chats.insert(c);
- GCDEST gcd = { m_szModuleName, sid, GC_EVENT_ADDGROUP };
- GCEVENT gce = { &gcd };
- for (int i = _countof(sttStatuses)-1; i >= 0; i--) {
- gce.ptszStatus = TranslateW(sttStatuses[i]);
- Chat_Event(&gce);
- }
+ for (int i = _countof(sttStatuses)-1; i >= 0; i--)
+ Chat_AddGroup(m_szModuleName, sid, TranslateW(sttStatuses[i]));
setDword(gci.hContact, "vk_chat_id", id);
@@ -97,7 +93,6 @@ CVkChatInfo* CVkProto::AppendChat(int id, const JSONNode &jnDlg) return NULL;
}
- gce.ptszStatus = 0;
Chat_Control(m_szModuleName, sid, (m_vkOptions.bHideChats) ? WINDOW_HIDDEN : SESSION_INITDONE);
Chat_Control(m_szModuleName, sid, SESSION_ONLINE);
diff --git a/protocols/WhatsApp/src/chat.cpp b/protocols/WhatsApp/src/chat.cpp index 0987c6ea52..07de0eca79 100644 --- a/protocols/WhatsApp/src/chat.cpp +++ b/protocols/WhatsApp/src/chat.cpp @@ -311,12 +311,8 @@ WAChatInfo* WhatsAppProto::InitChat(const std::string &jid, const std::string &n pInfo->hContact = (hOldContact != NULL) ? hOldContact : ContactIDToHContact(jid);
- GCDEST gcd = { m_szModuleName, ptszJid, GC_EVENT_ADDGROUP };
- GCEVENT gce = { &gcd };
- for (int i = _countof(sttStatuses) - 1; i >= 0; i--) {
- gce.ptszStatus = TranslateW(sttStatuses[i]);
- Chat_Event(&gce);
- }
+ for (int i = _countof(sttStatuses) - 1; i >= 0; i--)
+ Chat_AddGroup(m_szModuleName, ptszJid, TranslateW(sttStatuses[i]));
Chat_Control(m_szModuleName, ptszJid, getBool(WHATSAPP_KEY_AUTORUNCHATS, true) ? SESSION_INITDONE : WINDOW_HIDDEN);
Chat_Control(m_szModuleName, ptszJid, SESSION_ONLINE);
diff --git a/protocols/Yahoo/src/chat.cpp b/protocols/Yahoo/src/chat.cpp index 07955a94ee..b11bcaba0c 100644 --- a/protocols/Yahoo/src/chat.cpp +++ b/protocols/Yahoo/src/chat.cpp @@ -159,14 +159,8 @@ void CYahooProto::ChatStart(const char* room) gcw.ptszID = idt;
Chat_NewSession(&gcw);
- GCDEST gcd = { m_szModuleName, idt, GC_EVENT_ADDGROUP };
- GCEVENT gce = { &gcd };
- gce.ptszStatus = TranslateT("Me");
- Chat_Event(&gce);
-
- gcd.iType = GC_EVENT_ADDGROUP;
- gce.ptszStatus = TranslateT("Others");
- Chat_Event(&gce);
+ Chat_AddGroup(m_szModuleName, idt, TranslateT("Me"));
+ Chat_AddGroup(m_szModuleName, idt, TranslateT("Others"));
Chat_Control(m_szModuleName, idt, SESSION_INITDONE);
Chat_Control(m_szModuleName, idt, SESSION_ONLINE);
diff --git a/src/mir_app/src/chat_svc.cpp b/src/mir_app/src/chat_svc.cpp index a5850be128..2e675131e8 100644 --- a/src/mir_app/src/chat_svc.cpp +++ b/src/mir_app/src/chat_svc.cpp @@ -192,17 +192,17 @@ EXTERN_C MIR_APP_DLL(int) Chat_NewSession(const GCSESSION *gcw) if (gcw == NULL)
return GC_NEWSESSION_ERROR;
- mir_cslock lck(csChat);
+ mir_cslockfull lck(csChat);
MODULEINFO *mi = chatApi.MM_FindModule(gcw->pszModule);
if (mi == NULL)
return GC_NEWSESSION_ERROR;
-
// try to restart a session first
SESSION_INFO *si = chatApi.SM_FindSession(gcw->ptszID, gcw->pszModule);
if (si != NULL) {
chatApi.UM_RemoveAll(&si->pUsers);
chatApi.TM_RemoveAll(&si->pStatuses);
+ lck.unlock();
si->iStatusCount = 0;
si->nUsersInNicklist = 0;
@@ -217,6 +217,7 @@ EXTERN_C MIR_APP_DLL(int) Chat_NewSession(const GCSESSION *gcw) if ((si = chatApi.SM_AddSession(gcw->ptszID, gcw->pszModule)) == NULL)
return GC_NEWSESSION_ERROR;
+ lck.unlock();
si->pItemData = gcw->pItemData;
if (gcw->iType != GCW_SERVER)
si->wStatus = ID_STATUS_ONLINE;
@@ -410,9 +411,6 @@ static BOOL AddEventToAllMatchingUID(GCEVENT *gce) EXTERN_C MIR_APP_DLL(int) Chat_Event(GCEVENT *gce)
{
- BOOL bIsHighlighted = FALSE;
- BOOL bRemoveFlag = FALSE;
-
if (gce == NULL)
return GC_EVENT_ERROR;
@@ -426,16 +424,11 @@ EXTERN_C MIR_APP_DLL(int) Chat_Event(GCEVENT *gce) if (NotifyEventHooks(hHookEvent, 0, LPARAM(gce)))
return 1;
+ BOOL bIsHighlighted = FALSE;
+ BOOL bRemoveFlag = FALSE;
+
// Do different things according to type of event
switch (gcd->iType) {
- case GC_EVENT_ADDGROUP:
- {
- STATUSINFO *si = chatApi.SM_AddStatus(gcd->ptszID, gcd->pszModule, gce->ptszStatus);
- if (si && gce->dwItemData)
- si->hIcon = CopyIcon((HICON)gce->dwItemData);
- }
- return 0;
-
case GC_EVENT_SETCONTACTSTATUS:
return chatApi.SM_SetContactStatus(gcd->ptszID, gcd->pszModule, gce->ptszUID, (WORD)gce->dwItemData);
@@ -546,6 +539,18 @@ EXTERN_C MIR_APP_DLL(int) Chat_Event(GCEVENT *gce) /////////////////////////////////////////////////////////////////////////////////////////
// chat control functions
+MIR_APP_DLL(int) Chat_AddGroup(const char *szModule, const wchar_t *wszId, const wchar_t *wszText, HICON hIcon)
+{
+ if (wszText == NULL)
+ return GC_EVENT_ERROR;
+
+ mir_cslock lck(csChat);
+ STATUSINFO *si = chatApi.SM_AddStatus(wszId, szModule, wszText);
+ if (si && hIcon)
+ si->hIcon = CopyIcon(hIcon);
+ return 0;
+}
+
MIR_APP_DLL(int) Chat_ChangeSessionName(const char *szModule, const wchar_t *wszId, const wchar_t *wszNewName)
{
if (wszNewName == NULL)
diff --git a/src/mir_app/src/chat_tools.cpp b/src/mir_app/src/chat_tools.cpp index eb262e1eed..ec3ab03934 100644 --- a/src/mir_app/src/chat_tools.cpp +++ b/src/mir_app/src/chat_tools.cpp @@ -658,7 +658,6 @@ BOOL IsEventSupported(int eventType) case GC_EVENT_ACTION:
case GC_EVENT_ADDSTATUS:
case GC_EVENT_REMOVESTATUS:
- case GC_EVENT_ADDGROUP:
case GC_EVENT_SETCONTACTSTATUS:
return TRUE;
}
diff --git a/src/mir_app/src/mir_app.def b/src/mir_app/src/mir_app.def index a72414500f..ae46f64976 100644 --- a/src/mir_app/src/mir_app.def +++ b/src/mir_app/src/mir_app.def @@ -308,3 +308,4 @@ Chat_SetStatusbarText @308 Chat_SendUserMessage @309
Chat_SetStatusEx @310
Chat_Terminate @311
+Chat_AddGroup @312
diff --git a/src/mir_app/src/mir_app64.def b/src/mir_app/src/mir_app64.def index e3d58e4aa3..6914577fc2 100644 --- a/src/mir_app/src/mir_app64.def +++ b/src/mir_app/src/mir_app64.def @@ -308,3 +308,4 @@ Chat_SetStatusbarText @308 Chat_SendUserMessage @309
Chat_SetStatusEx @310
Chat_Terminate @311
+Chat_AddGroup @312
|