diff options
26 files changed, 75 insertions, 208 deletions
diff --git a/bin10/lib/mir_app.lib b/bin10/lib/mir_app.lib Binary files differindex 9ad4aba990..c17035ca39 100644 --- a/bin10/lib/mir_app.lib +++ b/bin10/lib/mir_app.lib diff --git a/bin12/lib/mir_app.lib b/bin12/lib/mir_app.lib Binary files differindex 9ad4aba990..c17035ca39 100644 --- a/bin12/lib/mir_app.lib +++ b/bin12/lib/mir_app.lib diff --git a/bin14/lib/mir_app.lib b/bin14/lib/mir_app.lib Binary files differindex 9ad4aba990..c17035ca39 100644 --- a/bin14/lib/mir_app.lib +++ b/bin14/lib/mir_app.lib diff --git a/include/m_chat.h b/include/m_chat.h index c94b2fa26d..479b44ceee 100644 --- a/include/m_chat.h +++ b/include/m_chat.h @@ -137,9 +137,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #define GC_FONTSIZE 0x0200 // enable font size selection
// Error messages
-#define GC_REGISTER_ERROR 2 // An internal error occurred. Registration failed.
-#define GC_REGISTER_NOUNICODE 3 // MS_GC_REGISTER returns this error if the Unicode version of chat
- // is not installed and GC_UNICODE is set. Registration failed
+#define GC_ERROR 1 // An internal error occurred.
// GCREGISTER struct
struct GCREGISTER
@@ -175,22 +173,13 @@ EXTERN_C MIR_APP_DLL(int) Chat_Register(const GCREGISTER*); #define GCW_PRIVMESS 3 // NOT SUPPORTED YET! the session is a 1 to 1 session, but with additional
// support for adding more users etc. ex "MSN session".
-// Error messages
-#define GC_NEWSESSION_ERROR 2 // An internal error occurred.
-
-// GCSESSION structure
-struct GCSESSION
-{
- const char *pszModule; // The name of the protocol owning the session (the same as pszModule when you register)
- const wchar_t *ptszName; // The name of the session as it will be displayed to the user
- const wchar_t *ptszID; // The unique identifier for the session.
- const wchar_t *ptszStatusbarText; // Optional text to set in the statusbar of the chat room window, or NULL.
- int iType; // Use one of the GCW_* flags above to set the type of session
- DWORD dwFlags;
- void *pItemData; // Set user defined data for this session. Retrieve it by using the Chat_GetUserInfo() call
-};
-
-EXTERN_C MIR_APP_DLL(int) Chat_NewSession(const GCSESSION *);
+EXTERN_C MIR_APP_DLL(int) Chat_NewSession(
+ int iType, // Use one of the GCW_* flags above to set the type of session
+ const char *pszModule, // The name of the protocol owning the session (the same as pszModule when you register)
+ const wchar_t *ptszID, // The unique identifier for the session.
+ const wchar_t *ptszName, // The name of the session as it will be displayed to the user
+ void *pItemData = NULL // Set user defined data for this session. Retrieve it by using the Chat_GetUserInfo() call
+);
/*
Step 3 -- SEND an EVENT --
diff --git a/include/m_chat_int.h b/include/m_chat_int.h index 6aa36ebfd4..eccd2318b8 100644 --- a/include/m_chat_int.h +++ b/include/m_chat_int.h @@ -209,7 +209,6 @@ struct GCSessionInfoBase WORD wState;
WORD wCommandsNum;
void *pItemData;
- DWORD dwFlags;
MCONTACT hContact;
HWND hwndStatus;
time_t LastTime;
@@ -347,7 +346,6 @@ struct CHAT_MANAGER BOOL (*LM_TrimLog)(LOGINFO **ppLogListStart, LOGINFO **ppLogListEnd, int iCount);
BOOL (*LM_RemoveAll)(LOGINFO **ppLogListStart, LOGINFO **ppLogListEnd);
- MCONTACT (*AddRoom)(const char *pszModule, const wchar_t *pszRoom, const wchar_t *pszDisplayName, int iType);
BOOL (*SetOffline)(MCONTACT hContact, BOOL bHide);
BOOL (*SetAllOffline)(BOOL bHide, const char *pszModule);
BOOL (*AddEvent)(MCONTACT hContact, HICON hIcon, MEVENT hEvent, int type, wchar_t* fmt, ...);
diff --git a/protocols/AimOscar/src/chat.cpp b/protocols/AimOscar/src/chat.cpp index be48243644..bd7a371619 100644 --- a/protocols/AimOscar/src/chat.cpp +++ b/protocols/AimOscar/src/chat.cpp @@ -37,13 +37,7 @@ void CAimProto::chat_register(void) void CAimProto::chat_start(const char *id, unsigned short exchange)
{
wchar_t *idt = mir_a2u(id);
-
- GCSESSION gcw = {};
- gcw.iType = GCW_CHATROOM;
- gcw.pszModule = m_szModuleName;
- gcw.ptszName = idt;
- gcw.ptszID = idt;
- Chat_NewSession(&gcw);
+ Chat_NewSession(GCW_CHATROOM, m_szModuleName, idt, idt);
Chat_AddGroup(m_szModuleName, idt, TranslateT("Me"));
Chat_AddGroup(m_szModuleName, idt, TranslateT("Others"));
diff --git a/protocols/FacebookRM/src/chat.cpp b/protocols/FacebookRM/src/chat.cpp index 5f46bfd42a..2d288ac103 100644 --- a/protocols/FacebookRM/src/chat.cpp +++ b/protocols/FacebookRM/src/chat.cpp @@ -245,12 +245,7 @@ void FacebookProto::AddChat(const char *id, const wchar_t *tname) ptrW tid(mir_a2u(id)); // Create the group chat session - GCSESSION gcw = {}; - gcw.iType = GCW_PRIVMESS; - gcw.ptszID = tid; - gcw.pszModule = m_szModuleName; - gcw.ptszName = tname; - Chat_NewSession(&gcw); + Chat_NewSession(GCW_PRIVMESS, m_szModuleName, tid, tname); // Send setting events Chat_AddGroup(m_szModuleName, tid, TranslateT("Myself")); @@ -411,16 +406,11 @@ void FacebookProto::PrepareNotificationsChatRoom() { mir_snwprintf(nameT, L"%s: %s", m_tszUserName, TranslateT("Notifications")); // Create the group chat session - GCSESSION gcw = {}; - gcw.iType = GCW_PRIVMESS; - gcw.ptszID = _A2W(FACEBOOK_NOTIFICATIONS_CHATROOM); - gcw.pszModule = m_szModuleName; - gcw.ptszName = nameT; - Chat_NewSession(&gcw); + Chat_NewSession(GCW_PRIVMESS, m_szModuleName, _A2W(FACEBOOK_NOTIFICATIONS_CHATROOM), nameT); // Send setting events - Chat_Control(m_szModuleName, gcw.ptszID, WINDOW_HIDDEN); - Chat_Control(m_szModuleName, gcw.ptszID, SESSION_ONLINE); + Chat_Control(m_szModuleName, _A2W(FACEBOOK_NOTIFICATIONS_CHATROOM), WINDOW_HIDDEN); + Chat_Control(m_szModuleName, _A2W(FACEBOOK_NOTIFICATIONS_CHATROOM), SESSION_ONLINE); } } diff --git a/protocols/Gadu-Gadu/src/groupchat.cpp b/protocols/Gadu-Gadu/src/groupchat.cpp index 8e36822a05..7137639aed 100644 --- a/protocols/Gadu-Gadu/src/groupchat.cpp +++ b/protocols/Gadu-Gadu/src/groupchat.cpp @@ -308,27 +308,10 @@ wchar_t* GGPROTO::gc_getchat(uin_t sender, uin_t *recipients, int recipients_cou mir_snwprintf(status, TranslateT("This is my own conference."));
}
- GCSESSION gcwindow = {};
- gcwindow.iType = GCW_CHATROOM;
- gcwindow.pszModule = m_szModuleName;
- gcwindow.ptszName = sender ? senderName : TranslateT("Conference");
- gcwindow.ptszID = chat->id;
- gcwindow.pItemData = chat;
- gcwindow.ptszStatusbarText = status;
-
- // Here we put nice new hash sign
- wchar_t *name = (wchar_t*)calloc(mir_wstrlen(gcwindow.ptszName) + 2, sizeof(wchar_t));
- *name = '#'; mir_wstrcpy(name + 1, gcwindow.ptszName);
- gcwindow.ptszName = name;
-
// Create new room
- if (Chat_NewSession( &gcwindow)) {
- debugLogW(L"gc_getchat(): Cannot create new chat window %s.", chat->id);
- free(name);
- free(chat);
- return NULL;
- }
- free(name);
+ CMStringW wszTitle(L"#"); wszTitle.Append(sender ? senderName : TranslateT("Conference"));
+ Chat_NewSession(GCW_CHATROOM, m_szModuleName, chat->id, wszTitle, chat);
+ Chat_SetStatusbarText(m_szModuleName, chat->id, status);
// Add normal group
Chat_AddGroup(m_szModuleName, chat->id, TranslateT("Participants"));
@@ -367,8 +350,8 @@ wchar_t* GGPROTO::gc_getchat(uin_t sender, uin_t *recipients, int recipients_cou for(i = 0; i < chat->recipients_count; i++) {
MCONTACT hContact = getcontact(chat->recipients[i], 1, 0, NULL);
UIN2IDT(chat->recipients[i], id);
- if (hContact && (name = pcli->pfnGetContactDisplayName(hContact, 0)) != NULL)
- gce.ptszNick = name;
+ if (hContact)
+ gce.ptszNick = pcli->pfnGetContactDisplayName(hContact, 0);
else
gce.ptszNick = TranslateT("'Unknown'");
gce.bIsMe = 0;
diff --git a/protocols/IRCG/src/commandmonitor.cpp b/protocols/IRCG/src/commandmonitor.cpp index 72788f322b..f47067ee3d 100644 --- a/protocols/IRCG/src/commandmonitor.cpp +++ b/protocols/IRCG/src/commandmonitor.cpp @@ -1266,14 +1266,7 @@ bool CIrcProto::OnIrc_ENDNAMES(const CIrcMessage* pmsg) CMStringW sID = MakeWndID(sChanName);
BYTE btOwnMode = 0;
- GCSESSION gcw = {};
- gcw.iType = GCW_CHATROOM;
- gcw.ptszID = sID;
- gcw.pszModule = m_szModuleName;
- gcw.ptszName = sChanName;
- if (!Chat_NewSession(&gcw)) {
- DBVARIANT dbv;
-
+ if (!Chat_NewSession(GCW_CHATROOM, m_szModuleName, sID, sChanName)) {
PostIrcMessage(L"/MODE %s", sChanName);
// register the statuses
@@ -1359,6 +1352,7 @@ bool CIrcProto::OnIrc_ENDNAMES(const CIrcMessage* pmsg) }
}
+ DBVARIANT dbv;
if (!getWString("JTemp", &dbv)) {
CMStringW command = L"a";
CMStringW save = L"";
diff --git a/protocols/IRCG/src/ircproto.cpp b/protocols/IRCG/src/ircproto.cpp index f80950ae5f..b0faf81af6 100644 --- a/protocols/IRCG/src/ircproto.cpp +++ b/protocols/IRCG/src/ircproto.cpp @@ -204,12 +204,7 @@ int CIrcProto::OnModulesLoaded(WPARAM, LPARAM) HookProtoEvent(ME_GC_EVENT, &CIrcProto::GCEventHook);
HookProtoEvent(ME_GC_BUILDMENU, &CIrcProto::GCMenuHook);
- GCSESSION gcw = {};
- gcw.iType = GCW_SERVER;
- gcw.ptszID = SERVERWINDOW;
- gcw.pszModule = m_szModuleName;
- gcw.ptszName = NEWWSTR_ALLOCA((wchar_t*)_A2T(m_network));
- Chat_NewSession(&gcw);
+ Chat_NewSession(GCW_SERVER, m_szModuleName, SERVERWINDOW, _A2T(m_network));
if (m_useServer && !m_hideServerWindow)
Chat_Control(m_szModuleName, SERVERWINDOW, WINDOW_VISIBLE);
diff --git a/protocols/JabberG/src/jabber_chat.cpp b/protocols/JabberG/src/jabber_chat.cpp index 0f405da76c..5838b6e2e1 100644 --- a/protocols/JabberG/src/jabber_chat.cpp +++ b/protocols/JabberG/src/jabber_chat.cpp @@ -127,13 +127,7 @@ int CJabberProto::GcInit(JABBER_LIST_ITEM *item) sttRoleItems[i].translate();
ptrW szNick(JabberNickFromJID(item->jid));
-
- GCSESSION gcw = {};
- gcw.iType = GCW_CHATROOM;
- gcw.pszModule = m_szModuleName;
- gcw.ptszName = szNick;
- gcw.ptszID = item->jid;
- Chat_NewSession(&gcw);
+ Chat_NewSession(GCW_CHATROOM, m_szModuleName, item->jid, szNick);
GCSessionInfoBase *si = pci->SM_FindSession(item->jid, m_szModuleName);
if (si != NULL) {
diff --git a/protocols/JabberG/src/jabber_iqid.cpp b/protocols/JabberG/src/jabber_iqid.cpp index bbf2407010..b0be15fb1d 100644 --- a/protocols/JabberG/src/jabber_iqid.cpp +++ b/protocols/JabberG/src/jabber_iqid.cpp @@ -440,17 +440,9 @@ void CJabberProto::OnIqResultGetRoster(HXML iqNode, CJabberIqInfo *pInfo) else db_unset(hContact, "CList", "MyHandle");
if (isChatRoom(hContact)) {
- GCSESSION gcw = {};
- gcw.iType = GCW_CHATROOM;
- gcw.pszModule = m_szModuleName;
- gcw.ptszID = jid;
- gcw.ptszName = NEWWSTR_ALLOCA(jid);
-
- wchar_t *p = (wchar_t*)wcschr(gcw.ptszName, '@');
- if (p)
- *p = 0;
-
- Chat_NewSession(&gcw);
+ wchar_t *wszTitle = NEWWSTR_ALLOCA(jid);
+ if (wchar_t *p = wcschr(wszTitle, '@')) *p = 0;
+ Chat_NewSession(GCW_CHATROOM, m_szModuleName, jid, wszTitle);
db_unset(hContact, "CList", "Hidden");
chatRooms.insert((HANDLE)hContact);
diff --git a/protocols/MRA/src/MraChat.cpp b/protocols/MRA/src/MraChat.cpp index 046093d84c..454d44a2e9 100644 --- a/protocols/MRA/src/MraChat.cpp +++ b/protocols/MRA/src/MraChat.cpp @@ -27,32 +27,26 @@ bool CMraProto::MraChatRegister() INT_PTR CMraProto::MraChatSessionNew(MCONTACT hContact)
{
if (bChatExists)
- if (hContact) {
- CMStringW wszEMail;
- mraGetStringW(hContact, "e-mail", wszEMail);
-
- GCSESSION gcw = {};
- gcw.iType = GCW_CHATROOM;
- gcw.pszModule = m_szModuleName;
- gcw.ptszName = pcli->pfnGetContactDisplayName(hContact, 0);
- gcw.ptszID = wszEMail;
- gcw.ptszStatusbarText = L"status bar";
- gcw.pItemData = (void*)hContact;
- if (!Chat_NewSession(&gcw)) {
- 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);
-
- DWORD opcode = MULTICHAT_GET_MEMBERS;
- CMStringA szEmail;
- if (mraGetStringA(hContact, "e-mail", szEmail))
- MraMessage(FALSE, NULL, 0, MESSAGE_FLAG_MULTICHAT, szEmail, L"", (LPBYTE)&opcode, sizeof(opcode));
- return 0;
- }
- }
- return 1;
+ if (!hContact)
+ return 1;
+
+ CMStringW wszEMail;
+ mraGetStringW(hContact, "e-mail", wszEMail);
+
+ if (Chat_NewSession(GCW_CHATROOM, m_szModuleName, wszEMail, pcli->pfnGetContactDisplayName(hContact, 0), (void*)hContact))
+ return 1;
+
+ 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);
+
+ DWORD opcode = MULTICHAT_GET_MEMBERS;
+ CMStringA szEmail;
+ if (mraGetStringA(hContact, "e-mail", szEmail))
+ MraMessage(FALSE, NULL, 0, MESSAGE_FLAG_MULTICHAT, szEmail, L"", (LPBYTE)&opcode, sizeof(opcode));
+ return 0;
}
void CMraProto::MraChatSessionDestroy(MCONTACT hContact)
diff --git a/protocols/MRA/src/Mra_functions.cpp b/protocols/MRA/src/Mra_functions.cpp index 34c002235d..844d654245 100644 --- a/protocols/MRA/src/Mra_functions.cpp +++ b/protocols/MRA/src/Mra_functions.cpp @@ -525,14 +525,7 @@ MCONTACT CMraProto::MraHContactFromEmail(const CMStringA &szEmail, BOOL bAddIfNe //not already there: add
if (IsEMailChatAgent(szEmail)) {
CMStringW wszEMail = szEmail;
-
- GCSESSION gcw = {};
- gcw.iType = GCW_CHATROOM;
- gcw.pszModule = m_szModuleName;
- gcw.ptszName = wszEMail;
- gcw.ptszID = (LPWSTR)wszEMail.c_str();
-
- if (Chat_NewSession(&gcw) == 0) {
+ if (Chat_NewSession(GCW_CHATROOM, m_szModuleName, wszEMail, wszEMail) == 0) {
BOOL bChatAdded = FALSE;
for (hContact = db_find_first(m_szModuleName); hContact; hContact = db_find_next(hContact, m_szModuleName)) {
if (mraGetStringA(hContact, "ChatRoomID", szEMailLocal)) {
diff --git a/protocols/MSN/src/msn_chat.cpp b/protocols/MSN/src/msn_chat.cpp index a2a62abeea..6c1a63978f 100644 --- a/protocols/MSN/src/msn_chat.cpp +++ b/protocols/MSN/src/msn_chat.cpp @@ -54,16 +54,11 @@ int CMsnProto::MSN_ChatInit(GCThreadData *info, const char *pszID, const char *p wchar_t szName[512];
InterlockedIncrement(&m_chatID);
- if (*pszTopic) wcsncpy(szName, _A2T(pszTopic), _countof(szName));
+ if (*pszTopic)
+ wcsncpy(szName, _A2T(pszTopic), _countof(szName));
else mir_snwprintf(szName, L"%s %s%d",
m_tszUserName, TranslateT("Chat #"), m_chatID);
-
- GCSESSION gcw = {};
- gcw.iType = GCW_CHATROOM;
- gcw.pszModule = m_szModuleName;
- gcw.ptszName = szName;
- gcw.ptszID = info->mChatID;
- Chat_NewSession(&gcw);
+ Chat_NewSession(GCW_CHATROOM, m_szModuleName, info->mChatID, szName);
for (int j = 0; j < _countof(m_ptszRoles); j++)
Chat_AddGroup(m_szModuleName, info->mChatID, m_ptszRoles[j]);
diff --git a/protocols/MinecraftDynmap/src/chat.cpp b/protocols/MinecraftDynmap/src/chat.cpp index 2261c4e867..2990d65933 100644 --- a/protocols/MinecraftDynmap/src/chat.cpp +++ b/protocols/MinecraftDynmap/src/chat.cpp @@ -126,12 +126,7 @@ INT_PTR MinecraftDynmapProto::OnJoinChat(WPARAM,LPARAM suppress) ptrW tszTitle(mir_a2u_cp(m_title.c_str(), CP_UTF8)); // Create the group chat session - GCSESSION gcw = {}; - gcw.iType = GCW_PRIVMESS; - gcw.ptszID = m_tszUserName; - gcw.ptszName = tszTitle; - gcw.pszModule = m_szModuleName; - Chat_NewSession(&gcw); + Chat_NewSession(GCW_PRIVMESS, m_szModuleName, m_tszUserName, tszTitle); if (m_iStatus == ID_STATUS_OFFLINE) return 0; diff --git a/protocols/Omegle/src/chat.cpp b/protocols/Omegle/src/chat.cpp index bab1fee7e9..bbfce622b8 100644 --- a/protocols/Omegle/src/chat.cpp +++ b/protocols/Omegle/src/chat.cpp @@ -267,12 +267,7 @@ void OmegleProto::DeleteChatContact(const wchar_t *name) INT_PTR OmegleProto::OnJoinChat(WPARAM, LPARAM suppress)
{
// Create the group chat session
- GCSESSION gcw = {};
- gcw.iType = GCW_PRIVMESS;
- gcw.ptszID = m_tszUserName;
- gcw.ptszName = m_tszUserName;
- gcw.pszModule = m_szModuleName;
- Chat_NewSession(&gcw);
+ Chat_NewSession(GCW_PRIVMESS, m_szModuleName, m_tszUserName, m_tszUserName);
if (m_iStatus == ID_STATUS_OFFLINE)
return 0;
diff --git a/protocols/Sametime/src/conference.cpp b/protocols/Sametime/src/conference.cpp index 9c2fac9b59..04af2e7372 100644 --- a/protocols/Sametime/src/conference.cpp +++ b/protocols/Sametime/src/conference.cpp @@ -112,12 +112,7 @@ void mwServiceConf_conf_opened(mwConference* conf, GList* members) ptrW tszConfTitle(mir_utf8decodeW(mwConference_getTitle(conf)));
// create new chat session
- GCSESSION gcs = {};
- gcs.iType = GCW_CHATROOM;
- gcs.pszModule = proto->m_szModuleName;
- gcs.ptszID = tszConfId;
- gcs.ptszName = tszConfTitle;
- Chat_NewSession(&gcs);
+ Chat_NewSession(GCW_CHATROOM, proto->m_szModuleName, tszConfId, tszConfTitle);
// add a group
Chat_AddGroup(proto->m_szModuleName, tszConfId, TranslateT("Normal"));
diff --git a/protocols/SkypeWeb/src/skype_chatrooms.cpp b/protocols/SkypeWeb/src/skype_chatrooms.cpp index bcdbdc1db1..d86c029374 100644 --- a/protocols/SkypeWeb/src/skype_chatrooms.cpp +++ b/protocols/SkypeWeb/src/skype_chatrooms.cpp @@ -59,12 +59,7 @@ MCONTACT CSkypeProto::FindChatRoom(const char *chatname) void CSkypeProto::StartChatRoom(const wchar_t *tid, const wchar_t *tname)
{
// Create the group chat session
- GCSESSION gcw = {};
- gcw.iType = GCW_CHATROOM;
- gcw.ptszID = tid;
- gcw.pszModule = m_szModuleName;
- gcw.ptszName = tname;
- Chat_NewSession(&gcw);
+ Chat_NewSession(GCW_CHATROOM, m_szModuleName, tid, tname);
// Create a user statuses
Chat_AddGroup(m_szModuleName, tid, TranslateT("Admin"));
diff --git a/protocols/Twitter/src/chat.cpp b/protocols/Twitter/src/chat.cpp index 59e41b9d0c..ed7c69e3c3 100644 --- a/protocols/Twitter/src/chat.cpp +++ b/protocols/Twitter/src/chat.cpp @@ -117,12 +117,7 @@ void TwitterProto::DeleteChatContact(const char *name) INT_PTR TwitterProto::OnJoinChat(WPARAM, LPARAM suppress)
{
// ***** Create the group chat session
- GCSESSION gcw = {};
- gcw.iType = GCW_CHATROOM;
- gcw.pszModule = m_szModuleName;
- gcw.ptszName = m_tszUserName;
- gcw.ptszID = m_tszUserName;
- Chat_NewSession(&gcw);
+ Chat_NewSession(GCW_CHATROOM, m_szModuleName, m_tszUserName, m_tszUserName);
if (m_iStatus != ID_STATUS_ONLINE)
return 0;
diff --git a/protocols/VKontakte/src/vk_chats.cpp b/protocols/VKontakte/src/vk_chats.cpp index a8b95dbc1e..2d3fdeb13c 100644 --- a/protocols/VKontakte/src/vk_chats.cpp +++ b/protocols/VKontakte/src/vk_chats.cpp @@ -59,13 +59,7 @@ CVkChatInfo* CVkProto::AppendChat(int id, const JSONNode &jnDlg) CMStringW sid;
sid.Format(L"%S_%d", m_szModuleName, id);
c->m_wszId = mir_wstrdup(sid);
-
- GCSESSION gcw = {};
- gcw.iType = GCW_CHATROOM;
- gcw.pszModule = m_szModuleName;
- gcw.ptszName = wszTitle;
- gcw.ptszID = sid;
- Chat_NewSession(&gcw);
+ Chat_NewSession(GCW_CHATROOM, m_szModuleName, sid, wszTitle);
GC_INFO gci = {};
gci.pszModule = m_szModuleName;
diff --git a/protocols/WhatsApp/src/chat.cpp b/protocols/WhatsApp/src/chat.cpp index 07de0eca79..a87be6a24f 100644 --- a/protocols/WhatsApp/src/chat.cpp +++ b/protocols/WhatsApp/src/chat.cpp @@ -302,12 +302,7 @@ WAChatInfo* WhatsAppProto::InitChat(const std::string &jid, const std::string &n setString(hOldContact, "ChatRoomID", jid.c_str());
}
- GCSESSION gcw = {};
- gcw.iType = GCW_CHATROOM;
- gcw.pszModule = m_szModuleName;
- gcw.ptszName = ptszNick;
- gcw.ptszID = ptszJid;
- Chat_NewSession(&gcw);
+ Chat_NewSession(GCW_CHATROOM, m_szModuleName, ptszJid, ptszNick);
pInfo->hContact = (hOldContact != NULL) ? hOldContact : ContactIDToHContact(jid);
diff --git a/protocols/Yahoo/src/chat.cpp b/protocols/Yahoo/src/chat.cpp index b11bcaba0c..afb1fafd94 100644 --- a/protocols/Yahoo/src/chat.cpp +++ b/protocols/Yahoo/src/chat.cpp @@ -151,13 +151,7 @@ void CYahooProto::ChatRegister(void) void CYahooProto::ChatStart(const char* room)
{
ptrW idt(mir_a2u(room));
-
- GCSESSION gcw = {};
- gcw.iType = GCW_CHATROOM;
- gcw.pszModule = m_szModuleName;
- gcw.ptszName = idt;
- gcw.ptszID = idt;
- Chat_NewSession(&gcw);
+ Chat_NewSession(GCW_CHATROOM, m_szModuleName, idt, idt);
Chat_AddGroup(m_szModuleName, idt, TranslateT("Me"));
Chat_AddGroup(m_szModuleName, idt, TranslateT("Others"));
diff --git a/src/core/stdchat/src/services.cpp b/src/core/stdchat/src/services.cpp index 5fe0c9c70e..119830d217 100644 --- a/src/core/stdchat/src/services.cpp +++ b/src/core/stdchat/src/services.cpp @@ -38,7 +38,6 @@ void ShowRoom(SESSION_INFO *si, WPARAM wp, BOOL bSetForeground) g_TabSession.pLog = si->pLog;
g_TabSession.pLogEnd = si->pLogEnd;
g_TabSession.pMe = si->pMe;
- g_TabSession.dwFlags = si->dwFlags;
g_TabSession.pStatuses = si->pStatuses;
g_TabSession.ptszID = si->ptszID;
g_TabSession.pszModule = si->pszModule;
diff --git a/src/mir_app/src/chat_manager.cpp b/src/mir_app/src/chat_manager.cpp index ccfa6c14a9..b602a42bc4 100644 --- a/src/mir_app/src/chat_manager.cpp +++ b/src/mir_app/src/chat_manager.cpp @@ -1123,7 +1123,6 @@ MIR_APP_DLL(CHAT_MANAGER*) Chat_GetInterface(CHAT_MANAGER_INITDATA *pInit, int _ chatApi.LM_TrimLog = LM_TrimLog;
chatApi.LM_RemoveAll = LM_RemoveAll;
- chatApi.AddRoom = AddRoom;
chatApi.SetOffline = SetOffline;
chatApi.SetAllOffline = SetAllOffline;
chatApi.AddEvent = AddEvent;
diff --git a/src/mir_app/src/chat_svc.cpp b/src/mir_app/src/chat_svc.cpp index 3734f29379..f3862b4140 100644 --- a/src/mir_app/src/chat_svc.cpp +++ b/src/mir_app/src/chat_svc.cpp @@ -153,12 +153,12 @@ EXTERN_C MIR_APP_DLL(int) Chat_GetInfo(GC_INFO *gci) MIR_APP_DLL(int) Chat_Register(const GCREGISTER *gcr)
{
if (gcr == NULL)
- return GC_REGISTER_ERROR;
+ return GC_ERROR;
mir_cslock lck(csChat);
MODULEINFO *mi = chatApi.MM_AddModule(gcr->pszModule);
if (mi == NULL)
- return GC_REGISTER_ERROR;
+ return GC_ERROR;
mi->ptszModDispName = mir_wstrdup(gcr->ptszDispName);
mi->bBold = (gcr->dwFlags & GC_BOLD) != 0;
@@ -187,18 +187,20 @@ MIR_APP_DLL(int) Chat_Register(const GCREGISTER *gcr) /////////////////////////////////////////////////////////////////////////////////////////
// starts new chat session
-EXTERN_C MIR_APP_DLL(int) Chat_NewSession(const GCSESSION *gcw)
+EXTERN_C MIR_APP_DLL(int) Chat_NewSession(
+ int iType, // Use one of the GCW_* flags above to set the type of session
+ const char *pszModule, // The name of the protocol owning the session (the same as pszModule when you register)
+ const wchar_t *ptszID, // The unique identifier for the session.
+ const wchar_t *ptszName, // The name of the session as it will be displayed to the user
+ void *pItemData) // Set user defined data for this session. Retrieve it by using the Chat_GetUserInfo() call
{
- if (gcw == NULL)
- return GC_NEWSESSION_ERROR;
-
mir_cslockfull lck(csChat);
- MODULEINFO *mi = chatApi.MM_FindModule(gcw->pszModule);
+ MODULEINFO *mi = chatApi.MM_FindModule(pszModule);
if (mi == NULL)
- return GC_NEWSESSION_ERROR;
+ return GC_ERROR;
// try to restart a session first
- SESSION_INFO *si = chatApi.SM_FindSession(gcw->ptszID, gcw->pszModule);
+ SESSION_INFO *si = chatApi.SM_FindSession(ptszID, pszModule);
if (si != NULL) {
chatApi.UM_RemoveAll(&si->pUsers);
chatApi.TM_RemoveAll(&si->pStatuses);
@@ -215,8 +217,8 @@ EXTERN_C MIR_APP_DLL(int) Chat_NewSession(const GCSESSION *gcw) // create a new session
si = (SESSION_INFO*)mir_calloc(g_cbSession);
- si->ptszID = mir_wstrdup(gcw->ptszID);
- si->pszModule = mir_strdup(gcw->pszModule);
+ si->ptszID = mir_wstrdup(ptszID);
+ si->pszModule = mir_strdup(pszModule);
if (chatApi.wndList == NULL) // list is empty
chatApi.wndList = si;
@@ -227,13 +229,11 @@ EXTERN_C MIR_APP_DLL(int) Chat_NewSession(const GCSESSION *gcw) lck.unlock();
// set the defaults
- si->pItemData = gcw->pItemData;
- if (gcw->iType != GCW_SERVER)
+ si->pItemData = pItemData;
+ if (iType != GCW_SERVER)
si->wStatus = ID_STATUS_ONLINE;
- si->iType = gcw->iType;
- si->dwFlags = gcw->dwFlags;
- si->ptszName = mir_wstrdup(gcw->ptszName);
- si->ptszStatusbarText = mir_wstrdup(gcw->ptszStatusbarText);
+ si->iType = iType;
+ si->ptszName = mir_wstrdup(ptszName);
si->iSplitterX = g_Settings->iSplitterX;
si->iSplitterY = g_Settings->iSplitterY;
si->iLogFilterFlags = db_get_dw(NULL, CHAT_MODULE, "FilterFlags", 0x03E0);
@@ -254,7 +254,7 @@ EXTERN_C MIR_APP_DLL(int) Chat_NewSession(const GCSESSION *gcw) mir_snwprintf(szTemp, L"Server: %s", si->ptszName);
else
wcsncpy_s(szTemp, si->ptszName, _TRUNCATE);
- si->hContact = chatApi.AddRoom(gcw->pszModule, gcw->ptszID, szTemp, si->iType);
+ si->hContact = AddRoom(pszModule, ptszID, szTemp, si->iType);
db_set_s(si->hContact, si->pszModule, "Topic", "");
db_unset(si->hContact, "CList", "StatusMsg");
if (si->ptszStatusbarText)
|