diff options
author | George Hazan <george.hazan@gmail.com> | 2016-09-19 12:27:44 +0000 |
---|---|---|
committer | George Hazan <george.hazan@gmail.com> | 2016-09-19 12:27:44 +0000 |
commit | 0f37fbfbfe24563a6be07f9abd245374e66cb173 (patch) | |
tree | 28efbce80dc0f81698b56afa073115b0f8543a59 /src/mir_app | |
parent | 8fbb710f69be547c9a1fb45346bbd01db9d23bee (diff) |
chat code reordering
git-svn-id: http://svn.miranda-ng.org/main/trunk@17317 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'src/mir_app')
-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 |
4 files changed, 145 insertions, 214 deletions
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)
|