diff options
-rw-r--r-- | include/m_chat.h | 1 | ||||
-rw-r--r-- | include/m_chat_int.h | 19 | ||||
-rw-r--r-- | protocols/FacebookRM/src/communication.cpp | 6 | ||||
-rw-r--r-- | src/core/stdchat/src/manager.cpp | 11 | ||||
-rw-r--r-- | src/core/stdchat/src/services.cpp | 2 | ||||
-rw-r--r-- | src/core/stdchat/src/stdafx.h | 1 | ||||
-rw-r--r-- | src/core/stdchat/src/window.cpp | 2 | ||||
-rw-r--r-- | src/mir_app/src/chat.h | 72 | ||||
-rw-r--r-- | src/mir_app/src/chat_clist.cpp | 2 | ||||
-rw-r--r-- | src/mir_app/src/chat_manager.cpp | 175 | ||||
-rw-r--r-- | src/mir_app/src/chat_svc.cpp | 110 |
11 files changed, 162 insertions, 239 deletions
diff --git a/include/m_chat.h b/include/m_chat.h index d8236f3971..c94b2fa26d 100644 --- a/include/m_chat.h +++ b/include/m_chat.h @@ -405,6 +405,7 @@ EXTERN_C MIR_APP_DLL(int) Chat_SetStatusbarText(const char *szModule, const wcha #define GC_SSE_TABDELIMITED 0x0004 // use tabs as delimiters
#define GC_SSE_OFFLINE 0x0008 // displays a contact offline, otherwise away
+// if wszId == NULL, the status is applied to all windows of specified szModule
EXTERN_C MIR_APP_DLL(int) Chat_SetStatusEx(const char *szModule, const wchar_t *wszId, int flags, const wchar_t *wszText);
/////////////////////////////////////////////////////////////////////////////////////////
diff --git a/include/m_chat_int.h b/include/m_chat_int.h index e8e56c654d..6aa36ebfd4 100644 --- a/include/m_chat_int.h +++ b/include/m_chat_int.h @@ -304,35 +304,16 @@ struct CHAT_MANAGER void (*SetActiveSession)(const wchar_t *pszID, const char *pszModule);
void (*SetActiveSessionEx)(SESSION_INFO *si);
SESSION_INFO* (*GetActiveSession)(void);
- SESSION_INFO* (*SM_AddSession)(const wchar_t *pszID, const char *pszModule);
- int (*SM_RemoveSession)(const wchar_t *pszID, const char *pszModule, BOOL removeContact);
SESSION_INFO* (*SM_FindSession)(const wchar_t *pszID, const char *pszModule);
- USERINFO* (*SM_AddUser)(const wchar_t *pszID, const char *pszModule, const wchar_t *pszUID, const wchar_t *pszNick, WORD wStatus);
- BOOL (*SM_ChangeUID)(const wchar_t *pszID, const char *pszModule, const wchar_t *pszUID, const wchar_t* pszNewUID);
- BOOL (*SM_ChangeNick)(const wchar_t *pszID, const char *pszModule, GCEVENT *gce);
- BOOL (*SM_RemoveUser)(const wchar_t *pszID, const char *pszModule, const wchar_t *pszUID);
- BOOL (*SM_SetOffline)(const wchar_t *pszID, const char *pszModule);
- BOOL (*SM_SetTabbedWindowHwnd)(SESSION_INFO *si, HWND hwnd);
HICON (*SM_GetStatusIcon)(SESSION_INFO *si, USERINFO * ui);
- BOOL (*SM_SetStatus)(const wchar_t *pszID, const char *pszModule, int wStatus);
- BOOL (*SM_SetStatusEx)(const wchar_t *pszID, const char *pszModule, const wchar_t* pszText, int flags);
- BOOL (*SM_SendUserMessage)(const wchar_t *pszID, const char *pszModule, const wchar_t* pszText);
- STATUSINFO* (*SM_AddStatus)(const wchar_t *pszID, const char *pszModule, const wchar_t *pszStatus);
BOOL (*SM_AddEvent)(const wchar_t *pszID, const char *pszModule, GCEVENT *gce, BOOL bIsHighlighted);
- LRESULT (*SM_SendMessage)(const wchar_t *pszID, const char *pszModule, UINT msg, WPARAM wParam, LPARAM lParam);
BOOL (*SM_PostMessage)(const wchar_t *pszID, const char *pszModule, UINT msg, WPARAM wParam, LPARAM lParam);
BOOL (*SM_BroadcastMessage)(const char *pszModule, UINT msg, WPARAM wParam, LPARAM lParam, BOOL bAsync);
- BOOL (*SM_RemoveAll)(void);
- BOOL (*SM_GiveStatus)(const wchar_t *pszID, const char *pszModule, const wchar_t *pszUID, const wchar_t *pszStatus);
- BOOL (*SM_SetContactStatus)(const wchar_t *pszID, const char *pszModule, const wchar_t *pszUID, WORD pszStatus);
- BOOL (*SM_TakeStatus)(const wchar_t *pszID, const char *pszModule, const wchar_t *pszUID, const wchar_t *pszStatus);
- BOOL (*SM_MoveUser)(const wchar_t *pszID, const char *pszModule, const wchar_t *pszUID);
void (*SM_AddCommand)(const wchar_t *pszID, const char *pszModule, const char* lpNewCommand);
char* (*SM_GetPrevCommand)(const wchar_t *pszID, const char *pszModule);
char* (*SM_GetNextCommand)(const wchar_t *pszID, const char *pszModule);
int (*SM_GetCount)(const char *pszModule);
SESSION_INFO* (*SM_FindSessionByIndex)(const char *pszModule, int iItem);
- char* (*SM_GetUsers)(SESSION_INFO *si);
USERINFO* (*SM_GetUserFromIndex)(const wchar_t *pszID, const char *pszModule, int index);
void (*SM_InvalidateLogDirectories)(void);
diff --git a/protocols/FacebookRM/src/communication.cpp b/protocols/FacebookRM/src/communication.cpp index 2e59510c22..419c7dbf7d 100644 --- a/protocols/FacebookRM/src/communication.cpp +++ b/protocols/FacebookRM/src/communication.cpp @@ -1144,8 +1144,7 @@ bool facebook_client::post_status(status_data *status) if (status->isPage) { // Switch to page identity by which name we will share this post - HttpRequest *request = new SwitchIdentityRequest(this->dtsg_.c_str(), status->user_id.c_str()); - sendRequest(request); + sendRequest(new SwitchIdentityRequest(this->dtsg_.c_str(), status->user_id.c_str())); } std::string linkData; @@ -1165,8 +1164,7 @@ bool facebook_client::post_status(status_data *status) if (status->isPage) { // Switch back to our identity - HttpRequest *request = new SwitchIdentityRequest(this->dtsg_.c_str(), this->self_.user_id.c_str()); - sendRequest(request); + sendRequest(new SwitchIdentityRequest(this->dtsg_.c_str(), this->self_.user_id.c_str())); } // cleanup status elements (delete users) diff --git a/src/core/stdchat/src/manager.cpp b/src/core/stdchat/src/manager.cpp index 069e2230a9..1132c7e875 100644 --- a/src/core/stdchat/src/manager.cpp +++ b/src/core/stdchat/src/manager.cpp @@ -24,6 +24,17 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. TABLIST *g_TabList = 0;
+BOOL SM_SetTabbedWindowHwnd(SESSION_INFO *si, HWND hwnd)
+{
+ for (SESSION_INFO *p = pci->wndList; p != NULL; p = p->next) {
+ if (si && si == p)
+ p->hWnd = hwnd;
+ else
+ p->hWnd = NULL;
+ }
+ return TRUE;
+}
+
SESSION_INFO* SM_GetPrevWindow(SESSION_INFO *si)
{
if (!si)
diff --git a/src/core/stdchat/src/services.cpp b/src/core/stdchat/src/services.cpp index f534c4a56c..5fe0c9c70e 100644 --- a/src/core/stdchat/src/services.cpp +++ b/src/core/stdchat/src/services.cpp @@ -61,7 +61,7 @@ void ShowRoom(SESSION_INFO *si, WPARAM wp, BOOL bSetForeground) // if the session was not the current tab we need to tell the window to
// redraw to show the contents of the current SESSION_INFO
if (!si->hWnd) {
- pci->SM_SetTabbedWindowHwnd(si, g_TabSession.hWnd);
+ SM_SetTabbedWindowHwnd(si, g_TabSession.hWnd);
SendMessage(g_TabSession.hWnd, GC_ADDTAB, -1, (LPARAM)si);
SendMessage(g_TabSession.hWnd, GC_TABCHANGE, 0, (LPARAM)&g_TabSession);
}
diff --git a/src/core/stdchat/src/stdafx.h b/src/core/stdchat/src/stdafx.h index 5e27b6b467..a5c90861a1 100644 --- a/src/core/stdchat/src/stdafx.h +++ b/src/core/stdchat/src/stdafx.h @@ -142,6 +142,7 @@ char* Log_CreateRtfHeader(MODULEINFO * mi); INT_PTR CALLBACK RoomWndProc(HWND hwndDlg,UINT uMsg,WPARAM wParam,LPARAM lParam);
int GetTextPixelSize( wchar_t* pszText, HFONT hFont, BOOL bWidth);
+BOOL SM_SetTabbedWindowHwnd(SESSION_INFO *si, HWND hwnd);
SESSION_INFO* SM_GetPrevWindow(SESSION_INFO *si);
SESSION_INFO* SM_GetNextWindow(SESSION_INFO *si);
diff --git a/src/core/stdchat/src/window.cpp b/src/core/stdchat/src/window.cpp index cd6be436d8..5f18af8b47 100644 --- a/src/core/stdchat/src/window.cpp +++ b/src/core/stdchat/src/window.cpp @@ -2590,7 +2590,7 @@ INT_PTR CALLBACK RoomWndProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPar case GC_CLOSEWINDOW:
if (g_Settings.bTabsEnable)
- pci->SM_SetTabbedWindowHwnd(0, 0);
+ SM_SetTabbedWindowHwnd(0, 0);
DestroyWindow(hwndDlg);
break;
diff --git a/src/mir_app/src/chat.h b/src/mir_app/src/chat.h index aff64769ff..5ad1c4e85b 100644 --- a/src/mir_app/src/chat.h +++ b/src/mir_app/src/chat.h @@ -45,6 +45,22 @@ char* Log_CreateRtfHeader(MODULEINFO *mi); char* Log_CreateRTF(LOGSTREAMDATA *streamData);
char* Log_SetStyle(int style);
+// chat_manager.cpp
+BOOL SM_ChangeNick(const wchar_t *pszID, const char *pszModule, GCEVENT *gce);
+char* SM_GetUsers(SESSION_INFO *si);
+BOOL SM_GiveStatus(const wchar_t *pszID, const char *pszModule, const wchar_t *pszUID, const wchar_t *pszStatus);
+BOOL SM_MoveUser(const wchar_t *pszID, const char *pszModule, const wchar_t *pszUID);
+void SM_RemoveAll(void);
+int SM_RemoveSession(const wchar_t *pszID, const char *pszModule, BOOL removeContact);
+BOOL SM_RemoveUser(const wchar_t *pszID, const char *pszModule, const wchar_t *pszUID);
+LRESULT SM_SendMessage(const wchar_t *pszID, const char *pszModule, UINT msg, WPARAM wParam, LPARAM lParam);
+BOOL SM_SetContactStatus(const wchar_t *pszID, const char *pszModule, const wchar_t *pszUID, WORD wStatus);
+BOOL SM_SetOffline(const wchar_t *pszID, const char *pszModule);
+BOOL SM_SetStatus(const wchar_t *pszID, const char *pszModule, int wStatus);
+BOOL SM_TakeStatus(const wchar_t *pszID, const char *pszModule, const wchar_t *pszUID, const wchar_t *pszStatus);
+
+SESSION_INFO* SM_FindSession(const wchar_t *pszID, const char *pszModule);
+
// clist.c
BOOL AddEvent(MCONTACT hContact, HICON hIcon, MEVENT hEvent, int type, wchar_t* fmt, ...);
MCONTACT AddRoom(const char *pszModule, const wchar_t *pszRoom, const wchar_t *pszDisplayName, int iType);
@@ -58,41 +74,41 @@ INT_PTR LeaveChat(WPARAM wParam, LPARAM lParam); int PrebuildContactMenu(WPARAM wParam, LPARAM lParam);
// colorchooser.c
-void ColorChooser(SESSION_INFO *si, BOOL bFG, HWND hwndDlg, HWND hwndTarget, HWND hwndChooser);
+void ColorChooser(SESSION_INFO *si, BOOL bFG, HWND hwndDlg, HWND hwndTarget, HWND hwndChooser);
// options.c
-int OptionsInit(void);
-int OptionsUnInit(void);
-void LoadMsgDlgFont(int i, LOGFONT * lf, COLORREF * colour);
-void LoadGlobalSettings(void);
-HICON LoadIconEx(char* pszIcoLibName, bool big);
-void LoadLogFonts(void);
-void SetIndentSize(void);
-void RegisterFonts(void);
+int OptionsInit(void);
+int OptionsUnInit(void);
+void LoadMsgDlgFont(int i, LOGFONT * lf, COLORREF * colour);
+void LoadGlobalSettings(void);
+HICON LoadIconEx(char* pszIcoLibName, bool big);
+void LoadLogFonts(void);
+void SetIndentSize(void);
+void RegisterFonts(void);
// services.c
-void LoadChatIcons(void);
-int LoadChatModule(void);
-void UnloadChatModule(void);
+void LoadChatIcons(void);
+int LoadChatModule(void);
+void UnloadChatModule(void);
// tools.c
-int DoRtfToTags(CMStringW &pszText, int iNumColors, COLORREF *pColors);
-int GetTextPixelSize(wchar_t* pszText, HFONT hFont, BOOL bWidth);
+int DoRtfToTags(CMStringW &pszText, int iNumColors, COLORREF *pColors);
+int GetTextPixelSize(wchar_t* pszText, HFONT hFont, BOOL bWidth);
wchar_t *RemoveFormatting(const wchar_t* pszText);
-BOOL DoSoundsFlashPopupTrayStuff(SESSION_INFO *si, GCEVENT *gce, BOOL bHighlight, int bManyFix);
-int GetColorIndex(const char *pszModule, COLORREF cr);
-void CheckColorsInModule(const char *pszModule);
-int GetRichTextLength(HWND hwnd);
-BOOL IsHighlighted(SESSION_INFO *si, GCEVENT *pszText);
-UINT CreateGCMenu(HWND hwndDlg, HMENU *hMenu, int iIndex, POINT pt, SESSION_INFO *si, wchar_t* pszUID, wchar_t* pszWordText);
-void DestroyGCMenu(HMENU *hMenu, int iIndex);
-BOOL DoEventHookAsync(HWND hwnd, const wchar_t *pszID, const char *pszModule, int iType, const wchar_t* pszUID, const wchar_t* pszText, INT_PTR dwItem);
-BOOL DoEventHook(const wchar_t *pszID, const char *pszModule, int iType, const wchar_t *pszUID, const wchar_t* pszText, INT_PTR dwItem);
-BOOL IsEventSupported(int eventType);
-BOOL LogToFile(SESSION_INFO *si, GCEVENT *gce);
-BOOL DoTrayIcon(SESSION_INFO *si, GCEVENT *gce);
-BOOL DoPopup(SESSION_INFO *si, GCEVENT *gce);
-int ShowPopup(MCONTACT hContact, SESSION_INFO *si, HICON hIcon, char* pszProtoName, wchar_t* pszRoomName, COLORREF crBkg, const wchar_t* fmt, ...);
+BOOL DoSoundsFlashPopupTrayStuff(SESSION_INFO *si, GCEVENT *gce, BOOL bHighlight, int bManyFix);
+int GetColorIndex(const char *pszModule, COLORREF cr);
+void CheckColorsInModule(const char *pszModule);
+int GetRichTextLength(HWND hwnd);
+BOOL IsHighlighted(SESSION_INFO *si, GCEVENT *pszText);
+UINT CreateGCMenu(HWND hwndDlg, HMENU *hMenu, int iIndex, POINT pt, SESSION_INFO *si, wchar_t* pszUID, wchar_t* pszWordText);
+void DestroyGCMenu(HMENU *hMenu, int iIndex);
+BOOL DoEventHookAsync(HWND hwnd, const wchar_t *pszID, const char *pszModule, int iType, const wchar_t* pszUID, const wchar_t* pszText, INT_PTR dwItem);
+BOOL DoEventHook(const wchar_t *pszID, const char *pszModule, int iType, const wchar_t *pszUID, const wchar_t* pszText, INT_PTR dwItem);
+BOOL IsEventSupported(int eventType);
+BOOL LogToFile(SESSION_INFO *si, GCEVENT *gce);
+BOOL DoTrayIcon(SESSION_INFO *si, GCEVENT *gce);
+BOOL DoPopup(SESSION_INFO *si, GCEVENT *gce);
+int ShowPopup(MCONTACT hContact, SESSION_INFO *si, HICON hIcon, char* pszProtoName, wchar_t* pszRoomName, COLORREF crBkg, const wchar_t* fmt, ...);
const wchar_t* my_strstri(const wchar_t* s1, const wchar_t* s2);
diff --git a/src/mir_app/src/chat_clist.cpp b/src/mir_app/src/chat_clist.cpp index 679e24e880..c2aec1fb3e 100644 --- a/src/mir_app/src/chat_clist.cpp +++ b/src/mir_app/src/chat_clist.cpp @@ -114,7 +114,7 @@ int RoomDoubleclicked(WPARAM hContact, LPARAM) if (roomid == NULL)
return 0;
- SESSION_INFO *si = chatApi.SM_FindSession(roomid, szProto);
+ SESSION_INFO *si = SM_FindSession(roomid, szProto);
if (si) {
// is the "toggle visibility option set, so we need to close the window?
if (si->hWnd != NULL &&
diff --git a/src/mir_app/src/chat_manager.cpp b/src/mir_app/src/chat_manager.cpp index 6fb83d1e92..ccfa6c14a9 100644 --- a/src/mir_app/src/chat_manager.cpp +++ b/src/mir_app/src/chat_manager.cpp @@ -40,14 +40,14 @@ static void SetActiveSessionEx(SESSION_INFO *si) static void SetActiveSession(const wchar_t *pszID, const char *pszModule)
{
- SESSION_INFO *si = chatApi.SM_FindSession(pszID, pszModule);
+ SESSION_INFO *si = SM_FindSession(pszID, pszModule);
if (si)
SetActiveSessionEx(si);
}
static SESSION_INFO* GetActiveSession(void)
{
- SESSION_INFO *si = chatApi.SM_FindSession(chatApi.szActiveWndID, chatApi.szActiveWndModule);
+ SESSION_INFO *si = SM_FindSession(chatApi.szActiveWndID, chatApi.szActiveWndModule);
if (si)
return si;
@@ -60,26 +60,6 @@ static SESSION_INFO* GetActiveSession(void) // Keeps track of all sessions and its windows
//---------------------------------------------------
-static SESSION_INFO* SM_AddSession(const wchar_t *pszID, const char *pszModule)
-{
- if (!pszID || !pszModule)
- return NULL;
-
- SESSION_INFO *node = (SESSION_INFO*)mir_calloc(g_cbSession);
- node->ptszID = mir_wstrdup(pszID);
- node->pszModule = mir_strdup(pszModule);
-
- if (chatApi.wndList == NULL) { // list is empty
- chatApi.wndList = node;
- node->next = NULL;
- }
- else {
- node->next = chatApi.wndList;
- chatApi.wndList = node;
- }
- return node;
-}
-
static void SM_FreeSession(SESSION_INFO *si)
{
// contact may have been deleted here already, since function may be called after deleting
@@ -114,7 +94,7 @@ static void SM_FreeSession(SESSION_INFO *si) mir_free(si);
}
-static int SM_RemoveSession(const wchar_t *pszID, const char *pszModule, BOOL removeContact)
+int SM_RemoveSession(const wchar_t *pszID, const char *pszModule, BOOL removeContact)
{
if (!pszModule)
return FALSE;
@@ -155,7 +135,7 @@ static int SM_RemoveSession(const wchar_t *pszID, const char *pszModule, BOOL re return FALSE;
}
-static SESSION_INFO* SM_FindSession(const wchar_t *pszID, const char *pszModule)
+SESSION_INFO* SM_FindSession(const wchar_t *pszID, const char *pszModule)
{
if (!pszID || !pszModule)
return NULL;
@@ -168,7 +148,7 @@ static SESSION_INFO* SM_FindSession(const wchar_t *pszID, const char *pszModule) return NULL;
}
-static BOOL SM_SetOffline(const wchar_t *pszID, const char *pszModule)
+BOOL SM_SetOffline(const wchar_t *pszID, const char *pszModule)
{
if (!pszModule)
return FALSE;
@@ -190,24 +170,6 @@ static BOOL SM_SetOffline(const wchar_t *pszID, const char *pszModule) return TRUE;
}
-static BOOL SM_SetStatusEx(const wchar_t *pszID, const char *pszModule, const wchar_t* pszText, int flags)
-{
- if (!pszModule)
- return FALSE;
-
- for (SESSION_INFO *si = chatApi.wndList; si != NULL; si = si->next) {
- if ((pszID && mir_wstrcmpi(si->ptszID, pszID)) || mir_strcmpi(si->pszModule, pszModule))
- continue;
-
- chatApi.UM_SetStatusEx(si->pUsers, pszText, flags);
- if (si->hWnd)
- RedrawWindow(GetDlgItem(si->hWnd, IDC_LIST), NULL, NULL, RDW_INVALIDATE);
- if (pszID)
- return TRUE;
- }
- return TRUE;
-}
-
static HICON SM_GetStatusIcon(SESSION_INFO *si, USERINFO * ui)
{
if (!ui || !si)
@@ -251,20 +213,7 @@ static BOOL SM_AddEvent(const wchar_t *pszID, const char *pszModule, GCEVENT *gc return TRUE;
}
-static USERINFO* SM_AddUser(const wchar_t *pszID, const char *pszModule, const wchar_t *pszUID, const wchar_t *pszNick, WORD wStatus)
-{
- SESSION_INFO *si = SM_FindSession(pszID, pszModule);
- if (si == NULL)
- return NULL;
-
- USERINFO *p = chatApi.UM_AddUser(si->pStatuses, &si->pUsers, pszUID, pszNick, wStatus);
- si->nUsersInNicklist++;
- if (chatApi.OnAddUser)
- chatApi.OnAddUser(si, p);
- return p;
-}
-
-static BOOL SM_MoveUser(const wchar_t *pszID, const char *pszModule, const wchar_t *pszUID)
+BOOL SM_MoveUser(const wchar_t *pszID, const char *pszModule, const wchar_t *pszUID)
{
if (!pszUID)
return FALSE;
@@ -277,7 +226,7 @@ static BOOL SM_MoveUser(const wchar_t *pszID, const char *pszModule, const wchar return TRUE;
}
-static BOOL SM_RemoveUser(const wchar_t *pszID, const char *pszModule, const wchar_t *pszUID)
+BOOL SM_RemoveUser(const wchar_t *pszID, const char *pszModule, const wchar_t *pszUID)
{
if (!pszModule || !pszUID)
return FALSE;
@@ -304,7 +253,7 @@ static BOOL SM_RemoveUser(const wchar_t *pszID, const char *pszModule, const wch }
}
- return 0;
+ return FALSE;
}
static USERINFO* SM_GetUserFromIndex(const wchar_t *pszID, const char *pszModule, int index)
@@ -313,21 +262,7 @@ static USERINFO* SM_GetUserFromIndex(const wchar_t *pszID, const char *pszModule return (si == NULL) ? NULL : chatApi.UM_FindUserFromIndex(si->pUsers, index);
}
-STATUSINFO* SM_AddStatus(const wchar_t *pszID, const char *pszModule, const wchar_t *pszStatus)
-{
- SESSION_INFO *si = SM_FindSession(pszID, pszModule);
- if (si == NULL)
- return NULL;
-
- STATUSINFO *ti = chatApi.TM_AddStatus(&si->pStatuses, pszStatus, &si->iStatusCount);
- if (ti)
- si->iStatusCount++;
- if (chatApi.OnAddStatus)
- chatApi.OnAddStatus(si, ti);
- return ti;
-}
-
-static BOOL SM_GiveStatus(const wchar_t *pszID, const char *pszModule, const wchar_t *pszUID, const wchar_t *pszStatus)
+BOOL SM_GiveStatus(const wchar_t *pszID, const char *pszModule, const wchar_t *pszUID, const wchar_t *pszStatus)
{
SESSION_INFO *si = SM_FindSession(pszID, pszModule);
if (si == NULL)
@@ -342,7 +277,7 @@ static BOOL SM_GiveStatus(const wchar_t *pszID, const char *pszModule, const wch return TRUE;
}
-static BOOL SM_SetContactStatus(const wchar_t *pszID, const char *pszModule, const wchar_t *pszUID, WORD wStatus)
+BOOL SM_SetContactStatus(const wchar_t *pszID, const char *pszModule, const wchar_t *pszUID, WORD wStatus)
{
SESSION_INFO *si = SM_FindSession(pszID, pszModule);
if (si == NULL)
@@ -357,7 +292,7 @@ static BOOL SM_SetContactStatus(const wchar_t *pszID, const char *pszModule, con return TRUE;
}
-static BOOL SM_TakeStatus(const wchar_t *pszID, const char *pszModule, const wchar_t *pszUID, const wchar_t *pszStatus)
+BOOL SM_TakeStatus(const wchar_t *pszID, const char *pszModule, const wchar_t *pszUID, const wchar_t *pszStatus)
{
SESSION_INFO *si = SM_FindSession(pszID, pszModule);
if (si == NULL)
@@ -372,7 +307,7 @@ static BOOL SM_TakeStatus(const wchar_t *pszID, const char *pszModule, const wch return TRUE;
}
-static LRESULT SM_SendMessage(const wchar_t *pszID, const char *pszModule, UINT msg, WPARAM wParam, LPARAM lParam)
+LRESULT SM_SendMessage(const wchar_t *pszID, const char *pszModule, UINT msg, WPARAM wParam, LPARAM lParam)
{
if (pszModule == NULL)
return 0;
@@ -392,17 +327,6 @@ static LRESULT SM_SendMessage(const wchar_t *pszID, const char *pszModule, UINT return 0;
}
-static BOOL SM_PostMessage(const wchar_t *pszID, const char *pszModule, UINT msg, WPARAM wParam, LPARAM lParam)
-{
- SESSION_INFO *si = SM_FindSession(pszID, pszModule);
- if (si == NULL)
- return FALSE;
-
- if (si->hWnd)
- return PostMessage(si->hWnd, msg, wParam, lParam);
- return FALSE;
-}
-
static BOOL SM_BroadcastMessage(const char *pszModule, UINT msg, WPARAM wParam, LPARAM lParam, BOOL bAsync)
{
for (SESSION_INFO *si = chatApi.wndList; si != NULL; si = si->next) {
@@ -419,7 +343,7 @@ static BOOL SM_BroadcastMessage(const char *pszModule, UINT msg, WPARAM wParam, return TRUE;
}
-static BOOL SM_SetStatus(const wchar_t *pszID, const char *pszModule, int wStatus)
+BOOL SM_SetStatus(const wchar_t *pszID, const char *pszModule, int wStatus)
{
if (!pszModule)
return FALSE;
@@ -445,42 +369,7 @@ static BOOL SM_SetStatus(const wchar_t *pszID, const char *pszModule, int wStatu return TRUE;
}
-static BOOL SM_SendUserMessage(const wchar_t *pszID, const char *pszModule, const wchar_t* pszText)
-{
- if (!pszModule || !pszText)
- return FALSE;
-
- for (SESSION_INFO *si = chatApi.wndList; si != NULL; si = si->next) {
- if ((pszID && mir_wstrcmpi(si->ptszID, pszID)) || mir_strcmpi(si->pszModule, pszModule))
- continue;
-
- if (si->iType == GCW_CHATROOM || si->iType == GCW_PRIVMESS)
- DoEventHook(si->ptszID, si->pszModule, GC_USER_MESSAGE, NULL, pszText, 0);
- if (pszID)
- return TRUE;
- }
- return TRUE;
-}
-
-static BOOL SM_ChangeUID(const wchar_t *pszID, const char *pszModule, const wchar_t *pszUID, const wchar_t* pszNewUID)
-{
- if (!pszModule)
- return FALSE;
-
- for (SESSION_INFO *si = chatApi.wndList; si != NULL; si = si->next) {
- if ((pszID && mir_wstrcmpi(si->ptszID, pszID)) || mir_strcmpi(si->pszModule, pszModule))
- continue;
-
- USERINFO *ui = chatApi.UM_FindUser(si->pUsers, pszUID);
- if (ui)
- replaceStrW(ui->pszUID, pszNewUID);
- if (pszID)
- return TRUE;
- }
- return TRUE;
-}
-
-static BOOL SM_ChangeNick(const wchar_t *pszID, const char *pszModule, GCEVENT *gce)
+BOOL SM_ChangeNick(const wchar_t *pszID, const char *pszModule, GCEVENT *gce)
{
if (!pszModule)
return FALSE;
@@ -504,18 +393,7 @@ static BOOL SM_ChangeNick(const wchar_t *pszID, const char *pszModule, GCEVENT * return TRUE;
}
-static BOOL SM_SetTabbedWindowHwnd(SESSION_INFO *si, HWND hwnd)
-{
- for (SESSION_INFO *p = chatApi.wndList; p != NULL; p = p->next) {
- if (si && si == p)
- p->hWnd = hwnd;
- else
- p->hWnd = NULL;
- }
- return TRUE;
-}
-
-static BOOL SM_RemoveAll(void)
+void SM_RemoveAll(void)
{
while (chatApi.wndList) {
SESSION_INFO *pLast = chatApi.wndList->next;
@@ -528,7 +406,6 @@ static BOOL SM_RemoveAll(void) chatApi.wndList = pLast;
}
chatApi.wndList = NULL;
- return TRUE;
}
static void SM_AddCommand(const wchar_t *pszID, const char *pszModule, const char* lpNewCommand)
@@ -625,7 +502,7 @@ static SESSION_INFO* SM_FindSessionByIndex(const char *pszModule, int iItem) }
-static char* SM_GetUsers(SESSION_INFO *si)
+char* SM_GetUsers(SESSION_INFO *si)
{
if (si == NULL)
return NULL;
@@ -1204,35 +1081,15 @@ MIR_APP_DLL(CHAT_MANAGER*) Chat_GetInterface(CHAT_MANAGER_INITDATA *pInit, int _ chatApi.SetActiveSession = SetActiveSession;
chatApi.SetActiveSessionEx = SetActiveSessionEx;
chatApi.GetActiveSession = GetActiveSession;
- chatApi.SM_AddSession = SM_AddSession;
- chatApi.SM_RemoveSession = SM_RemoveSession;
chatApi.SM_FindSession = SM_FindSession;
- chatApi.SM_AddUser = SM_AddUser;
- chatApi.SM_ChangeUID = SM_ChangeUID;
- chatApi.SM_ChangeNick = SM_ChangeNick;
- chatApi.SM_RemoveUser = SM_RemoveUser;
- chatApi.SM_SetOffline = SM_SetOffline;
- chatApi.SM_SetTabbedWindowHwnd = SM_SetTabbedWindowHwnd;
chatApi.SM_GetStatusIcon = SM_GetStatusIcon;
- chatApi.SM_SetStatus = SM_SetStatus;
- chatApi.SM_SetStatusEx = SM_SetStatusEx;
- chatApi.SM_SendUserMessage = SM_SendUserMessage;
- chatApi.SM_AddStatus = SM_AddStatus;
chatApi.SM_AddEvent = SM_AddEvent;
- chatApi.SM_SendMessage = SM_SendMessage;
- chatApi.SM_PostMessage = SM_PostMessage;
chatApi.SM_BroadcastMessage = SM_BroadcastMessage;
- chatApi.SM_RemoveAll = SM_RemoveAll;
- chatApi.SM_GiveStatus = SM_GiveStatus;
- chatApi.SM_SetContactStatus = SM_SetContactStatus;
- chatApi.SM_TakeStatus = SM_TakeStatus;
- chatApi.SM_MoveUser = SM_MoveUser;
chatApi.SM_AddCommand = SM_AddCommand;
chatApi.SM_GetPrevCommand = SM_GetPrevCommand;
chatApi.SM_GetNextCommand = SM_GetNextCommand;
chatApi.SM_GetCount = SM_GetCount;
chatApi.SM_FindSessionByIndex = SM_FindSessionByIndex;
- chatApi.SM_GetUsers = SM_GetUsers;
chatApi.SM_GetUserFromIndex = SM_GetUserFromIndex;
chatApi.SM_InvalidateLogDirectories = SM_InvalidateLogDirectories;
diff --git a/src/mir_app/src/chat_svc.cpp b/src/mir_app/src/chat_svc.cpp index 2e675131e8..3734f29379 100644 --- a/src/mir_app/src/chat_svc.cpp +++ b/src/mir_app/src/chat_svc.cpp @@ -104,7 +104,7 @@ static int PreShutdown(WPARAM, LPARAM) if (g_Settings != NULL) {
chatApi.SM_BroadcastMessage(NULL, GC_CLOSEWINDOW, 0, 1, FALSE);
- chatApi.SM_RemoveAll();
+ SM_RemoveAll();
chatApi.MM_RemoveAll();
DeleteObject(chatApi.hListBkgBrush);
@@ -141,7 +141,7 @@ EXTERN_C MIR_APP_DLL(int) Chat_GetInfo(GC_INFO *gci) if (gci->Flags & GCF_HCONTACT) gci->hContact = si->hContact;
if (gci->Flags & GCF_TYPE) gci->iType = si->iType;
if (gci->Flags & GCF_COUNT) gci->iCount = si->nUsersInNicklist;
- if (gci->Flags & GCF_USERS) gci->pszUsers = chatApi.SM_GetUsers(si);
+ if (gci->Flags & GCF_USERS) gci->pszUsers = SM_GetUsers(si);
if (gci->Flags & GCF_ID) gci->pszID = si->ptszID;
if (gci->Flags & GCF_NAME) gci->pszName = si->ptszName;
return 0;
@@ -213,11 +213,20 @@ EXTERN_C MIR_APP_DLL(int) Chat_NewSession(const GCSESSION *gcw) return 0;
}
- // create a new session and set the defaults
- if ((si = chatApi.SM_AddSession(gcw->ptszID, gcw->pszModule)) == NULL)
- return GC_NEWSESSION_ERROR;
+ // create a new session
+ si = (SESSION_INFO*)mir_calloc(g_cbSession);
+ si->ptszID = mir_wstrdup(gcw->ptszID);
+ si->pszModule = mir_strdup(gcw->pszModule);
+ if (chatApi.wndList == NULL) // list is empty
+ chatApi.wndList = si;
+ else {
+ si->next = chatApi.wndList;
+ chatApi.wndList = si;
+ }
lck.unlock();
+
+ // set the defaults
si->pItemData = gcw->pItemData;
if (gcw->iType != GCW_SERVER)
si->wStatus = ID_STATUS_ONLINE;
@@ -307,15 +316,15 @@ static INT_PTR __stdcall stubRoomControl(void *param) break;
case SESSION_OFFLINE:
- chatApi.SM_SetOffline(p->wszId, p->szModule);
+ SM_SetOffline(p->wszId, p->szModule);
// fall through
case SESSION_ONLINE:
- chatApi.SM_SetStatus(p->wszId, p->szModule, p->command == SESSION_ONLINE ? ID_STATUS_ONLINE : ID_STATUS_OFFLINE);
+ SM_SetStatus(p->wszId, p->szModule, p->command == SESSION_ONLINE ? ID_STATUS_ONLINE : ID_STATUS_OFFLINE);
break;
case SESSION_TERMINATE:
- return chatApi.SM_RemoveSession(p->wszId, p->szModule, false);
+ return SM_RemoveSession(p->wszId, p->szModule, false);
case WINDOW_CLEARLOG:
if (SESSION_INFO *si = chatApi.SM_FindSession(p->wszId, p->szModule)) {
@@ -331,7 +340,7 @@ static INT_PTR __stdcall stubRoomControl(void *param) return GC_EVENT_ERROR;
}
- chatApi.SM_SendMessage(p->wszId, p->szModule, GC_CONTROL_MSG, p->command, 0);
+ SM_SendMessage(p->wszId, p->szModule, GC_CONTROL_MSG, p->command, 0);
return 0;
}
@@ -344,7 +353,7 @@ MIR_APP_DLL(int) Chat_Control(const char *szModule, const wchar_t *wszId, int iC MIR_APP_DLL(int) Chat_Terminate(const char *szModule, const wchar_t *wszId, bool bRemoveContact)
{
mir_cslock lck(csChat);
- return chatApi.SM_RemoveSession(wszId, szModule, bRemoveContact);
+ return SM_RemoveSession(wszId, szModule, bRemoveContact);
}
/////////////////////////////////////////////////////////////////////////////////////////
@@ -366,11 +375,18 @@ static INT_PTR __stdcall stubFlash(void *param) static void AddUser(GCEVENT *gce)
{
SESSION_INFO *si = chatApi.SM_FindSession(gce->pDest->ptszID, gce->pDest->pszModule);
- if (si == NULL) return;
+ if (si == NULL)
+ return;
WORD status = chatApi.TM_StringToWord(si->pStatuses, gce->ptszStatus);
- USERINFO *ui = chatApi.SM_AddUser(gce->pDest->ptszID, gce->pDest->pszModule, gce->ptszUID, gce->ptszNick, status);
- if (ui == NULL) return;
+
+ USERINFO *ui = chatApi.UM_AddUser(si->pStatuses, &si->pUsers, gce->ptszUID, gce->ptszNick, status);
+ if (ui == NULL)
+ return;
+
+ si->nUsersInNicklist++;
+ if (chatApi.OnAddUser)
+ chatApi.OnAddUser(si, ui);
ui->pszNick = mir_wstrdup(gce->ptszNick);
if (gce->bIsMe)
@@ -430,7 +446,7 @@ EXTERN_C MIR_APP_DLL(int) Chat_Event(GCEVENT *gce) // Do different things according to type of event
switch (gcd->iType) {
case GC_EVENT_SETCONTACTSTATUS:
- return chatApi.SM_SetContactStatus(gcd->ptszID, gcd->pszModule, gce->ptszUID, (WORD)gce->dwItemData);
+ return SM_SetContactStatus(gcd->ptszID, gcd->pszModule, gce->ptszUID, (WORD)gce->dwItemData);
case GC_EVENT_TOPIC:
if (SESSION_INFO *si = chatApi.SM_FindSession(gcd->ptszID, gcd->pszModule)) {
@@ -446,12 +462,12 @@ EXTERN_C MIR_APP_DLL(int) Chat_Event(GCEVENT *gce) break;
case GC_EVENT_ADDSTATUS:
- chatApi.SM_GiveStatus(gcd->ptszID, gcd->pszModule, gce->ptszUID, gce->ptszStatus);
+ SM_GiveStatus(gcd->ptszID, gcd->pszModule, gce->ptszUID, gce->ptszStatus);
bIsHighlighted = chatApi.IsHighlighted(NULL, gce);
break;
case GC_EVENT_REMOVESTATUS:
- chatApi.SM_TakeStatus(gcd->ptszID, gcd->pszModule, gce->ptszUID, gce->ptszStatus);
+ SM_TakeStatus(gcd->ptszID, gcd->pszModule, gce->ptszUID, gce->ptszStatus);
bIsHighlighted = chatApi.IsHighlighted(NULL, gce);
break;
@@ -464,7 +480,7 @@ EXTERN_C MIR_APP_DLL(int) Chat_Event(GCEVENT *gce) break;
case GC_EVENT_NICK:
- chatApi.SM_ChangeNick(gcd->ptszID, gcd->pszModule, gce);
+ SM_ChangeNick(gcd->ptszID, gcd->pszModule, gce);
bIsHighlighted = chatApi.IsHighlighted(NULL, gce);
break;
@@ -531,7 +547,7 @@ EXTERN_C MIR_APP_DLL(int) Chat_Event(GCEVENT *gce) }
if (bRemoveFlag)
- return chatApi.SM_RemoveUser(gcd->ptszID, gcd->pszModule, gce->ptszUID) == 0;
+ return SM_RemoveUser(gcd->ptszID, gcd->pszModule, gce->ptszUID) == 0;
return GC_EVENT_ERROR;
}
@@ -545,9 +561,19 @@ MIR_APP_DLL(int) Chat_AddGroup(const char *szModule, const wchar_t *wszId, const return GC_EVENT_ERROR;
mir_cslock lck(csChat);
- STATUSINFO *si = chatApi.SM_AddStatus(wszId, szModule, wszText);
- if (si && hIcon)
- si->hIcon = CopyIcon(hIcon);
+ SESSION_INFO *si = SM_FindSession(wszId, szModule);
+ if (si == NULL)
+ return NULL;
+
+ STATUSINFO *ti = chatApi.TM_AddStatus(&si->pStatuses, wszText, &si->iStatusCount);
+ if (ti) {
+ si->iStatusCount++;
+ if (hIcon)
+ ti->hIcon = CopyIcon(hIcon);
+ }
+
+ if (chatApi.OnAddStatus)
+ chatApi.OnAddStatus(si, ti);
return 0;
}
@@ -569,11 +595,21 @@ MIR_APP_DLL(int) Chat_ChangeSessionName(const char *szModule, const wchar_t *wsz MIR_APP_DLL(int) Chat_ChangeUserId(const char *szModule, const wchar_t *wszId, const wchar_t *wszOldId, const wchar_t *wszNewId)
{
- if (wszNewId == NULL)
+ if (szModule == NULL || wszNewId == NULL)
return GC_EVENT_ERROR;
mir_cslock lck(csChat);
- return !chatApi.SM_ChangeUID(wszId, szModule, wszOldId, wszNewId);
+ for (SESSION_INFO *si = chatApi.wndList; si != NULL; si = si->next) {
+ if ((wszId && mir_wstrcmpi(si->ptszID, wszId)) || mir_strcmpi(si->pszModule, szModule))
+ continue;
+
+ USERINFO *ui = chatApi.UM_FindUser(si->pUsers, wszOldId);
+ if (ui)
+ replaceStrW(ui->pszUID, wszNewId);
+ if (wszId)
+ break;
+ }
+ return 0;
}
MIR_APP_DLL(void*) Chat_GetUserInfo(const char *szModule, const wchar_t *wszId)
@@ -586,11 +622,20 @@ MIR_APP_DLL(void*) Chat_GetUserInfo(const char *szModule, const wchar_t *wszId) MIR_APP_DLL(int) Chat_SendUserMessage(const char *szModule, const wchar_t *wszId, const wchar_t *wszText)
{
- if (wszText == NULL)
+ if (wszText == NULL || szModule == NULL)
return GC_EVENT_ERROR;
mir_cslock lck(csChat);
- return !chatApi.SM_SendUserMessage(wszId, szModule, wszText);
+ for (SESSION_INFO *si = chatApi.wndList; si != NULL; si = si->next) {
+ if ((wszId && mir_wstrcmpi(si->ptszID, wszId)) || mir_strcmpi(si->pszModule, szModule))
+ continue;
+
+ if (si->iType == GCW_CHATROOM || si->iType == GCW_PRIVMESS)
+ DoEventHook(si->ptszID, si->pszModule, GC_USER_MESSAGE, NULL, wszText, 0);
+ if (wszId)
+ break;
+ }
+ return 0;
}
MIR_APP_DLL(int) Chat_SetStatusbarText(const char *szModule, const wchar_t *wszId, const wchar_t *wszText)
@@ -611,8 +656,21 @@ MIR_APP_DLL(int) Chat_SetStatusbarText(const char *szModule, const wchar_t *wszI MIR_APP_DLL(int) Chat_SetStatusEx(const char *szModule, const wchar_t *wszId, int flags, const wchar_t *wszText)
{
+ if (!szModule)
+ return GC_EVENT_ERROR;
+
mir_cslock lck(csChat);
- return !chatApi.SM_SetStatusEx(wszId, szModule, wszText, flags);
+ for (SESSION_INFO *si = chatApi.wndList; si != NULL; si = si->next) {
+ if ((wszId && mir_wstrcmpi(si->ptszID, wszId)) || mir_strcmpi(si->pszModule, szModule))
+ continue;
+
+ chatApi.UM_SetStatusEx(si->pUsers, wszText, flags);
+ if (si->hWnd)
+ RedrawWindow(GetDlgItem(si->hWnd, IDC_LIST), NULL, NULL, RDW_INVALIDATE);
+ if (wszId)
+ break;
+ }
+ return 0;
}
MIR_APP_DLL(int) Chat_SetUserInfo(const char *szModule, const wchar_t *wszId, void *pItemData)
|