summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/m_chat_int.h30
-rw-r--r--plugins/TabSRMM/src/chat/manager.cpp2
-rw-r--r--src/mir_app/src/chat_manager.cpp1
-rw-r--r--src/mir_app/src/chat_svc.cpp52
4 files changed, 42 insertions, 43 deletions
diff --git a/include/m_chat_int.h b/include/m_chat_int.h
index afeb345a81..e8e56c654d 100644
--- a/include/m_chat_int.h
+++ b/include/m_chat_int.h
@@ -110,7 +110,7 @@ struct LOGSTREAMDATA;
struct GCModuleInfoBase
{
char* pszModule;
- wchar_t* ptszModDispName;
+ wchar_t* ptszModDispName;
char* pszHeader;
bool bBold;
bool bUnderline;
@@ -145,16 +145,16 @@ struct FONTINFO
struct LOGINFO
{
- wchar_t* ptszText;
- wchar_t* ptszNick;
- wchar_t* ptszUID;
- wchar_t* ptszStatus;
- wchar_t* ptszUserInfo;
- BOOL bIsMe;
- BOOL bIsHighlighted;
- time_t time;
- int iType;
- DWORD dwFlags;
+ wchar_t *ptszText;
+ wchar_t *ptszNick;
+ wchar_t *ptszUID;
+ wchar_t *ptszStatus;
+ wchar_t *ptszUserInfo;
+ BOOL bIsMe;
+ BOOL bIsHighlighted;
+ time_t time;
+ int iType;
+ DWORD dwFlags;
LOGINFO *next, *prev;
};
@@ -188,10 +188,10 @@ struct GCSessionInfoBase
BOOL bTrimmed;
char* pszModule;
- wchar_t* ptszID;
- wchar_t* ptszName;
- wchar_t* ptszStatusbarText;
- wchar_t* ptszTopic;
+ wchar_t* ptszID;
+ wchar_t* ptszName;
+ wchar_t* ptszStatusbarText;
+ wchar_t* ptszTopic;
int iType;
int iFG;
diff --git a/plugins/TabSRMM/src/chat/manager.cpp b/plugins/TabSRMM/src/chat/manager.cpp
index 2b5143465c..8c0300568d 100644
--- a/plugins/TabSRMM/src/chat/manager.cpp
+++ b/plugins/TabSRMM/src/chat/manager.cpp
@@ -113,7 +113,7 @@ SESSION_INFO* SM_FindSessionAutoComplete(const char* pszModule, SESSION_INFO* cu
if (prevSession == NULL && my_strstri(currSession->ptszName, pszOriginal) == currSession->ptszName)
return currSession;
- wchar_t* pszName = NULL;
+ wchar_t *pszName = NULL;
if (currSession == prevSession)
pszCurrent = pszOriginal;
diff --git a/src/mir_app/src/chat_manager.cpp b/src/mir_app/src/chat_manager.cpp
index 9758431011..6fb83d1e92 100644
--- a/src/mir_app/src/chat_manager.cpp
+++ b/src/mir_app/src/chat_manager.cpp
@@ -160,6 +160,7 @@ static SESSION_INFO* SM_FindSession(const wchar_t *pszID, const char *pszModule)
if (!pszID || !pszModule)
return NULL;
+ mir_cslock lck(csChat);
for (SESSION_INFO *si = chatApi.wndList; si != NULL; si = si->next)
if (!mir_wstrcmpi(si->ptszID, pszID) && !mir_strcmpi(si->pszModule, pszModule))
return si;
diff --git a/src/mir_app/src/chat_svc.cpp b/src/mir_app/src/chat_svc.cpp
index c6b1e486ec..da27bdd19a 100644
--- a/src/mir_app/src/chat_svc.cpp
+++ b/src/mir_app/src/chat_svc.cpp
@@ -260,23 +260,17 @@ EXTERN_C MIR_APP_DLL(int) Chat_NewSession(const GCSESSION *gcw)
/////////////////////////////////////////////////////////////////////////////////////////
// chat control
-struct ShowChatParam
+struct ChatConrolParam
{
- ShowChatParam(SESSION_INFO *_si, int _command, int _bShow) :
- si(_si), command(_command), bShow(_bShow)
+ ChatConrolParam(const char *_szModule, const wchar_t *_wszId, int _command) :
+ szModule(_szModule), wszId(_wszId), command(_command)
{}
- SESSION_INFO *si;
- int command, bShow;
+ const wchar_t *wszId;
+ const char *szModule;
+ int command;
};
-static void __stdcall stubShowRoom(void *param)
-{
- ShowChatParam *p = (ShowChatParam*)param;
- chatApi.ShowRoom(p->si, p->command, p->bShow);
- delete p;
-}
-
static void SetInitDone(SESSION_INFO *si)
{
if (si->bInitDone)
@@ -288,18 +282,18 @@ static void SetInitDone(SESSION_INFO *si)
p->hIcon = HICON(si->iStatusCount - (INT_PTR)p->hIcon - 1);
}
-MIR_APP_DLL(int) Chat_Control(const char *szModule, const wchar_t *wszId, int iCommand)
+static INT_PTR __stdcall stubRoomControl(void *param)
{
- SESSION_INFO *si;
+ ChatConrolParam *p = (ChatConrolParam*)param;
mir_cslock lck(csChat);
- switch (iCommand) {
+ switch (p->command) {
case WINDOW_HIDDEN:
- if (si = chatApi.SM_FindSession(wszId, szModule)) {
+ if (SESSION_INFO *si = chatApi.SM_FindSession(p->wszId, p->szModule)) {
SetInitDone(si);
chatApi.SetActiveSession(si->ptszID, si->pszModule);
if (si->hWnd)
- CallFunctionAsync(stubShowRoom, new ShowChatParam(si, iCommand, FALSE));
+ chatApi.ShowRoom(si, p->command, FALSE);
}
return 0;
@@ -307,27 +301,27 @@ MIR_APP_DLL(int) Chat_Control(const char *szModule, const wchar_t *wszId, int iC
case WINDOW_MAXIMIZE:
case WINDOW_VISIBLE:
case SESSION_INITDONE:
- if (si = chatApi.SM_FindSession(wszId, szModule)) {
+ if (SESSION_INFO *si = chatApi.SM_FindSession(p->wszId, p->szModule)) {
SetInitDone(si);
- if (iCommand != SESSION_INITDONE || db_get_b(NULL, CHAT_MODULE, "PopupOnJoin", 0) == 0)
- CallFunctionAsync(stubShowRoom, new ShowChatParam(si, iCommand, TRUE));
+ if (p->command != SESSION_INITDONE || db_get_b(NULL, CHAT_MODULE, "PopupOnJoin", 0) == 0)
+ chatApi.ShowRoom(si, p->command, TRUE);
return 0;
}
break;
case SESSION_OFFLINE:
- chatApi.SM_SetOffline(wszId, szModule);
+ chatApi.SM_SetOffline(p->wszId, p->szModule);
// fall through
case SESSION_ONLINE:
- chatApi.SM_SetStatus(wszId, szModule, iCommand == SESSION_ONLINE ? ID_STATUS_ONLINE : ID_STATUS_OFFLINE);
+ chatApi.SM_SetStatus(p->wszId, p->szModule, p->command == SESSION_ONLINE ? ID_STATUS_ONLINE : ID_STATUS_OFFLINE);
break;
case SESSION_TERMINATE:
- return chatApi.SM_RemoveSession(wszId, szModule, false);
+ return chatApi.SM_RemoveSession(p->wszId, p->szModule, false);
case WINDOW_CLEARLOG:
- if (si = chatApi.SM_FindSession(wszId, szModule)) {
+ if (SESSION_INFO *si = chatApi.SM_FindSession(p->wszId, p->szModule)) {
chatApi.LM_RemoveAll(&si->pLog, &si->pLogEnd);
if (chatApi.OnClearLog)
chatApi.OnClearLog(si);
@@ -340,10 +334,16 @@ MIR_APP_DLL(int) Chat_Control(const char *szModule, const wchar_t *wszId, int iC
return GC_EVENT_ERROR;
}
- chatApi.SM_SendMessage(wszId, szModule, GC_CONTROL_MSG, iCommand, 0);
+ chatApi.SM_SendMessage(p->wszId, p->szModule, GC_CONTROL_MSG, p->command, 0);
return 0;
}
+MIR_APP_DLL(int) Chat_Control(const char *szModule, const wchar_t *wszId, int iCommand)
+{
+ ChatConrolParam param = { szModule, wszId, iCommand };
+ return CallFunctionSync(stubRoomControl, &param);
+}
+
MIR_APP_DLL(int) Chat_Terminate(const char *szModule, const wchar_t *wszId, bool bRemoveContact)
{
mir_cslock lck(csChat);
@@ -430,8 +430,6 @@ EXTERN_C MIR_APP_DLL(int) Chat_Event(GCEVENT *gce)
if (NotifyEventHooks(hHookEvent, 0, LPARAM(gce)))
return 1;
- mir_cslock lck(csChat);
-
// Do different things according to type of event
switch (gcd->iType) {
case GC_EVENT_ADDGROUP: