diff options
author | George Hazan <ghazan@miranda.im> | 2018-05-27 14:52:20 +0300 |
---|---|---|
committer | George Hazan <ghazan@miranda.im> | 2018-05-27 14:52:20 +0300 |
commit | 66ab99eb5b5c47a01e1cc6613af07426abbeb19b (patch) | |
tree | 6b3a84cf91b9e383f348355d702e4b38ff1be1e8 /src | |
parent | 38d70bf8d8d08cc687263b83ab598279d36a9c56 (diff) |
unused variable CHAT_MANAGER *pci removed and replaced with g_chatApi
Diffstat (limited to 'src')
-rw-r--r-- | src/core/stdmsg/src/chat_manager.cpp | 34 | ||||
-rw-r--r-- | src/core/stdmsg/src/chat_options.cpp | 6 | ||||
-rw-r--r-- | src/core/stdmsg/src/chat_window.cpp | 48 | ||||
-rw-r--r-- | src/core/stdmsg/src/cmdlist.cpp | 2 | ||||
-rw-r--r-- | src/core/stdmsg/src/globals.cpp | 2 | ||||
-rw-r--r-- | src/core/stdmsg/src/msgdialog.cpp | 4 | ||||
-rw-r--r-- | src/core/stdmsg/src/msgoptions.cpp | 2 | ||||
-rw-r--r-- | src/core/stdmsg/src/tabs.cpp | 6 | ||||
-rw-r--r-- | src/mir_app/src/chat_clist.cpp | 8 | ||||
-rw-r--r-- | src/mir_app/src/chat_log.cpp | 32 | ||||
-rw-r--r-- | src/mir_app/src/chat_manager.cpp | 218 | ||||
-rw-r--r-- | src/mir_app/src/chat_opts.cpp | 18 | ||||
-rw-r--r-- | src/mir_app/src/chat_svc.cpp | 146 | ||||
-rw-r--r-- | src/mir_app/src/chat_tools.cpp | 126 | ||||
-rw-r--r-- | src/mir_app/src/mir_app.def | 3 | ||||
-rw-r--r-- | src/mir_app/src/mir_app64.def | 3 | ||||
-rw-r--r-- | src/mir_app/src/miranda.h | 4 | ||||
-rw-r--r-- | src/mir_app/src/srmm_base.cpp | 24 | ||||
-rw-r--r-- | src/mir_app/src/srmm_util.cpp | 2 |
19 files changed, 342 insertions, 346 deletions
diff --git a/src/core/stdmsg/src/chat_manager.cpp b/src/core/stdmsg/src/chat_manager.cpp index 26b834617e..38d36978ad 100644 --- a/src/core/stdmsg/src/chat_manager.cpp +++ b/src/core/stdmsg/src/chat_manager.cpp @@ -27,12 +27,12 @@ pfnDoPopup oldDoPopup; SESSION_INFO* SM_GetPrevWindow(SESSION_INFO *si) { - int i = pci->arSessions.indexOf(si); + int i = g_chatApi.arSessions.indexOf(si); if (i == -1) return nullptr; for (i--; i >= 0; i--) { - SESSION_INFO *p = pci->arSessions[i]; + SESSION_INFO *p = g_chatApi.arSessions[i]; if (p->pDlg) return p; } @@ -42,11 +42,11 @@ SESSION_INFO* SM_GetPrevWindow(SESSION_INFO *si) SESSION_INFO* SM_GetNextWindow(SESSION_INFO *si) { - int i = pci->arSessions.indexOf(si); + int i = g_chatApi.arSessions.indexOf(si); if (i == -1) return nullptr; - for (auto &p : pci->arSessions) + for (auto &p : g_chatApi.arSessions) if (p->pDlg) return p; @@ -55,8 +55,6 @@ SESSION_INFO* SM_GetNextWindow(SESSION_INFO *si) ///////////////////////////////////////////////////////////////////////////////////////// -CHAT_MANAGER *pci; - HMENU g_hMenu = nullptr; BOOL SmileyAddInstalled = FALSE, PopupInstalled = FALSE; @@ -130,7 +128,7 @@ static void OnLoadSettings() DeleteObject(g_Settings.MessageAreaFont); LOGFONT lf; - pci->LoadMsgDlgFont(17, &lf, &g_Settings.MessageAreaColor); + g_chatApi.LoadMsgDlgFont(17, &lf, &g_Settings.MessageAreaColor); g_Settings.MessageAreaFont = CreateFontIndirect(&lf); g_Settings.iX = db_get_dw(0, CHAT_MODULE, "roomx", -1); @@ -234,20 +232,20 @@ void Load_ChatModule() RegisterFonts(); CHAT_MANAGER_INITDATA data = { &g_Settings, sizeof(MODULEINFO), sizeof(SESSION_INFO), LPGENW("Message sessions") L"/" LPGENW("Chat module"), FONTMODE_USE }; - pci = Chat_GetInterface(&data); + Chat_CustomizeApi(&data); - pci->OnCreateModule = OnCreateModule; - pci->OnDestroyModule = OnDestroyModule; - pci->OnReplaceSession = OnReplaceSession; + g_chatApi.OnCreateModule = OnCreateModule; + g_chatApi.OnDestroyModule = OnDestroyModule; + g_chatApi.OnReplaceSession = OnReplaceSession; - pci->OnLoadSettings = OnLoadSettings; - pci->OnFlashWindow = OnFlashWindow; - pci->OnFlashHighlight = OnFlashHighlight; - pci->ShowRoom = ShowRoom; + g_chatApi.OnLoadSettings = OnLoadSettings; + g_chatApi.OnFlashWindow = OnFlashWindow; + g_chatApi.OnFlashHighlight = OnFlashHighlight; + g_chatApi.ShowRoom = ShowRoom; - oldDoPopup = pci->DoPopup; pci->DoPopup = DoPopup; - oldDoTrayIcon = pci->DoTrayIcon; pci->DoTrayIcon = DoTrayIcon; - pci->ReloadSettings(); + oldDoPopup = g_chatApi.DoPopup; g_chatApi.DoPopup = DoPopup; + oldDoTrayIcon = g_chatApi.DoTrayIcon; g_chatApi.DoTrayIcon = DoTrayIcon; + g_chatApi.ReloadSettings(); g_hMenu = LoadMenu(g_plugin.getInst(), MAKEINTRESOURCE(IDR_MENU)); diff --git a/src/core/stdmsg/src/chat_options.cpp b/src/core/stdmsg/src/chat_options.cpp index 10b645db68..1b20b5aee1 100644 --- a/src/core/stdmsg/src/chat_options.cpp +++ b/src/core/stdmsg/src/chat_options.cpp @@ -375,7 +375,7 @@ public: if (PopupInstalled) SaveBranch(branch6, _countof(branch6)); - pci->ReloadSettings(); + g_chatApi.ReloadSettings(); Chat_UpdateOptions(); } @@ -510,7 +510,7 @@ public: db_set_ws(0, CHAT_MODULE, "LogDirectory", pszText); else db_unset(0, CHAT_MODULE, "LogDirectory"); - pci->SM_InvalidateLogDirectories(); + g_chatApi.SM_InvalidateLogDirectories(); pszText = rtrimw(edtLogTimestamp.GetText()); if (*pszText) @@ -553,7 +553,7 @@ public: else db_unset(0, CHAT_MODULE, "NicklistRowDist"); - pci->ReloadSettings(); + g_chatApi.ReloadSettings(); Chat_UpdateOptions(); } diff --git a/src/core/stdmsg/src/chat_window.cpp b/src/core/stdmsg/src/chat_window.cpp index 66be4aaba6..828961afc8 100644 --- a/src/core/stdmsg/src/chat_window.cpp +++ b/src/core/stdmsg/src/chat_window.cpp @@ -97,7 +97,7 @@ void CChatRoomDlg::OnActivate() g_Settings.iHeight = wp.rcNormalPosition.bottom - wp.rcNormalPosition.top; UpdateTitle(); - pci->SetActiveSession(m_si); + g_chatApi.SetActiveSession(m_si); UpdateStatusBar(); if (KillTimer(m_hwnd, TIMERID_FLASHWND)) @@ -142,14 +142,14 @@ void CChatRoomDlg::onClick_Ok(CCtrlButton *pButton) if (pszRtf == nullptr) return; - MODULEINFO *mi = pci->MM_FindModule(m_si->pszModule); + MODULEINFO *mi = g_chatApi.MM_FindModule(m_si->pszModule); if (mi == nullptr) return; - pci->SM_AddCommand(m_si->ptszID, m_si->pszModule, pszRtf); + g_chatApi.SM_AddCommand(m_si->ptszID, m_si->pszModule, pszRtf); CMStringW ptszText(ptrW(mir_utf8decodeW(pszRtf))); - pci->DoRtfToTags(ptszText, 0, nullptr); + g_chatApi.DoRtfToTags(ptszText, 0, nullptr); ptszText.Trim(); ptszText.Replace(L"%", L"%%"); @@ -202,7 +202,7 @@ int CChatRoomDlg::GetImageId() const if (m_si->wState & GC_EVENT_HIGHLIGHT) return 0; - MODULEINFO *mi = pci->MM_FindModule(m_si->pszModule); + MODULEINFO *mi = g_chatApi.MM_FindModule(m_si->pszModule); return (m_si->wStatus == ID_STATUS_ONLINE) ? mi->OnlineIconIndex : mi->OfflineIconIndex; } @@ -280,7 +280,7 @@ void CChatRoomDlg::UpdateOptions() m_btnNickList.SendMsg(BM_SETIMAGE, IMAGE_ICON, (LPARAM)LoadIconEx(m_bNicklistEnabled ? "nicklist" : "nicklist2", FALSE)); m_btnFilter.SendMsg(BM_SETIMAGE, IMAGE_ICON, (LPARAM)LoadIconEx(m_bFilterEnabled ? "filter" : "filter2", FALSE)); - MODULEINFO *mi = pci->MM_FindModule(m_si->pszModule); + MODULEINFO *mi = g_chatApi.MM_FindModule(m_si->pszModule); EnableWindow(m_btnBold.GetHwnd(), mi->bBold); EnableWindow(m_btnItalic.GetHwnd(), mi->bItalics); EnableWindow(m_btnUnderline.GetHwnd(), mi->bUnderline); @@ -291,7 +291,7 @@ void CChatRoomDlg::UpdateOptions() HICON hIcon = (m_si->wStatus == ID_STATUS_ONLINE) ? mi->hOnlineIcon : mi->hOfflineIcon; if (!hIcon) { - pci->MM_IconsChanged(); + g_chatApi.MM_IconsChanged(); hIcon = (m_si->wStatus == ID_STATUS_ONLINE) ? mi->hOnlineIcon : mi->hOfflineIcon; } @@ -329,7 +329,7 @@ void CChatRoomDlg::UpdateOptions() void CChatRoomDlg::UpdateStatusBar() { - MODULEINFO *mi = pci->MM_FindModule(m_si->pszModule); + MODULEINFO *mi = g_chatApi.MM_FindModule(m_si->pszModule); wchar_t *ptszDispName = mi->ptszModDispName; int x = 12; x += Chat_GetTextPixelSize(ptszDispName, (HFONT)SendMessage(m_pOwner->m_hwndStatus, WM_GETFONT, 0, 0), TRUE); @@ -340,7 +340,7 @@ void CChatRoomDlg::UpdateStatusBar() // stupid hack to make icons show. I dunno why this is needed currently HICON hIcon = m_si->wStatus == ID_STATUS_ONLINE ? mi->hOnlineIcon : mi->hOfflineIcon; if (!hIcon) { - pci->MM_IconsChanged(); + g_chatApi.MM_IconsChanged(); hIcon = m_si->wStatus == ID_STATUS_ONLINE ? mi->hOnlineIcon : mi->hOfflineIcon; } @@ -423,8 +423,8 @@ void CChatRoomDlg::StreamInEvents(LOGINFO *lin, bool bRedraw) //get the number of pixels per logical inch if (bRedraw) { HDC hdc = GetDC(nullptr); - pci->logPixelSY = GetDeviceCaps(hdc, LOGPIXELSY); - pci->logPixelSX = GetDeviceCaps(hdc, LOGPIXELSX); + g_chatApi.logPixelSY = GetDeviceCaps(hdc, LOGPIXELSY); + g_chatApi.logPixelSX = GetDeviceCaps(hdc, LOGPIXELSX); ReleaseDC(nullptr, hdc); m_log.SendMsg(WM_SETREDRAW, FALSE, 0); bFlag = true; @@ -686,7 +686,7 @@ LRESULT CChatRoomDlg::WndProc_Message(UINT msg, WPARAM wParam, LPARAM lParam) if (g_Settings.bTabsEnable) SendMessage(GetParent(GetParent(m_hwnd)), GC_SWITCHNEXTTAB, 0, 0); else - pci->ShowRoom(SM_GetNextWindow(m_si)); + g_chatApi.ShowRoom(SM_GetNextWindow(m_si)); return TRUE; } @@ -694,7 +694,7 @@ LRESULT CChatRoomDlg::WndProc_Message(UINT msg, WPARAM wParam, LPARAM lParam) if (g_Settings.bTabsEnable) SendMessage(GetParent(GetParent(m_hwnd)), GC_SWITCHPREVTAB, 0, 0); else - pci->ShowRoom(SM_GetPrevWindow(m_si)); + g_chatApi.ShowRoom(SM_GetPrevWindow(m_si)); return TRUE; } @@ -738,7 +738,7 @@ LRESULT CChatRoomDlg::WndProc_Message(UINT msg, WPARAM wParam, LPARAM lParam) wchar_t *pszSelName = (wchar_t *)mir_alloc(sizeof(wchar_t)*(end - start + 1)); mir_wstrncpy(pszSelName, pszText + start, end - start + 1); - wchar_t *pszName = pci->UM_FindUserAutoComplete(m_si->pUsers, szTabSave, pszSelName); + wchar_t *pszName = g_chatApi.UM_FindUserAutoComplete(m_si->pUsers, szTabSave, pszSelName); if (pszName == nullptr) { pszName = szTabSave; m_message.SendMsg(EM_SETSEL, start, end); @@ -802,7 +802,7 @@ LRESULT CChatRoomDlg::WndProc_Message(UINT msg, WPARAM wParam, LPARAM lParam) } if (wParam == VK_UP && isCtrl && !isAlt) { - char* lpPrevCmd = pci->SM_GetPrevCommand(m_si->ptszID, m_si->pszModule); + char* lpPrevCmd = g_chatApi.SM_GetPrevCommand(m_si->ptszID, m_si->pszModule); m_message.SendMsg(WM_SETREDRAW, FALSE, 0); @@ -827,7 +827,7 @@ LRESULT CChatRoomDlg::WndProc_Message(UINT msg, WPARAM wParam, LPARAM lParam) } if (wParam == VK_DOWN && isCtrl && !isAlt) { - char *lpPrevCmd = pci->SM_GetNextCommand(m_si->ptszID, m_si->pszModule); + char *lpPrevCmd = g_chatApi.SM_GetNextCommand(m_si->ptszID, m_si->pszModule); m_message.SendMsg(WM_SETREDRAW, FALSE, 0); if (lpPrevCmd) { @@ -1017,7 +1017,7 @@ INT_PTR CChatRoomDlg::DlgProc(UINT uMsg, WPARAM wParam, LPARAM lParam) m_btnNickList.Enable(true); m_btnFilter.Enable(true); if (m_si->iType == GCW_CHATROOM) - m_btnChannelMgr.Enable(pci->MM_FindModule(m_si->pszModule)->bChanMgr); + m_btnChannelMgr.Enable(g_chatApi.MM_FindModule(m_si->pszModule)->bChanMgr); } CSuper::DlgProc(uMsg, wParam, lParam); // call built-in resizer @@ -1031,7 +1031,7 @@ INT_PTR CChatRoomDlg::DlgProc(UINT uMsg, WPARAM wParam, LPARAM lParam) case WM_CTLCOLORLISTBOX: SetBkColor((HDC)wParam, g_Settings.crUserListBGColor); - return (INT_PTR)pci->hListBkgBrush; + return (INT_PTR)g_chatApi.hListBkgBrush; case WM_MEASUREITEM: { @@ -1060,7 +1060,7 @@ INT_PTR CChatRoomDlg::DlgProc(UINT uMsg, WPARAM wParam, LPARAM lParam) if (dis->CtlID == IDC_SRMM_NICKLIST) { int index = dis->itemID; - USERINFO *ui = pci->SM_GetUserFromIndex(m_si->ptszID, m_si->pszModule, index); + USERINFO *ui = g_chatApi.SM_GetUserFromIndex(m_si->ptszID, m_si->pszModule, index); if (ui) { int x_offset = 2; @@ -1074,16 +1074,16 @@ INT_PTR CChatRoomDlg::DlgProc(UINT uMsg, WPARAM wParam, LPARAM lParam) SetBkMode(dis->hDC, TRANSPARENT); if (dis->itemAction == ODA_FOCUS && dis->itemState & ODS_SELECTED) - FillRect(dis->hDC, &dis->rcItem, pci->hListSelectedBkgBrush); + FillRect(dis->hDC, &dis->rcItem, g_chatApi.hListSelectedBkgBrush); else //if (dis->itemState & ODS_INACTIVE) - FillRect(dis->hDC, &dis->rcItem, pci->hListBkgBrush); + FillRect(dis->hDC, &dis->rcItem, g_chatApi.hListBkgBrush); if (g_Settings.bShowContactStatus && g_Settings.bContactStatusFirst && ui->ContactStatus) { HICON hIcon = Skin_LoadProtoIcon(m_si->pszModule, ui->ContactStatus); DrawIconEx(dis->hDC, x_offset, dis->rcItem.top + offset - 3, hIcon, 16, 16, 0, nullptr, DI_NORMAL); x_offset += 18; } - DrawIconEx(dis->hDC, x_offset, dis->rcItem.top + offset, pci->SM_GetStatusIcon(m_si, ui), 10, 10, 0, nullptr, DI_NORMAL); + DrawIconEx(dis->hDC, x_offset, dis->rcItem.top + offset, g_chatApi.SM_GetStatusIcon(m_si, ui), 10, 10, 0, nullptr, DI_NORMAL); x_offset += 12; if (g_Settings.bShowContactStatus && !g_Settings.bContactStatusFirst && ui->ContactStatus) { HICON hIcon = Skin_LoadProtoIcon(m_si->pszModule, ui->ContactStatus); @@ -1131,13 +1131,13 @@ INT_PTR CChatRoomDlg::DlgProc(UINT uMsg, WPARAM wParam, LPARAM lParam) GetCursorPos(&p); ScreenToClient(m_nickList.GetHwnd(), &p); int item = LOWORD(m_nickList.SendMsg(LB_ITEMFROMPOINT, 0, MAKELPARAM(p.x, p.y))); - USERINFO *ui = pci->SM_GetUserFromIndex(parentdat->ptszID, parentdat->pszModule, item); + USERINFO *ui = g_chatApi.SM_GetUserFromIndex(parentdat->ptszID, parentdat->pszModule, item); if (ui != nullptr) { static wchar_t ptszBuf[1024]; mir_snwprintf(ptszBuf, L"%s: %s\r\n%s: %s\r\n%s: %s", TranslateT("Nickname"), ui->pszNick, TranslateT("Unique ID"), ui->pszUID, - TranslateT("Status"), pci->TM_WordToString(parentdat->pStatuses, ui->Status)); + TranslateT("Status"), g_chatApi.TM_WordToString(parentdat->pStatuses, ui->Status)); lpttd->lpszText = ptszBuf; } } diff --git a/src/core/stdmsg/src/cmdlist.cpp b/src/core/stdmsg/src/cmdlist.cpp index 726eb7a9dc..8532ae8249 100644 --- a/src/core/stdmsg/src/cmdlist.cpp +++ b/src/core/stdmsg/src/cmdlist.cpp @@ -97,7 +97,7 @@ void msgQueue_processack(MCONTACT hContact, int id, BOOL success, const char *sz dbei.pBlob = (PBYTE)p->szMsg;
MessageWindowEvent evt = { id, hContact, &dbei };
- NotifyEventHooks(pci->hevPreCreate, 0, (LPARAM)&evt);
+ NotifyEventHooks(g_chatApi.hevPreCreate, 0, (LPARAM)&evt);
p->szMsg = (char*)dbei.pBlob;
diff --git a/src/core/stdmsg/src/globals.cpp b/src/core/stdmsg/src/globals.cpp index 08a91a5d3b..968e845c0d 100644 --- a/src/core/stdmsg/src/globals.cpp +++ b/src/core/stdmsg/src/globals.cpp @@ -42,7 +42,7 @@ static int IconsChanged(WPARAM, LPARAM) static int OnShutdown(WPARAM, LPARAM)
{
- for (auto &si : pci->arSessions)
+ for (auto &si : g_chatApi.arSessions)
if (si->pDlg)
si->pDlg->Close();
diff --git a/src/core/stdmsg/src/msgdialog.cpp b/src/core/stdmsg/src/msgdialog.cpp index a0828b0c32..e8e95ecff8 100644 --- a/src/core/stdmsg/src/msgdialog.cpp +++ b/src/core/stdmsg/src/msgdialog.cpp @@ -891,7 +891,7 @@ LRESULT CSrmmWindow::WndProc_Message(UINT msg, WPARAM wParam, LPARAM lParam) }
// First notification
- NotifyEventHooks(pci->hevWinPopup, 0, (LPARAM)&mwpd);
+ NotifyEventHooks(g_chatApi.hevWinPopup, 0, (LPARAM)&mwpd);
// Someone added items?
if (GetMenuItemCount(mwpd.hMenu) > 0) {
@@ -902,7 +902,7 @@ LRESULT CSrmmWindow::WndProc_Message(UINT msg, WPARAM wParam, LPARAM lParam) // Second notification
mwpd.uType = MSG_WINDOWPOPUP_SELECTED;
- NotifyEventHooks(pci->hevWinPopup, 0, (LPARAM)&mwpd);
+ NotifyEventHooks(g_chatApi.hevWinPopup, 0, (LPARAM)&mwpd);
switch (mwpd.selection) {
case IDM_UNDO:
diff --git a/src/core/stdmsg/src/msgoptions.cpp b/src/core/stdmsg/src/msgoptions.cpp index 20622ddd70..c7aee9c376 100644 --- a/src/core/stdmsg/src/msgoptions.cpp +++ b/src/core/stdmsg/src/msgoptions.cpp @@ -556,7 +556,7 @@ public: db_set_b(0, CHAT_MODULE, "TabCloseOnDblClick", m_chkTabsClose.GetState());
db_set_b(0, CHAT_MODULE, "TabRestore", m_chkTabsRestore.GetState());
- pci->ReloadSettings();
+ g_chatApi.ReloadSettings();
if (bOldValue != db_get_b(0, CHAT_MODULE, "Tabs", 1)) {
if (g_pTabDialog != nullptr)
diff --git a/src/core/stdmsg/src/tabs.cpp b/src/core/stdmsg/src/tabs.cpp index 8aa3608d1b..1b4f8867be 100644 --- a/src/core/stdmsg/src/tabs.cpp +++ b/src/core/stdmsg/src/tabs.cpp @@ -81,7 +81,7 @@ static LRESULT CALLBACK TabSubclassProc(HWND hwnd, UINT msg, WPARAM wParam, LPAR SESSION_INFO *si = pDlg->getChat(); if (si != nullptr) { bool bOnline = db_get_w(si->hContact, si->pszModule, "Status", ID_STATUS_OFFLINE) == ID_STATUS_ONLINE; - MODULEINFO *mi = pci->MM_FindModule(si->pszModule); + MODULEINFO *mi = g_chatApi.MM_FindModule(si->pszModule); bDragging = true; iBeginIndex = idx; ImageList_BeginDrag(Clist_GetImageList(), bOnline ? mi->OnlineIconIndex : mi->OfflineIconIndex, 8, 8); @@ -196,7 +196,7 @@ void CTabbedWindow::OnInitDialog() // restore previous tabs if (g_Settings.bTabRestore) { for (auto &p : arSavedTabs) { - SESSION_INFO *si = pci->SM_FindSession(p->m_id, p->m_szModule); + SESSION_INFO *si = g_chatApi.SM_FindSession(p->m_id, p->m_szModule); if (si) AddPage(si); } @@ -414,7 +414,7 @@ void CTabbedWindow::TabClicked() FixTabIcons(pDlg); if (!s->pDlg) { - pci->ShowRoom(s); + g_chatApi.ShowRoom(s); SendMessage(m_hwnd, WM_MOUSEACTIVATE, 0, 0); } } diff --git a/src/mir_app/src/chat_clist.cpp b/src/mir_app/src/chat_clist.cpp index 8fac7d27f1..339db5cca4 100644 --- a/src/mir_app/src/chat_clist.cpp +++ b/src/mir_app/src/chat_clist.cpp @@ -40,7 +40,7 @@ MCONTACT AddRoom(const char *pszModule, const wchar_t *pszRoom, const wchar_t *p }
}
- MCONTACT hContact = chatApi.FindRoom(pszModule, pszRoom);
+ MCONTACT hContact = g_chatApi.FindRoom(pszModule, pszRoom);
if (hContact) { //contact exist, make sure it is in the right group
if (pszGroup[0]) {
ptrW grpName(db_get_wsa(hContact, "CList", "Group"));
@@ -85,7 +85,7 @@ BOOL SetAllOffline(BOOL, const char *pszModule) {
for (auto &hContact : Contacts(pszModule)) {
char *szProto = GetContactProto(hContact);
- if (!chatApi.MM_FindModule(szProto))
+ if (!g_chatApi.MM_FindModule(szProto))
continue;
int i = db_get_b(hContact, szProto, "ChatRoom", 0);
if (i != 0) {
@@ -103,7 +103,7 @@ int RoomDoubleclicked(WPARAM hContact, LPARAM) return 0;
char *szProto = GetContactProto(hContact);
- if (chatApi.MM_FindModule(szProto) == nullptr)
+ if (g_chatApi.MM_FindModule(szProto) == nullptr)
return 0;
if (db_get_b(hContact, szProto, "ChatRoom", 0) == 0)
return 0;
@@ -118,7 +118,7 @@ int RoomDoubleclicked(WPARAM hContact, LPARAM) si->pDlg->CloseTab();
return 1;
}
- chatApi.ShowRoom(si);
+ g_chatApi.ShowRoom(si);
}
return 1;
}
diff --git a/src/mir_app/src/chat_log.cpp b/src/mir_app/src/chat_log.cpp index 95d40df71c..46b9d5be4a 100644 --- a/src/mir_app/src/chat_log.cpp +++ b/src/mir_app/src/chat_log.cpp @@ -294,7 +294,7 @@ wchar_t* MakeTimeStamp(wchar_t *pszStamp, time_t time) char* Log_CreateRTF(LOGSTREAMDATA *streamData)
{
SESSION_INFO *si = streamData->si;
- MODULEINFO *mi = chatApi.MM_FindModule(si->pszModule);
+ MODULEINFO *mi = g_chatApi.MM_FindModule(si->pszModule);
// guesstimate amount of memory for the RTF
CMStringA buf;
@@ -324,16 +324,16 @@ char* Log_CreateRTF(LOGSTREAMDATA *streamData) }
if (g_Settings->bTimeStampEventColour) {
- LOGFONT &lf = chatApi.aFonts[0].lf;
+ LOGFONT &lf = g_chatApi.aFonts[0].lf;
// colored timestamps
if (lin->ptszNick && lin->iType == GC_EVENT_MESSAGE) {
int iii = lin->bIsHighlighted ? 16 : (lin->bIsMe ? 2 : 1);
- buf.AppendFormat("\\f0\\cf%u\\ul0\\highlight0\\b%d\\i%d\\fs%u", iii + 1, lf.lfWeight >= FW_BOLD ? 1 : 0, lf.lfItalic, 2 * abs(lf.lfHeight) * 74 / chatApi.logPixelSY);
+ buf.AppendFormat("\\f0\\cf%u\\ul0\\highlight0\\b%d\\i%d\\fs%u", iii + 1, lf.lfWeight >= FW_BOLD ? 1 : 0, lf.lfItalic, 2 * abs(lf.lfHeight) * 74 / g_chatApi.logPixelSY);
}
else {
int iii = lin->bIsHighlighted ? 16 : EventToIndex(lin);
- buf.AppendFormat("\\f0\\cf%u\\ul0\\highlight0\\b%d\\i%d\\fs%u", iii + 1, lf.lfWeight >= FW_BOLD ? 1 : 0, lf.lfItalic, 2 * abs(lf.lfHeight) * 74 / chatApi.logPixelSY);
+ buf.AppendFormat("\\f0\\cf%u\\ul0\\highlight0\\b%d\\i%d\\fs%u", iii + 1, lf.lfWeight >= FW_BOLD ? 1 : 0, lf.lfItalic, 2 * abs(lf.lfHeight) * 74 / g_chatApi.logPixelSY);
}
}
else buf.AppendFormat("%s ", Log_SetStyle(0));
@@ -389,8 +389,8 @@ char* Log_CreateRtfHeader() // get the number of pixels per logical inch
HDC hdc = GetDC(nullptr);
- chatApi.logPixelSY = GetDeviceCaps(hdc, LOGPIXELSY);
- chatApi.logPixelSX = GetDeviceCaps(hdc, LOGPIXELSX);
+ g_chatApi.logPixelSY = GetDeviceCaps(hdc, LOGPIXELSY);
+ g_chatApi.logPixelSX = GetDeviceCaps(hdc, LOGPIXELSX);
ReleaseDC(nullptr, hdc);
// ### RTF HEADER
@@ -398,13 +398,13 @@ char* Log_CreateRtfHeader() // font table
buf.Append("{\\rtf1\\ansi\\deff0{\\fonttbl");
for (int i = 0; i < OPTIONS_FONTCOUNT; i++)
- buf.AppendFormat("{\\f%u\\fnil\\fcharset%u%S;}", i, chatApi.aFonts[i].lf.lfCharSet, chatApi.aFonts[i].lf.lfFaceName);
+ buf.AppendFormat("{\\f%u\\fnil\\fcharset%u%S;}", i, g_chatApi.aFonts[i].lf.lfCharSet, g_chatApi.aFonts[i].lf.lfFaceName);
// colour table
buf.Append("}{\\colortbl ;");
for (int i = 0; i < OPTIONS_FONTCOUNT; i++)
- buf.AppendFormat("\\red%u\\green%u\\blue%u;", GetRValue(chatApi.aFonts[i].color), GetGValue(chatApi.aFonts[i].color), GetBValue(chatApi.aFonts[i].color));
+ buf.AppendFormat("\\red%u\\green%u\\blue%u;", GetRValue(g_chatApi.aFonts[i].color), GetGValue(g_chatApi.aFonts[i].color), GetBValue(g_chatApi.aFonts[i].color));
// new paragraph
buf.Append("}\\pard");
@@ -413,11 +413,11 @@ char* Log_CreateRtfHeader() int iIndent = 0;
if (g_Settings->dwIconFlags) {
- iIndent += (14 * 1440) / chatApi.logPixelSX;
+ iIndent += (14 * 1440) / g_chatApi.logPixelSX;
buf.AppendFormat("\\tx%u", iIndent);
}
if (g_Settings->bShowTime) {
- int iSize = (g_Settings->LogTextIndent * 1440) / chatApi.logPixelSX;
+ int iSize = (g_Settings->LogTextIndent * 1440) / g_chatApi.logPixelSX;
buf.AppendFormat("\\tx%u", iIndent + iSize);
if (g_Settings->bLogIndentEnabled)
iIndent += iSize;
@@ -455,7 +455,7 @@ void LoadMsgLogBitmaps(void) pLogIconBmpBits[i] = (char*)mir_alloc(size);
size_t rtfHeaderSize = mir_snprintf((char *)pLogIconBmpBits[i], size, "{\\pict\\dibitmap0\\wbmbitspixel%u\\wbmplanes1\\wbmwidthbytes%u\\picw%u\\pich%u ", bih.biBitCount, widthBytes, bih.biWidth, bih.biHeight);
- HICON hIcon = chatApi.hIcons[i];
+ HICON hIcon = g_chatApi.hIcons[i];
HBITMAP hoBmp = (HBITMAP)SelectObject(hdcMem, hBmp);
FillRect(hdcMem, &rc, hBkgBrush);
DrawIconEx(hdcMem, 0, 0, hIcon, bih.biWidth, bih.biHeight, 0, nullptr, DI_NORMAL);
@@ -473,18 +473,18 @@ void LoadMsgLogBitmaps(void) ReleaseDC(nullptr, hdc);
DeleteObject(hBkgBrush);
- if (chatApi.logPixelSY == 0) {
+ if (g_chatApi.logPixelSY == 0) {
hdc = GetDC(nullptr);
- chatApi.logPixelSY = GetDeviceCaps(hdc, LOGPIXELSY);
- chatApi.logPixelSX = GetDeviceCaps(hdc, LOGPIXELSX);
+ g_chatApi.logPixelSY = GetDeviceCaps(hdc, LOGPIXELSY);
+ g_chatApi.logPixelSX = GetDeviceCaps(hdc, LOGPIXELSX);
ReleaseDC(nullptr, hdc);
}
for (int i = 0; i < OPTIONS_FONTCOUNT; i++) {
- LOGFONT &F = chatApi.aFonts[i].lf;
+ LOGFONT &F = g_chatApi.aFonts[i].lf;
mir_snprintf(CHAT_rtfFontsGlobal[i], RTFCACHELINESIZE,
"\\f%u\\cf%u\\ul0\\highlight0\\b%d\\i%d\\ul%d\\fs%u", i, i + 1,
- F.lfWeight >= FW_BOLD ? 1 : 0, F.lfItalic, F.lfUnderline, 2 * abs(F.lfHeight) * 74 / chatApi.logPixelSY);
+ F.lfWeight >= FW_BOLD ? 1 : 0, F.lfItalic, F.lfUnderline, 2 * abs(F.lfHeight) * 74 / g_chatApi.logPixelSY);
}
}
diff --git a/src/mir_app/src/chat_manager.cpp b/src/mir_app/src/chat_manager.cpp index 10bdf56d93..345331ebb0 100644 --- a/src/mir_app/src/chat_manager.cpp +++ b/src/mir_app/src/chat_manager.cpp @@ -49,21 +49,21 @@ CHAT_MANAGER::CHAT_MANAGER() : arSessions(g_arSessions)
{}
-CHAT_MANAGER chatApi;
+MIR_APP_EXPORT CHAT_MANAGER g_chatApi;
/////////////////////////////////////////////////////////////////////////////////////////
static void SetActiveSession(SESSION_INFO *si)
{
if (si) {
- replaceStrW(chatApi.szActiveWndID, si->ptszID);
- replaceStr(chatApi.szActiveWndModule, si->pszModule);
+ replaceStrW(g_chatApi.szActiveWndID, si->ptszID);
+ replaceStr(g_chatApi.szActiveWndModule, si->pszModule);
}
}
static SESSION_INFO* GetActiveSession(void)
{
- SESSION_INFO *si = SM_FindSession(chatApi.szActiveWndID, chatApi.szActiveWndModule);
+ SESSION_INFO *si = SM_FindSession(g_chatApi.szActiveWndID, g_chatApi.szActiveWndModule);
if (si)
return si;
@@ -92,15 +92,15 @@ static void SM_FreeSession(SESSION_INFO *si, bool bRemoveContact = false) // contact may have been deleted here already, since function may be called after deleting
// contact so the handle may be invalid, therefore db_get_b shall return 0
if (si->hContact && db_get_b(si->hContact, si->pszModule, "ChatRoom", 0) != 0) {
- chatApi.SetOffline(si->hContact, (si->iType == GCW_CHATROOM || si->iType == GCW_PRIVMESS) ? TRUE : FALSE);
+ g_chatApi.SetOffline(si->hContact, (si->iType == GCW_CHATROOM || si->iType == GCW_PRIVMESS) ? TRUE : FALSE);
db_set_s(si->hContact, si->pszModule, "Topic", "");
db_set_s(si->hContact, si->pszModule, "StatusBar", "");
db_unset(si->hContact, "CList", "StatusMsg");
}
- chatApi.UM_RemoveAll(&si->pUsers);
- chatApi.TM_RemoveAll(&si->pStatuses);
- chatApi.LM_RemoveAll(&si->pLog, &si->pLogEnd);
+ g_chatApi.UM_RemoveAll(&si->pUsers);
+ g_chatApi.TM_RemoveAll(&si->pStatuses);
+ g_chatApi.LM_RemoveAll(&si->pLog, &si->pLogEnd);
si->iStatusCount = 0;
si->nUsersInNicklist = 0;
@@ -172,13 +172,13 @@ BOOL SM_SetOffline(const char *pszModule, SESSION_INFO *si) return TRUE;
}
- chatApi.UM_RemoveAll(&si->pUsers);
+ g_chatApi.UM_RemoveAll(&si->pUsers);
si->pMe = nullptr;
si->nUsersInNicklist = 0;
if (si->iType != GCW_SERVER)
si->bInitDone = false;
- if (chatApi.OnOfflineSession)
- chatApi.OnOfflineSession(si);
+ if (g_chatApi.OnOfflineSession)
+ g_chatApi.OnOfflineSession(si);
return TRUE;
}
@@ -187,11 +187,11 @@ static HICON SM_GetStatusIcon(SESSION_INFO *si, USERINFO *ui) if (!ui || !si)
return nullptr;
- STATUSINFO *ti = chatApi.TM_FindStatus(si->pStatuses, chatApi.TM_WordToString(si->pStatuses, ui->Status));
+ STATUSINFO *ti = g_chatApi.TM_FindStatus(si->pStatuses, g_chatApi.TM_WordToString(si->pStatuses, ui->Status));
if (ti != nullptr)
- return chatApi.hIcons[ICON_STATUS0 + ti->iIconIndex];
+ return g_chatApi.hIcons[ICON_STATUS0 + ti->iIconIndex];
- return chatApi.hIcons[ICON_STATUS0];
+ return g_chatApi.hIcons[ICON_STATUS0];
}
BOOL SM_AddEvent(const wchar_t *pszID, const char *pszModule, GCEVENT *gce, bool bIsHighlighted)
@@ -200,7 +200,7 @@ BOOL SM_AddEvent(const wchar_t *pszID, const char *pszModule, GCEVENT *gce, bool if (si == nullptr)
return TRUE;
- LOGINFO *li = chatApi.LM_AddEvent(&si->pLog, &si->pLogEnd);
+ LOGINFO *li = g_chatApi.LM_AddEvent(&si->pLog, &si->pLogEnd);
si->iEventCount++;
li->iType = gce->iType;
@@ -214,7 +214,7 @@ BOOL SM_AddEvent(const wchar_t *pszID, const char *pszModule, GCEVENT *gce, bool li->bIsHighlighted = bIsHighlighted;
if (g_Settings->iEventLimit > 0 && si->iEventCount > g_Settings->iEventLimit + 20) {
- chatApi.LM_TrimLog(&si->pLog, &si->pLogEnd, si->iEventCount - g_Settings->iEventLimit);
+ g_chatApi.LM_TrimLog(&si->pLog, &si->pLogEnd, si->iEventCount - g_Settings->iEventLimit);
si->bTrimmed = true;
si->iEventCount = g_Settings->iEventLimit;
return FALSE;
@@ -231,7 +231,7 @@ BOOL SM_MoveUser(const wchar_t *pszID, const char *pszModule, const wchar_t *psz if (si == nullptr)
return FALSE;
- chatApi.UM_SortUser(&si->pUsers, pszUID);
+ g_chatApi.UM_SortUser(&si->pUsers, pszUID);
return TRUE;
}
@@ -244,15 +244,15 @@ BOOL SM_RemoveUser(const wchar_t *pszID, const char *pszModule, const wchar_t *p if ((pszID && mir_wstrcmpi(si->ptszID, pszID)) || mir_strcmpi(si->pszModule, pszModule))
continue;
- USERINFO *ui = chatApi.UM_FindUser(si->pUsers, pszUID);
+ USERINFO *ui = g_chatApi.UM_FindUser(si->pUsers, pszUID);
if (ui) {
si->nUsersInNicklist--;
- if (chatApi.OnRemoveUser)
- chatApi.OnRemoveUser(si, ui);
+ if (g_chatApi.OnRemoveUser)
+ g_chatApi.OnRemoveUser(si, ui);
if (si->pMe == ui)
si->pMe = nullptr;
- chatApi.UM_RemoveUser(&si->pUsers, pszUID);
+ g_chatApi.UM_RemoveUser(&si->pUsers, pszUID);
if (si->pDlg)
si->pDlg->UpdateNickList();
@@ -268,7 +268,7 @@ BOOL SM_RemoveUser(const wchar_t *pszID, const char *pszModule, const wchar_t *p static USERINFO* SM_GetUserFromIndex(const wchar_t *pszID, const char *pszModule, int index)
{
SESSION_INFO *si = SM_FindSession(pszID, pszModule);
- return (si == nullptr) ? nullptr : chatApi.UM_FindUserFromIndex(si->pUsers, index);
+ return (si == nullptr) ? nullptr : g_chatApi.UM_FindUserFromIndex(si->pUsers, index);
}
BOOL SM_GiveStatus(const wchar_t *pszID, const char *pszModule, const wchar_t *pszUID, const wchar_t *pszStatus)
@@ -277,7 +277,7 @@ BOOL SM_GiveStatus(const wchar_t *pszID, const char *pszModule, const wchar_t *p if (si == nullptr)
return FALSE;
- USERINFO *ui = chatApi.UM_GiveStatus(si->pUsers, pszUID, TM_StringToWord(si->pStatuses, pszStatus));
+ USERINFO *ui = g_chatApi.UM_GiveStatus(si->pUsers, pszUID, TM_StringToWord(si->pStatuses, pszStatus));
if (ui) {
SM_MoveUser(si->ptszID, si->pszModule, ui->pszUID);
if (si->pDlg)
@@ -292,7 +292,7 @@ BOOL SM_SetContactStatus(const wchar_t *pszID, const char *pszModule, const wcha if (si == nullptr)
return FALSE;
- USERINFO *ui = chatApi.UM_SetContactStatus(si->pUsers, pszUID, wStatus);
+ USERINFO *ui = g_chatApi.UM_SetContactStatus(si->pUsers, pszUID, wStatus);
if (ui) {
SM_MoveUser(si->ptszID, si->pszModule, ui->pszUID);
if (si->pDlg)
@@ -307,7 +307,7 @@ BOOL SM_TakeStatus(const wchar_t *pszID, const char *pszModule, const wchar_t *p if (si == nullptr)
return FALSE;
- USERINFO *ui = chatApi.UM_TakeStatus(si->pUsers, pszUID, TM_StringToWord(si->pStatuses, pszStatus));
+ USERINFO *ui = g_chatApi.UM_TakeStatus(si->pUsers, pszUID, TM_StringToWord(si->pStatuses, pszStatus));
if (ui) {
SM_MoveUser(si->ptszID, si->pszModule, ui->pszUID);
if (si->pDlg)
@@ -353,8 +353,8 @@ BOOL SM_SetStatus(const char *pszModule, SESSION_INFO *si, int wStatus) db_set_w(si->hContact, si->pszModule, "Status", (WORD)wStatus);
}
- if (chatApi.OnSetStatus)
- chatApi.OnSetStatus(si, wStatus);
+ if (g_chatApi.OnSetStatus)
+ g_chatApi.OnSetStatus(si, wStatus);
return TRUE;
}
@@ -366,14 +366,14 @@ BOOL SM_ChangeNick(const wchar_t *pszID, const char *pszModule, GCEVENT *gce) for (auto &si : g_arSessions) {
if ((!pszID || !mir_wstrcmpi(si->ptszID, pszID)) && !mir_strcmpi(si->pszModule, pszModule)) {
- USERINFO *ui = chatApi.UM_FindUser(si->pUsers, gce->ptszUID);
+ USERINFO *ui = g_chatApi.UM_FindUser(si->pUsers, gce->ptszUID);
if (ui) {
replaceStrW(ui->pszNick, gce->ptszText);
SM_MoveUser(si->ptszID, si->pszModule, ui->pszUID);
if (si->pDlg)
si->pDlg->UpdateNickList();
- if (chatApi.OnChangeNick)
- chatApi.OnChangeNick(si);
+ if (g_chatApi.OnChangeNick)
+ g_chatApi.OnChangeNick(si);
}
if (pszID)
@@ -535,13 +535,13 @@ static MODULEINFO* MM_AddModule(const char *pszModule) if (pszModule == nullptr)
return nullptr;
- if (chatApi.MM_FindModule(pszModule))
+ if (g_chatApi.MM_FindModule(pszModule))
return nullptr;
MODULEINFO *node = (MODULEINFO*)mir_calloc(g_cbModuleInfo);
replaceStr(node->pszModule, pszModule);
- if (chatApi.OnCreateModule)
- chatApi.OnCreateModule(node);
+ if (g_chatApi.OnCreateModule)
+ g_chatApi.OnCreateModule(node);
g_arModules.insert(node);
return node;
@@ -552,14 +552,14 @@ static void MM_IconsChanged() LoadChatIcons();
for (auto &mi : g_arModules)
- if (chatApi.OnCreateModule) // recreate icons
- chatApi.OnCreateModule(mi);
+ if (g_chatApi.OnCreateModule) // recreate icons
+ g_chatApi.OnCreateModule(mi);
}
static void MM_FontsChanged()
{
for (auto &mi : g_arModules)
- mi->pszHeader = chatApi.Log_CreateRtfHeader();
+ mi->pszHeader = g_chatApi.Log_CreateRtfHeader();
}
static MODULEINFO* MM_FindModule(const char *pszModule)
@@ -573,8 +573,8 @@ static MODULEINFO* MM_FindModule(const char *pszModule) static BOOL MM_RemoveAll(void)
{
for (auto &mi : g_arModules) {
- if (chatApi.OnDestroyModule)
- chatApi.OnDestroyModule(mi);
+ if (g_chatApi.OnDestroyModule)
+ g_chatApi.OnDestroyModule(mi);
mir_free(mi->pszModule);
mir_free(mi->ptszModDispName);
@@ -593,7 +593,7 @@ STATUSINFO* TM_AddStatus(STATUSINFO **ppStatusList, const wchar_t *pszStatus, in if (!ppStatusList || !pszStatus)
return nullptr;
- if (!chatApi.TM_FindStatus(*ppStatusList, pszStatus)) {
+ if (!g_chatApi.TM_FindStatus(*ppStatusList, pszStatus)) {
STATUSINFO *node = (STATUSINFO*)mir_calloc(sizeof(STATUSINFO));
replaceStrW(node->pszGroup, pszStatus);
node->iIconIndex = *iCount;
@@ -719,7 +719,7 @@ static USERINFO* UM_SortUser(USERINFO **ppUserList, const wchar_t *pszUID) pLast = nullptr;
- while (ui && chatApi.UM_CompareItem(ui, node->pszNick, node->Status) <= 0) {
+ while (ui && g_chatApi.UM_CompareItem(ui, node->pszNick, node->Status) <= 0) {
pLast = ui;
ui = ui->next;
}
@@ -748,7 +748,7 @@ USERINFO* UM_AddUser(STATUSINFO *pStatusList, USERINFO **ppUserList, const wchar return nullptr;
USERINFO *ui = *ppUserList, *pLast = nullptr;
- while (ui && chatApi.UM_CompareItem(ui, pszNick, wStatus) <= 0) {
+ while (ui && g_chatApi.UM_CompareItem(ui, pszNick, wStatus) <= 0) {
pLast = ui;
ui = ui->next;
}
@@ -971,13 +971,13 @@ static BOOL LM_RemoveAll(LOGINFO **ppLogListStart, LOGINFO **ppLogListEnd) return TRUE;
}
-MIR_APP_DLL(CHAT_MANAGER*) Chat_GetInterface(CHAT_MANAGER_INITDATA *pInit)
+MIR_APP_DLL(CHAT_MANAGER*) Chat_CustomizeApi(const CHAT_MANAGER_INITDATA *pInit)
{
if (pInit == nullptr)
- return &chatApi;
+ return &g_chatApi;
// wipe out old junk
- memset(PBYTE(&chatApi) + offsetof(CHAT_MANAGER, OnCreateModule), 0, sizeof(CHAT_MANAGER) - offsetof(CHAT_MANAGER, OnCreateModule));
+ memset(PBYTE(&g_chatApi) + offsetof(CHAT_MANAGER, OnCreateModule), 0, sizeof(CHAT_MANAGER) - offsetof(CHAT_MANAGER, OnCreateModule));
if (g_cbSession) { // reallocate old sessions
mir_cslock lck(csChat);
@@ -1011,72 +1011,72 @@ MIR_APP_DLL(CHAT_MANAGER*) Chat_GetInterface(CHAT_MANAGER_INITDATA *pInit) g_iFontMode = pInit->iFontMode;
g_iChatLang = pInit->iLangId;
- chatApi.SetActiveSession = SetActiveSession;
- chatApi.GetActiveSession = GetActiveSession;
- chatApi.SM_FindSession = SM_FindSession;
- chatApi.SM_GetStatusIcon = SM_GetStatusIcon;
- chatApi.SM_BroadcastMessage = SM_BroadcastMessage;
- 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_GetUserFromIndex = SM_GetUserFromIndex;
- chatApi.SM_InvalidateLogDirectories = SM_InvalidateLogDirectories;
-
- chatApi.MM_AddModule = MM_AddModule;
- chatApi.MM_FindModule = MM_FindModule;
- chatApi.MM_FontsChanged = MM_FontsChanged;
- chatApi.MM_IconsChanged = MM_IconsChanged;
- chatApi.MM_RemoveAll = MM_RemoveAll;
-
- chatApi.TM_FindStatus = TM_FindStatus;
- chatApi.TM_WordToString = TM_WordToString;
- chatApi.TM_RemoveAll = TM_RemoveAll;
-
- chatApi.UM_SetStatusEx = UM_SetStatusEx;
- chatApi.UM_AddUser = UM_AddUser;
- chatApi.UM_SortUser = UM_SortUser;
- chatApi.UM_FindUser = UM_FindUser;
- chatApi.UM_FindUserFromIndex = UM_FindUserFromIndex;
- chatApi.UM_GiveStatus = UM_GiveStatus;
- chatApi.UM_SetContactStatus = UM_SetContactStatus;
- chatApi.UM_TakeStatus = UM_TakeStatus;
- chatApi.UM_FindUserAutoComplete = UM_FindUserAutoComplete;
- chatApi.UM_RemoveUser = UM_RemoveUser;
- chatApi.UM_RemoveAll = UM_RemoveAll;
- chatApi.UM_CompareItem = UM_CompareItem;
-
- chatApi.LM_AddEvent = LM_AddEvent;
- chatApi.LM_TrimLog = LM_TrimLog;
- chatApi.LM_RemoveAll = LM_RemoveAll;
-
- chatApi.SetOffline = SetOffline;
- chatApi.SetAllOffline = SetAllOffline;
- chatApi.AddEvent = AddEvent;
- chatApi.FindRoom = FindRoom;
- chatApi.DoRtfToTags = DoRtfToTags;
-
- chatApi.Log_CreateRTF = Log_CreateRTF;
- chatApi.Log_CreateRtfHeader = Log_CreateRtfHeader;
- chatApi.LoadMsgDlgFont = LoadMsgDlgFont;
- chatApi.MakeTimeStamp = MakeTimeStamp;
-
- chatApi.DoSoundsFlashPopupTrayStuff = DoSoundsFlashPopupTrayStuff;
- chatApi.DoTrayIcon = DoTrayIcon;
- chatApi.DoPopup = DoPopup;
- chatApi.ShowPopup = ShowPopup;
- chatApi.LogToFile = LogToFile;
- chatApi.GetChatLogsFilename = GetChatLogsFilename;
- chatApi.Log_SetStyle = Log_SetStyle;
-
- chatApi.IsHighlighted = IsHighlighted;
- chatApi.RemoveFormatting = RemoveFormatting;
- chatApi.ReloadSettings = LoadGlobalSettings;
-
- chatApi.pLogIconBmpBits = pLogIconBmpBits;
+ g_chatApi.SetActiveSession = SetActiveSession;
+ g_chatApi.GetActiveSession = GetActiveSession;
+ g_chatApi.SM_FindSession = SM_FindSession;
+ g_chatApi.SM_GetStatusIcon = SM_GetStatusIcon;
+ g_chatApi.SM_BroadcastMessage = SM_BroadcastMessage;
+ g_chatApi.SM_AddCommand = SM_AddCommand;
+ g_chatApi.SM_GetPrevCommand = SM_GetPrevCommand;
+ g_chatApi.SM_GetNextCommand = SM_GetNextCommand;
+ g_chatApi.SM_GetCount = SM_GetCount;
+ g_chatApi.SM_FindSessionByIndex = SM_FindSessionByIndex;
+ g_chatApi.SM_GetUserFromIndex = SM_GetUserFromIndex;
+ g_chatApi.SM_InvalidateLogDirectories = SM_InvalidateLogDirectories;
+
+ g_chatApi.MM_AddModule = MM_AddModule;
+ g_chatApi.MM_FindModule = MM_FindModule;
+ g_chatApi.MM_FontsChanged = MM_FontsChanged;
+ g_chatApi.MM_IconsChanged = MM_IconsChanged;
+ g_chatApi.MM_RemoveAll = MM_RemoveAll;
+
+ g_chatApi.TM_FindStatus = TM_FindStatus;
+ g_chatApi.TM_WordToString = TM_WordToString;
+ g_chatApi.TM_RemoveAll = TM_RemoveAll;
+
+ g_chatApi.UM_SetStatusEx = UM_SetStatusEx;
+ g_chatApi.UM_AddUser = UM_AddUser;
+ g_chatApi.UM_SortUser = UM_SortUser;
+ g_chatApi.UM_FindUser = UM_FindUser;
+ g_chatApi.UM_FindUserFromIndex = UM_FindUserFromIndex;
+ g_chatApi.UM_GiveStatus = UM_GiveStatus;
+ g_chatApi.UM_SetContactStatus = UM_SetContactStatus;
+ g_chatApi.UM_TakeStatus = UM_TakeStatus;
+ g_chatApi.UM_FindUserAutoComplete = UM_FindUserAutoComplete;
+ g_chatApi.UM_RemoveUser = UM_RemoveUser;
+ g_chatApi.UM_RemoveAll = UM_RemoveAll;
+ g_chatApi.UM_CompareItem = UM_CompareItem;
+
+ g_chatApi.LM_AddEvent = LM_AddEvent;
+ g_chatApi.LM_TrimLog = LM_TrimLog;
+ g_chatApi.LM_RemoveAll = LM_RemoveAll;
+
+ g_chatApi.SetOffline = SetOffline;
+ g_chatApi.SetAllOffline = SetAllOffline;
+ g_chatApi.AddEvent = AddEvent;
+ g_chatApi.FindRoom = FindRoom;
+ g_chatApi.DoRtfToTags = DoRtfToTags;
+
+ g_chatApi.Log_CreateRTF = Log_CreateRTF;
+ g_chatApi.Log_CreateRtfHeader = Log_CreateRtfHeader;
+ g_chatApi.LoadMsgDlgFont = LoadMsgDlgFont;
+ g_chatApi.MakeTimeStamp = MakeTimeStamp;
+
+ g_chatApi.DoSoundsFlashPopupTrayStuff = DoSoundsFlashPopupTrayStuff;
+ g_chatApi.DoTrayIcon = DoTrayIcon;
+ g_chatApi.DoPopup = DoPopup;
+ g_chatApi.ShowPopup = ShowPopup;
+ g_chatApi.LogToFile = LogToFile;
+ g_chatApi.GetChatLogsFilename = GetChatLogsFilename;
+ g_chatApi.Log_SetStyle = Log_SetStyle;
+
+ g_chatApi.IsHighlighted = IsHighlighted;
+ g_chatApi.RemoveFormatting = RemoveFormatting;
+ g_chatApi.ReloadSettings = LoadGlobalSettings;
+
+ g_chatApi.pLogIconBmpBits = pLogIconBmpBits;
RegisterFonts();
OptionsInit();
- return &chatApi;
+ return &g_chatApi;
}
diff --git a/src/mir_app/src/chat_opts.cpp b/src/mir_app/src/chat_opts.cpp index b532848027..0be395a93c 100644 --- a/src/mir_app/src/chat_opts.cpp +++ b/src/mir_app/src/chat_opts.cpp @@ -78,16 +78,16 @@ static void LoadColors() void LoadLogFonts(void)
{
for (int i=0; i < OPTIONS_FONTCOUNT; i++)
- LoadMsgDlgFont(i, &chatApi.aFonts[i].lf, &chatApi.aFonts[i].color);
+ LoadMsgDlgFont(i, &g_chatApi.aFonts[i].lf, &g_chatApi.aFonts[i].color);
LoadColors();
- if (chatApi.hListBkgBrush != nullptr)
- DeleteObject(chatApi.hListBkgBrush);
- chatApi.hListBkgBrush = CreateSolidBrush(g_Settings->crUserListBGColor);
+ if (g_chatApi.hListBkgBrush != nullptr)
+ DeleteObject(g_chatApi.hListBkgBrush);
+ g_chatApi.hListBkgBrush = CreateSolidBrush(g_Settings->crUserListBGColor);
- if (chatApi.hListSelectedBkgBrush != nullptr)
- DeleteObject(chatApi.hListSelectedBkgBrush);
- chatApi.hListSelectedBkgBrush = CreateSolidBrush(g_Settings->crUserListSelectedBGColor);
+ if (g_chatApi.hListSelectedBkgBrush != nullptr)
+ DeleteObject(g_chatApi.hListSelectedBkgBrush);
+ g_chatApi.hListSelectedBkgBrush = CreateSolidBrush(g_Settings->crUserListSelectedBGColor);
}
void LoadMsgDlgFont(int i, LOGFONT *lf, COLORREF *colour)
@@ -235,8 +235,8 @@ void LoadGlobalSettings(void) LoadColors();
- if (chatApi.OnLoadSettings)
- chatApi.OnLoadSettings();
+ if (g_chatApi.OnLoadSettings)
+ g_chatApi.OnLoadSettings();
InitSetting(&g_Settings->pszTimeStamp, "HeaderTime", L"[%H:%M]");
InitSetting(&g_Settings->pszTimeStampLog, "LogTimestamp", L"[%d %b %y %H:%M]");
diff --git a/src/mir_app/src/chat_svc.cpp b/src/mir_app/src/chat_svc.cpp index b700fa3be2..db317f7791 100644 --- a/src/mir_app/src/chat_svc.cpp +++ b/src/mir_app/src/chat_svc.cpp @@ -51,26 +51,26 @@ static HANDLE void LoadChatIcons(void)
{
- chatApi.hIcons[ICON_ACTION] = LoadIconEx("log_action", FALSE);
- chatApi.hIcons[ICON_ADDSTATUS] = LoadIconEx("log_addstatus", FALSE);
- chatApi.hIcons[ICON_HIGHLIGHT] = LoadIconEx("log_highlight", FALSE);
- chatApi.hIcons[ICON_INFO] = LoadIconEx("log_info", FALSE);
- chatApi.hIcons[ICON_JOIN] = LoadIconEx("log_join", FALSE);
- chatApi.hIcons[ICON_KICK] = LoadIconEx("log_kick", FALSE);
- chatApi.hIcons[ICON_MESSAGE] = LoadIconEx("log_message_in", FALSE);
- chatApi.hIcons[ICON_MESSAGEOUT] = LoadIconEx("log_message_out", FALSE);
- chatApi.hIcons[ICON_NICK] = LoadIconEx("log_nick", FALSE);
- chatApi.hIcons[ICON_NOTICE] = LoadIconEx("log_notice", FALSE);
- chatApi.hIcons[ICON_PART] = LoadIconEx("log_part", FALSE);
- chatApi.hIcons[ICON_QUIT] = LoadIconEx("log_quit", FALSE);
- chatApi.hIcons[ICON_REMSTATUS] = LoadIconEx("log_removestatus", FALSE);
- chatApi.hIcons[ICON_TOPIC] = LoadIconEx("log_topic", FALSE);
- chatApi.hIcons[ICON_STATUS0] = LoadIconEx("status0", FALSE);
- chatApi.hIcons[ICON_STATUS1] = LoadIconEx("status1", FALSE);
- chatApi.hIcons[ICON_STATUS2] = LoadIconEx("status2", FALSE);
- chatApi.hIcons[ICON_STATUS3] = LoadIconEx("status3", FALSE);
- chatApi.hIcons[ICON_STATUS4] = LoadIconEx("status4", FALSE);
- chatApi.hIcons[ICON_STATUS5] = LoadIconEx("status5", FALSE);
+ g_chatApi.hIcons[ICON_ACTION] = LoadIconEx("log_action", FALSE);
+ g_chatApi.hIcons[ICON_ADDSTATUS] = LoadIconEx("log_addstatus", FALSE);
+ g_chatApi.hIcons[ICON_HIGHLIGHT] = LoadIconEx("log_highlight", FALSE);
+ g_chatApi.hIcons[ICON_INFO] = LoadIconEx("log_info", FALSE);
+ g_chatApi.hIcons[ICON_JOIN] = LoadIconEx("log_join", FALSE);
+ g_chatApi.hIcons[ICON_KICK] = LoadIconEx("log_kick", FALSE);
+ g_chatApi.hIcons[ICON_MESSAGE] = LoadIconEx("log_message_in", FALSE);
+ g_chatApi.hIcons[ICON_MESSAGEOUT] = LoadIconEx("log_message_out", FALSE);
+ g_chatApi.hIcons[ICON_NICK] = LoadIconEx("log_nick", FALSE);
+ g_chatApi.hIcons[ICON_NOTICE] = LoadIconEx("log_notice", FALSE);
+ g_chatApi.hIcons[ICON_PART] = LoadIconEx("log_part", FALSE);
+ g_chatApi.hIcons[ICON_QUIT] = LoadIconEx("log_quit", FALSE);
+ g_chatApi.hIcons[ICON_REMSTATUS] = LoadIconEx("log_removestatus", FALSE);
+ g_chatApi.hIcons[ICON_TOPIC] = LoadIconEx("log_topic", FALSE);
+ g_chatApi.hIcons[ICON_STATUS0] = LoadIconEx("status0", FALSE);
+ g_chatApi.hIcons[ICON_STATUS1] = LoadIconEx("status1", FALSE);
+ g_chatApi.hIcons[ICON_STATUS2] = LoadIconEx("status2", FALSE);
+ g_chatApi.hIcons[ICON_STATUS3] = LoadIconEx("status3", FALSE);
+ g_chatApi.hIcons[ICON_STATUS4] = LoadIconEx("status4", FALSE);
+ g_chatApi.hIcons[ICON_STATUS5] = LoadIconEx("status5", FALSE);
FreeMsgLogBitmaps();
LoadMsgLogBitmaps();
@@ -87,7 +87,7 @@ static int FontsChanged(WPARAM, LPARAM) SetIndentSize();
g_Settings->bLogIndentEnabled = (db_get_b(0, CHAT_MODULE, "LogIndentEnabled", 1) != 0) ? TRUE : FALSE;
- chatApi.MM_FontsChanged();
+ g_chatApi.MM_FontsChanged();
Chat_UpdateOptions();
return 0;
}
@@ -97,7 +97,7 @@ static int IconsChanged(WPARAM, LPARAM) FreeMsgLogBitmaps();
LoadMsgLogBitmaps();
- chatApi.MM_IconsChanged();
+ g_chatApi.MM_IconsChanged();
Chat_UpdateOptions();
return 0;
}
@@ -106,10 +106,10 @@ static int PreShutdown(WPARAM, LPARAM) {
if (g_Settings != nullptr) {
SM_RemoveAll();
- chatApi.MM_RemoveAll();
+ g_chatApi.MM_RemoveAll();
- DeleteObject(chatApi.hListBkgBrush);
- DeleteObject(chatApi.hListSelectedBkgBrush);
+ DeleteObject(g_chatApi.hListBkgBrush);
+ DeleteObject(g_chatApi.hListSelectedBkgBrush);
}
return 0;
}
@@ -158,7 +158,7 @@ MIR_APP_DLL(int) Chat_Register(const GCREGISTER *gcr) return GC_ERROR;
mir_cslock lck(csChat);
- MODULEINFO *mi = chatApi.MM_AddModule(gcr->pszModule);
+ MODULEINFO *mi = g_chatApi.MM_AddModule(gcr->pszModule);
if (mi == nullptr)
return GC_ERROR;
@@ -171,9 +171,9 @@ MIR_APP_DLL(int) Chat_Register(const GCREGISTER *gcr) mi->bAckMsg = (gcr->dwFlags & GC_ACKMSG) != 0;
mi->bChanMgr = (gcr->dwFlags & GC_CHANMGR) != 0;
mi->iMaxText = gcr->iMaxText;
- mi->pszHeader = chatApi.Log_CreateRtfHeader();
+ mi->pszHeader = g_chatApi.Log_CreateRtfHeader();
- chatApi.SetAllOffline(TRUE, gcr->pszModule);
+ g_chatApi.SetAllOffline(TRUE, gcr->pszModule);
return 0;
}
@@ -188,23 +188,23 @@ EXTERN_C MIR_APP_DLL(GCSessionInfoBase*) Chat_NewSession( void *pItemData) // Set user defined data for this session. Retrieve it by using the Chat_GetUserInfo() call
{
mir_cslockfull lck(csChat);
- MODULEINFO *mi = chatApi.MM_FindModule(pszModule);
+ MODULEINFO *mi = g_chatApi.MM_FindModule(pszModule);
if (mi == nullptr)
return nullptr;
// try to restart a session first
SESSION_INFO *si = SM_FindSession(ptszID, pszModule);
if (si != nullptr) {
- chatApi.UM_RemoveAll(&si->pUsers);
- chatApi.TM_RemoveAll(&si->pStatuses);
+ g_chatApi.UM_RemoveAll(&si->pUsers);
+ g_chatApi.TM_RemoveAll(&si->pStatuses);
lck.unlock();
si->iStatusCount = 0;
si->nUsersInNicklist = 0;
si->pMe = nullptr;
- if (chatApi.OnReplaceSession)
- chatApi.OnReplaceSession(si);
+ if (g_chatApi.OnReplaceSession)
+ g_chatApi.OnReplaceSession(si);
return si;
}
@@ -213,7 +213,7 @@ EXTERN_C MIR_APP_DLL(GCSessionInfoBase*) Chat_NewSession( si->ptszID = mir_wstrdup(ptszID);
si->pszModule = mir_strdup(pszModule);
- chatApi.arSessions.insert(si);
+ g_chatApi.arSessions.insert(si);
lck.unlock();
// set the defaults
@@ -237,8 +237,8 @@ EXTERN_C MIR_APP_DLL(GCSessionInfoBase*) Chat_NewSession( else
db_set_s(si->hContact, si->pszModule, "StatusBar", "");
- if (chatApi.OnCreateSession)
- chatApi.OnCreateSession(si, mi);
+ if (g_chatApi.OnCreateSession)
+ g_chatApi.OnCreateSession(si, mi);
return si;
}
@@ -278,7 +278,7 @@ static INT_PTR __stdcall stubRoomControl(void *param) return GC_EVENT_ERROR;
SetInitDone(si);
- chatApi.SetActiveSession(si);
+ g_chatApi.SetActiveSession(si);
break;
case WINDOW_VISIBLE:
@@ -288,7 +288,7 @@ static INT_PTR __stdcall stubRoomControl(void *param) SetInitDone(si);
if (p->command != SESSION_INITDONE || db_get_b(0, CHAT_MODULE, "PopupOnJoin", 0) == 0)
- chatApi.ShowRoom(si);
+ g_chatApi.ShowRoom(si);
break;
case SESSION_OFFLINE:
@@ -316,7 +316,7 @@ static INT_PTR __stdcall stubRoomControl(void *param) if (si == nullptr)
return GC_EVENT_ERROR;
- chatApi.LM_RemoveAll(&si->pLog, &si->pLogEnd);
+ g_chatApi.LM_RemoveAll(&si->pLog, &si->pLogEnd);
si->iEventCount = 0;
si->LastTime = 0;
if (si->pDlg)
@@ -369,13 +369,13 @@ static void AddUser(GCEVENT *gce) WORD status = TM_StringToWord(si->pStatuses, gce->ptszStatus);
- USERINFO *ui = chatApi.UM_AddUser(si->pStatuses, &si->pUsers, gce->ptszUID, gce->ptszNick, status);
+ USERINFO *ui = g_chatApi.UM_AddUser(si->pStatuses, &si->pUsers, gce->ptszUID, gce->ptszNick, status);
if (ui == nullptr)
return;
si->nUsersInNicklist++;
- if (chatApi.OnAddUser)
- chatApi.OnAddUser(si, ui);
+ if (g_chatApi.OnAddUser)
+ g_chatApi.OnAddUser(si, ui);
ui->pszNick = mir_wstrdup(gce->ptszNick);
if (gce->bIsMe)
@@ -386,8 +386,8 @@ static void AddUser(GCEVENT *gce) if (si->pDlg)
si->pDlg->UpdateNickList();
- if (chatApi.OnNewUser)
- chatApi.OnNewUser(si, ui);
+ if (g_chatApi.OnNewUser)
+ g_chatApi.OnNewUser(si, ui);
}
static BOOL AddEventToAllMatchingUID(GCEVENT *gce)
@@ -398,11 +398,11 @@ static BOOL AddEventToAllMatchingUID(GCEVENT *gce) if (!si->bInitDone || mir_strcmpi(si->pszModule, gce->pszModule))
continue;
- if (!chatApi.UM_FindUser(si->pUsers, gce->ptszUID))
+ if (!g_chatApi.UM_FindUser(si->pUsers, gce->ptszUID))
continue;
- if (chatApi.OnEventBroadcast)
- chatApi.OnEventBroadcast(si, gce);
+ if (g_chatApi.OnEventBroadcast)
+ g_chatApi.OnEventBroadcast(si, gce);
if (si->pDlg && si->bInitDone) {
if (SM_AddEvent(si->ptszID, si->pszModule, gce, FALSE))
@@ -412,11 +412,11 @@ static BOOL AddEventToAllMatchingUID(GCEVENT *gce) }
if (!(gce->dwFlags & GCEF_NOTNOTIFY))
- chatApi.DoSoundsFlashPopupTrayStuff(si, gce, FALSE, bManyFix);
+ g_chatApi.DoSoundsFlashPopupTrayStuff(si, gce, FALSE, bManyFix);
bManyFix++;
if ((gce->dwFlags & GCEF_ADDTOLOG) && g_Settings->bLoggingEnabled)
- chatApi.LogToFile(si, gce);
+ g_chatApi.LogToFile(si, gce);
}
return 0;
@@ -447,8 +447,8 @@ static INT_PTR CALLBACK sttEventStub(void *_param) else
db_unset(si->hContact, si->pszModule, "Topic");
- if (chatApi.OnSetTopic)
- chatApi.OnSetTopic(si);
+ if (g_chatApi.OnSetTopic)
+ g_chatApi.OnSetTopic(si);
if (db_get_b(0, CHAT_MODULE, "TopicOnClist", 0)) {
if (pwszNew != nullptr)
@@ -461,37 +461,37 @@ static INT_PTR CALLBACK sttEventStub(void *_param) case GC_EVENT_ADDSTATUS:
SM_GiveStatus(gce->ptszID, gce->pszModule, gce->ptszUID, gce->ptszStatus);
- bIsHighlighted = chatApi.IsHighlighted(nullptr, gce);
+ bIsHighlighted = g_chatApi.IsHighlighted(nullptr, gce);
break;
case GC_EVENT_REMOVESTATUS:
SM_TakeStatus(gce->ptszID, gce->pszModule, gce->ptszUID, gce->ptszStatus);
- bIsHighlighted = chatApi.IsHighlighted(nullptr, gce);
+ bIsHighlighted = g_chatApi.IsHighlighted(nullptr, gce);
break;
case GC_EVENT_MESSAGE:
case GC_EVENT_ACTION:
if (!gce->bIsMe && gce->ptszID && gce->ptszText) {
SESSION_INFO *si = SM_FindSession(gce->ptszID, gce->pszModule);
- bIsHighlighted = chatApi.IsHighlighted(si, gce);
+ bIsHighlighted = g_chatApi.IsHighlighted(si, gce);
}
break;
case GC_EVENT_NICK:
SM_ChangeNick(gce->ptszID, gce->pszModule, gce);
- bIsHighlighted = chatApi.IsHighlighted(nullptr, gce);
+ bIsHighlighted = g_chatApi.IsHighlighted(nullptr, gce);
break;
case GC_EVENT_JOIN:
AddUser(gce);
- bIsHighlighted = chatApi.IsHighlighted(nullptr, gce);
+ bIsHighlighted = g_chatApi.IsHighlighted(nullptr, gce);
break;
case GC_EVENT_PART:
case GC_EVENT_QUIT:
case GC_EVENT_KICK:
bRemoveFlag = TRUE;
- bIsHighlighted = chatApi.IsHighlighted(nullptr, gce);
+ bIsHighlighted = g_chatApi.IsHighlighted(nullptr, gce);
break;
}
@@ -503,7 +503,7 @@ static INT_PTR CALLBACK sttEventStub(void *_param) pMod = gce->pszModule;
}
else if (gce->iType == GC_EVENT_NOTICE || gce->iType == GC_EVENT_INFORMATION) {
- SESSION_INFO *si = chatApi.GetActiveSession();
+ SESSION_INFO *si = g_chatApi.GetActiveSession();
if (si && !mir_strcmp(si->pszModule, gce->pszModule)) {
pWnd = si->ptszID;
pMod = si->pszModule;
@@ -533,7 +533,7 @@ static INT_PTR CALLBACK sttEventStub(void *_param) if (si && (si->bInitDone || gce->iType == GC_EVENT_TOPIC || (gce->iType == GC_EVENT_JOIN && gce->bIsMe))) {
if (gce->ptszNick == nullptr && gce->ptszUID != nullptr) {
- USERINFO *ui = chatApi.UM_FindUser(si->pUsers, gce->ptszUID);
+ USERINFO *ui = g_chatApi.UM_FindUser(si->pUsers, gce->ptszUID);
if (ui != nullptr)
gce->ptszNick = ui->pszNick;
}
@@ -547,10 +547,10 @@ static INT_PTR CALLBACK sttEventStub(void *_param) }
if (!(gce->dwFlags & GCEF_NOTNOTIFY))
- chatApi.DoSoundsFlashPopupTrayStuff(si, gce, bIsHighlighted, 0);
+ g_chatApi.DoSoundsFlashPopupTrayStuff(si, gce, bIsHighlighted, 0);
if ((gce->dwFlags & GCEF_ADDTOLOG) && g_Settings->bLoggingEnabled)
- chatApi.LogToFile(si, gce);
+ g_chatApi.LogToFile(si, gce);
}
if (!bRemoveFlag)
@@ -591,8 +591,8 @@ MIR_APP_DLL(int) Chat_AddGroup(const char *szModule, const wchar_t *wszId, const if (ti)
si->iStatusCount++;
- if (chatApi.OnAddStatus)
- chatApi.OnAddStatus(si, ti);
+ if (g_chatApi.OnAddStatus)
+ g_chatApi.OnAddStatus(si, ti);
return 0;
}
@@ -625,7 +625,7 @@ MIR_APP_DLL(int) Chat_ChangeUserId(const char *szModule, const wchar_t *wszId, c if ((wszId && mir_wstrcmpi(si->ptszID, wszId)) || mir_strcmpi(si->pszModule, szModule))
continue;
- USERINFO *ui = chatApi.UM_FindUser(si->pUsers, wszOldId);
+ USERINFO *ui = g_chatApi.UM_FindUser(si->pUsers, wszOldId);
if (ui)
replaceStrW(ui->pszUID, wszNewId);
if (wszId)
@@ -691,7 +691,7 @@ MIR_APP_DLL(int) Chat_SetStatusEx(const char *szModule, const wchar_t *wszId, in if ((wszId && mir_wstrcmpi(si->ptszID, wszId)) || mir_strcmpi(si->pszModule, szModule))
continue;
- chatApi.UM_SetStatusEx(si->pUsers, wszText, flags);
+ g_chatApi.UM_SetStatusEx(si->pUsers, wszText, flags);
if (si->pDlg)
RedrawWindow(GetDlgItem(si->pDlg->GetHwnd(), IDC_LIST), nullptr, nullptr, RDW_INVALIDATE);
if (wszId)
@@ -702,7 +702,7 @@ MIR_APP_DLL(int) Chat_SetStatusEx(const char *szModule, const wchar_t *wszId, in MIR_APP_DLL(int) Chat_SetUserInfo(const char *szModule, const wchar_t *wszId, void *pItemData)
{
- if (SESSION_INFO *si = chatApi.SM_FindSession(wszId, szModule)) {
+ if (SESSION_INFO *si = g_chatApi.SM_FindSession(wszId, szModule)) {
si->pItemData = pItemData;
return 0;
}
@@ -745,7 +745,7 @@ static int ModulesLoaded(WPARAM, LPARAM) hLeaveMenuItem = Menu_AddContactMenuItem(&mi);
CreateServiceFunction(mi.pszService, LeaveChat);
- chatApi.SetAllOffline(TRUE, nullptr);
+ g_chatApi.SetAllOffline(TRUE, nullptr);
return 0;
}
@@ -762,8 +762,8 @@ int LoadChatModule(void) hevSendEvent = CreateHookableEvent(ME_GC_EVENT);
hevBuildMenuEvent = CreateHookableEvent(ME_GC_BUILDMENU);
- chatApi.hevPreCreate = CreateHookableEvent(ME_MSG_PRECREATEEVENT);
- chatApi.hevWinPopup = CreateHookableEvent(ME_MSG_WINDOWPOPUP);
+ g_chatApi.hevPreCreate = CreateHookableEvent(ME_MSG_PRECREATEEVENT);
+ g_chatApi.hevWinPopup = CreateHookableEvent(ME_MSG_WINDOWPOPUP);
HookEvent(ME_FONT_RELOAD, FontsChanged);
HookEvent(ME_SKIN2_ICONSCHANGED, IconsChanged);
@@ -780,8 +780,8 @@ void UnloadChatModule(void) if (!bInited)
return;
- mir_free(chatApi.szActiveWndID);
- mir_free(chatApi.szActiveWndModule);
+ mir_free(g_chatApi.szActiveWndID);
+ mir_free(g_chatApi.szActiveWndModule);
FreeMsgLogBitmaps();
OptionsUnInit();
@@ -792,8 +792,8 @@ void UnloadChatModule(void) DestroyHookableEvent(hevBuildMenuEvent);
DestroyHookableEvent(hHookEvent);
- DestroyHookableEvent(chatApi.hevPreCreate);
- DestroyHookableEvent(chatApi.hevWinPopup);
+ DestroyHookableEvent(g_chatApi.hevPreCreate);
+ DestroyHookableEvent(g_chatApi.hevWinPopup);
DestroyMenu(g_hMenu);
}
diff --git a/src/mir_app/src/chat_tools.cpp b/src/mir_app/src/chat_tools.cpp index ee89291d70..dfd627a4de 100644 --- a/src/mir_app/src/chat_tools.cpp +++ b/src/mir_app/src/chat_tools.cpp @@ -85,43 +85,43 @@ BOOL DoTrayIcon(SESSION_INFO *si, GCEVENT *gce) switch (gce->iType) {
case GC_EVENT_MESSAGE | GC_EVENT_HIGHLIGHT:
case GC_EVENT_ACTION | GC_EVENT_HIGHLIGHT:
- chatApi.AddEvent(si->hContact, Skin_LoadIcon(SKINICON_EVENT_MESSAGE), GC_FAKE_EVENT, 0, TranslateT("%s wants your attention in %s"), gce->ptszNick, si->ptszName);
+ g_chatApi.AddEvent(si->hContact, Skin_LoadIcon(SKINICON_EVENT_MESSAGE), GC_FAKE_EVENT, 0, TranslateT("%s wants your attention in %s"), gce->ptszNick, si->ptszName);
break;
case GC_EVENT_MESSAGE:
- chatApi.AddEvent(si->hContact, chatApi.hIcons[ICON_MESSAGE], GC_FAKE_EVENT, CLEF_ONLYAFEW, TranslateT("%s speaks in %s"), gce->ptszNick, si->ptszName);
+ g_chatApi.AddEvent(si->hContact, g_chatApi.hIcons[ICON_MESSAGE], GC_FAKE_EVENT, CLEF_ONLYAFEW, TranslateT("%s speaks in %s"), gce->ptszNick, si->ptszName);
break;
case GC_EVENT_ACTION:
- chatApi.AddEvent(si->hContact, chatApi.hIcons[ICON_ACTION], GC_FAKE_EVENT, CLEF_ONLYAFEW, TranslateT("%s speaks in %s"), gce->ptszNick, si->ptszName);
+ g_chatApi.AddEvent(si->hContact, g_chatApi.hIcons[ICON_ACTION], GC_FAKE_EVENT, CLEF_ONLYAFEW, TranslateT("%s speaks in %s"), gce->ptszNick, si->ptszName);
break;
case GC_EVENT_JOIN:
- chatApi.AddEvent(si->hContact, chatApi.hIcons[ICON_JOIN], GC_FAKE_EVENT, CLEF_ONLYAFEW, TranslateT("%s has joined %s"), gce->ptszNick, si->ptszName);
+ g_chatApi.AddEvent(si->hContact, g_chatApi.hIcons[ICON_JOIN], GC_FAKE_EVENT, CLEF_ONLYAFEW, TranslateT("%s has joined %s"), gce->ptszNick, si->ptszName);
break;
case GC_EVENT_PART:
- chatApi.AddEvent(si->hContact, chatApi.hIcons[ICON_PART], GC_FAKE_EVENT, CLEF_ONLYAFEW, TranslateT("%s has left %s"), gce->ptszNick, si->ptszName);
+ g_chatApi.AddEvent(si->hContact, g_chatApi.hIcons[ICON_PART], GC_FAKE_EVENT, CLEF_ONLYAFEW, TranslateT("%s has left %s"), gce->ptszNick, si->ptszName);
break;
case GC_EVENT_QUIT:
- chatApi.AddEvent(si->hContact, chatApi.hIcons[ICON_QUIT], GC_FAKE_EVENT, CLEF_ONLYAFEW, TranslateT("%s has disconnected"), gce->ptszNick);
+ g_chatApi.AddEvent(si->hContact, g_chatApi.hIcons[ICON_QUIT], GC_FAKE_EVENT, CLEF_ONLYAFEW, TranslateT("%s has disconnected"), gce->ptszNick);
break;
case GC_EVENT_NICK:
- chatApi.AddEvent(si->hContact, chatApi.hIcons[ICON_NICK], GC_FAKE_EVENT, CLEF_ONLYAFEW, TranslateT("%s is now known as %s"), gce->ptszNick, gce->ptszText);
+ g_chatApi.AddEvent(si->hContact, g_chatApi.hIcons[ICON_NICK], GC_FAKE_EVENT, CLEF_ONLYAFEW, TranslateT("%s is now known as %s"), gce->ptszNick, gce->ptszText);
break;
case GC_EVENT_KICK:
- chatApi.AddEvent(si->hContact, chatApi.hIcons[ICON_KICK], GC_FAKE_EVENT, CLEF_ONLYAFEW, TranslateT("%s kicked %s from %s"), gce->ptszStatus, gce->ptszNick, si->ptszName);
+ g_chatApi.AddEvent(si->hContact, g_chatApi.hIcons[ICON_KICK], GC_FAKE_EVENT, CLEF_ONLYAFEW, TranslateT("%s kicked %s from %s"), gce->ptszStatus, gce->ptszNick, si->ptszName);
break;
case GC_EVENT_NOTICE:
- chatApi.AddEvent(si->hContact, chatApi.hIcons[ICON_NOTICE], GC_FAKE_EVENT, CLEF_ONLYAFEW, TranslateT("Notice from %s"), gce->ptszNick);
+ g_chatApi.AddEvent(si->hContact, g_chatApi.hIcons[ICON_NOTICE], GC_FAKE_EVENT, CLEF_ONLYAFEW, TranslateT("Notice from %s"), gce->ptszNick);
break;
case GC_EVENT_TOPIC:
- chatApi.AddEvent(si->hContact, chatApi.hIcons[ICON_TOPIC], GC_FAKE_EVENT, CLEF_ONLYAFEW, TranslateT("Topic change in %s"), si->ptszName);
+ g_chatApi.AddEvent(si->hContact, g_chatApi.hIcons[ICON_TOPIC], GC_FAKE_EVENT, CLEF_ONLYAFEW, TranslateT("Topic change in %s"), si->ptszName);
break;
case GC_EVENT_INFORMATION:
- chatApi.AddEvent(si->hContact, chatApi.hIcons[ICON_INFO], GC_FAKE_EVENT, CLEF_ONLYAFEW, TranslateT("Information in %s"), si->ptszName);
+ g_chatApi.AddEvent(si->hContact, g_chatApi.hIcons[ICON_INFO], GC_FAKE_EVENT, CLEF_ONLYAFEW, TranslateT("Information in %s"), si->ptszName);
break;
case GC_EVENT_ADDSTATUS:
- chatApi.AddEvent(si->hContact, chatApi.hIcons[ICON_ADDSTATUS], GC_FAKE_EVENT, CLEF_ONLYAFEW, TranslateT("%s enables '%s' status for %s in %s"), gce->ptszText, gce->ptszStatus, gce->ptszNick, si->ptszName);
+ g_chatApi.AddEvent(si->hContact, g_chatApi.hIcons[ICON_ADDSTATUS], GC_FAKE_EVENT, CLEF_ONLYAFEW, TranslateT("%s enables '%s' status for %s in %s"), gce->ptszText, gce->ptszStatus, gce->ptszNick, si->ptszName);
break;
case GC_EVENT_REMOVESTATUS:
- chatApi.AddEvent(si->hContact, chatApi.hIcons[ICON_REMSTATUS], GC_FAKE_EVENT, CLEF_ONLYAFEW, TranslateT("%s disables '%s' status for %s in %s"), gce->ptszText, gce->ptszStatus, gce->ptszNick, si->ptszName);
+ g_chatApi.AddEvent(si->hContact, g_chatApi.hIcons[ICON_REMSTATUS], GC_FAKE_EVENT, CLEF_ONLYAFEW, TranslateT("%s disables '%s' status for %s in %s"), gce->ptszText, gce->ptszStatus, gce->ptszNick, si->ptszName);
break;
}
@@ -133,7 +133,7 @@ BOOL DoTrayIcon(SESSION_INFO *si, GCEVENT *gce) static void __stdcall ShowRoomFromPopup(void *pi)
{
SESSION_INFO *si = (SESSION_INFO*)pi;
- chatApi.ShowRoom(si);
+ g_chatApi.ShowRoom(si);
}
static LRESULT CALLBACK PopupDlgProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
@@ -210,58 +210,58 @@ BOOL DoPopup(SESSION_INFO *si, GCEVENT *gce) {
switch (gce->iType) {
case GC_EVENT_MESSAGE | GC_EVENT_HIGHLIGHT:
- chatApi.ShowPopup(si->hContact, si, Skin_LoadIcon(SKINICON_EVENT_MESSAGE), si->pszModule, si->ptszName, chatApi.aFonts[16].color, TranslateT("%s says: %s"), gce->ptszNick, RemoveFormatting(gce->ptszText));
+ g_chatApi.ShowPopup(si->hContact, si, Skin_LoadIcon(SKINICON_EVENT_MESSAGE), si->pszModule, si->ptszName, g_chatApi.aFonts[16].color, TranslateT("%s says: %s"), gce->ptszNick, RemoveFormatting(gce->ptszText));
break;
case GC_EVENT_ACTION | GC_EVENT_HIGHLIGHT:
- chatApi.ShowPopup(si->hContact, si, Skin_LoadIcon(SKINICON_EVENT_MESSAGE), si->pszModule, si->ptszName, chatApi.aFonts[16].color, L"%s %s", gce->ptszNick, RemoveFormatting(gce->ptszText));
+ g_chatApi.ShowPopup(si->hContact, si, Skin_LoadIcon(SKINICON_EVENT_MESSAGE), si->pszModule, si->ptszName, g_chatApi.aFonts[16].color, L"%s %s", gce->ptszNick, RemoveFormatting(gce->ptszText));
break;
case GC_EVENT_MESSAGE:
- chatApi.ShowPopup(si->hContact, si, chatApi.hIcons[ICON_MESSAGE], si->pszModule, si->ptszName, chatApi.aFonts[9].color, TranslateT("%s says: %s"), gce->ptszNick, RemoveFormatting(gce->ptszText));
+ g_chatApi.ShowPopup(si->hContact, si, g_chatApi.hIcons[ICON_MESSAGE], si->pszModule, si->ptszName, g_chatApi.aFonts[9].color, TranslateT("%s says: %s"), gce->ptszNick, RemoveFormatting(gce->ptszText));
break;
case GC_EVENT_ACTION:
- chatApi.ShowPopup(si->hContact, si, chatApi.hIcons[ICON_ACTION], si->pszModule, si->ptszName, chatApi.aFonts[15].color, L"%s %s", gce->ptszNick, RemoveFormatting(gce->ptszText));
+ g_chatApi.ShowPopup(si->hContact, si, g_chatApi.hIcons[ICON_ACTION], si->pszModule, si->ptszName, g_chatApi.aFonts[15].color, L"%s %s", gce->ptszNick, RemoveFormatting(gce->ptszText));
break;
case GC_EVENT_JOIN:
- chatApi.ShowPopup(si->hContact, si, chatApi.hIcons[ICON_JOIN], si->pszModule, si->ptszName, chatApi.aFonts[3].color, TranslateT("%s has joined"), gce->ptszNick);
+ g_chatApi.ShowPopup(si->hContact, si, g_chatApi.hIcons[ICON_JOIN], si->pszModule, si->ptszName, g_chatApi.aFonts[3].color, TranslateT("%s has joined"), gce->ptszNick);
break;
case GC_EVENT_PART:
if (!gce->ptszText)
- chatApi.ShowPopup(si->hContact, si, chatApi.hIcons[ICON_PART], si->pszModule, si->ptszName, chatApi.aFonts[4].color, TranslateT("%s has left"), gce->ptszNick);
+ g_chatApi.ShowPopup(si->hContact, si, g_chatApi.hIcons[ICON_PART], si->pszModule, si->ptszName, g_chatApi.aFonts[4].color, TranslateT("%s has left"), gce->ptszNick);
else
- chatApi.ShowPopup(si->hContact, si, chatApi.hIcons[ICON_PART], si->pszModule, si->ptszName, chatApi.aFonts[4].color, TranslateT("%s has left (%s)"), gce->ptszNick, RemoveFormatting(gce->ptszText));
+ g_chatApi.ShowPopup(si->hContact, si, g_chatApi.hIcons[ICON_PART], si->pszModule, si->ptszName, g_chatApi.aFonts[4].color, TranslateT("%s has left (%s)"), gce->ptszNick, RemoveFormatting(gce->ptszText));
break;
case GC_EVENT_QUIT:
if (!gce->ptszText)
- chatApi.ShowPopup(si->hContact, si, chatApi.hIcons[ICON_QUIT], si->pszModule, si->ptszName, chatApi.aFonts[5].color, TranslateT("%s has disconnected"), gce->ptszNick);
+ g_chatApi.ShowPopup(si->hContact, si, g_chatApi.hIcons[ICON_QUIT], si->pszModule, si->ptszName, g_chatApi.aFonts[5].color, TranslateT("%s has disconnected"), gce->ptszNick);
else
- chatApi.ShowPopup(si->hContact, si, chatApi.hIcons[ICON_QUIT], si->pszModule, si->ptszName, chatApi.aFonts[5].color, TranslateT("%s has disconnected (%s)"), gce->ptszNick, RemoveFormatting(gce->ptszText));
+ g_chatApi.ShowPopup(si->hContact, si, g_chatApi.hIcons[ICON_QUIT], si->pszModule, si->ptszName, g_chatApi.aFonts[5].color, TranslateT("%s has disconnected (%s)"), gce->ptszNick, RemoveFormatting(gce->ptszText));
break;
case GC_EVENT_NICK:
- chatApi.ShowPopup(si->hContact, si, chatApi.hIcons[ICON_NICK], si->pszModule, si->ptszName, chatApi.aFonts[7].color, TranslateT("%s is now known as %s"), gce->ptszNick, gce->ptszText);
+ g_chatApi.ShowPopup(si->hContact, si, g_chatApi.hIcons[ICON_NICK], si->pszModule, si->ptszName, g_chatApi.aFonts[7].color, TranslateT("%s is now known as %s"), gce->ptszNick, gce->ptszText);
break;
case GC_EVENT_KICK:
if (!gce->ptszText)
- chatApi.ShowPopup(si->hContact, si, chatApi.hIcons[ICON_KICK], si->pszModule, si->ptszName, chatApi.aFonts[6].color, TranslateT("%s kicked %s"), (char *)gce->ptszStatus, gce->ptszNick);
+ g_chatApi.ShowPopup(si->hContact, si, g_chatApi.hIcons[ICON_KICK], si->pszModule, si->ptszName, g_chatApi.aFonts[6].color, TranslateT("%s kicked %s"), (char *)gce->ptszStatus, gce->ptszNick);
else
- chatApi.ShowPopup(si->hContact, si, chatApi.hIcons[ICON_KICK], si->pszModule, si->ptszName, chatApi.aFonts[6].color, TranslateT("%s kicked %s (%s)"), (char *)gce->ptszStatus, gce->ptszNick, RemoveFormatting(gce->ptszText));
+ g_chatApi.ShowPopup(si->hContact, si, g_chatApi.hIcons[ICON_KICK], si->pszModule, si->ptszName, g_chatApi.aFonts[6].color, TranslateT("%s kicked %s (%s)"), (char *)gce->ptszStatus, gce->ptszNick, RemoveFormatting(gce->ptszText));
break;
case GC_EVENT_NOTICE:
- chatApi.ShowPopup(si->hContact, si, chatApi.hIcons[ICON_NOTICE], si->pszModule, si->ptszName, chatApi.aFonts[8].color, TranslateT("Notice from %s: %s"), gce->ptszNick, RemoveFormatting(gce->ptszText));
+ g_chatApi.ShowPopup(si->hContact, si, g_chatApi.hIcons[ICON_NOTICE], si->pszModule, si->ptszName, g_chatApi.aFonts[8].color, TranslateT("Notice from %s: %s"), gce->ptszNick, RemoveFormatting(gce->ptszText));
break;
case GC_EVENT_TOPIC:
if (!gce->ptszNick)
- chatApi.ShowPopup(si->hContact, si, chatApi.hIcons[ICON_TOPIC], si->pszModule, si->ptszName, chatApi.aFonts[11].color, TranslateT("The topic is '%s'"), RemoveFormatting(gce->ptszText));
+ g_chatApi.ShowPopup(si->hContact, si, g_chatApi.hIcons[ICON_TOPIC], si->pszModule, si->ptszName, g_chatApi.aFonts[11].color, TranslateT("The topic is '%s'"), RemoveFormatting(gce->ptszText));
else
- chatApi.ShowPopup(si->hContact, si, chatApi.hIcons[ICON_TOPIC], si->pszModule, si->ptszName, chatApi.aFonts[11].color, TranslateT("The topic is '%s' (set by %s)"), RemoveFormatting(gce->ptszText), gce->ptszNick);
+ g_chatApi.ShowPopup(si->hContact, si, g_chatApi.hIcons[ICON_TOPIC], si->pszModule, si->ptszName, g_chatApi.aFonts[11].color, TranslateT("The topic is '%s' (set by %s)"), RemoveFormatting(gce->ptszText), gce->ptszNick);
break;
case GC_EVENT_INFORMATION:
- chatApi.ShowPopup(si->hContact, si, chatApi.hIcons[ICON_INFO], si->pszModule, si->ptszName, chatApi.aFonts[12].color, L"%s", RemoveFormatting(gce->ptszText));
+ g_chatApi.ShowPopup(si->hContact, si, g_chatApi.hIcons[ICON_INFO], si->pszModule, si->ptszName, g_chatApi.aFonts[12].color, L"%s", RemoveFormatting(gce->ptszText));
break;
case GC_EVENT_ADDSTATUS:
- chatApi.ShowPopup(si->hContact, si, chatApi.hIcons[ICON_ADDSTATUS], si->pszModule, si->ptszName, chatApi.aFonts[13].color, TranslateT("%s enables '%s' status for %s"), gce->ptszText, (char *)gce->ptszStatus, gce->ptszNick);
+ g_chatApi.ShowPopup(si->hContact, si, g_chatApi.hIcons[ICON_ADDSTATUS], si->pszModule, si->ptszName, g_chatApi.aFonts[13].color, TranslateT("%s enables '%s' status for %s"), gce->ptszText, (char *)gce->ptszStatus, gce->ptszNick);
break;
case GC_EVENT_REMOVESTATUS:
- chatApi.ShowPopup(si->hContact, si, chatApi.hIcons[ICON_REMSTATUS], si->pszModule, si->ptszName, chatApi.aFonts[14].color, TranslateT("%s disables '%s' status for %s"), gce->ptszText, (char *)gce->ptszStatus, gce->ptszNick);
+ g_chatApi.ShowPopup(si->hContact, si, g_chatApi.hIcons[ICON_REMSTATUS], si->pszModule, si->ptszName, g_chatApi.aFonts[14].color, TranslateT("%s disables '%s' status for %s"), gce->ptszText, (char *)gce->ptszStatus, gce->ptszNick);
break;
}
@@ -295,23 +295,23 @@ BOOL DoSoundsFlashPopupTrayStuff(SESSION_INFO *si, GCEVENT *gce, BOOL bHighlight if (db_get_b(si->hContact, "CList", "Hidden", 0) != 0)
db_unset(si->hContact, "CList", "Hidden");
if (bInactive)
- chatApi.DoTrayIcon(si, gce);
+ g_chatApi.DoTrayIcon(si, gce);
if (bInactive || !g_Settings->bPopupInactiveOnly)
- chatApi.DoPopup(si, gce);
- if (chatApi.OnFlashHighlight)
- chatApi.OnFlashHighlight(si, bInactive);
+ g_chatApi.DoPopup(si, gce);
+ if (g_chatApi.OnFlashHighlight)
+ g_chatApi.OnFlashHighlight(si, bInactive);
return TRUE;
}
// do blinking icons in tray
if (bInactive || !g_Settings->bTrayIconInactiveOnly)
- chatApi.DoTrayIcon(si, gce);
+ g_chatApi.DoTrayIcon(si, gce);
// stupid thing to not create multiple popups for a QUIT event for instance
if (bManyFix == 0) {
// do popups
if (bInactive || !g_Settings->bPopupInactiveOnly)
- chatApi.DoPopup(si, gce);
+ g_chatApi.DoPopup(si, gce);
// do sounds and flashing
const char *szSound = nullptr;
@@ -333,8 +333,8 @@ BOOL DoSoundsFlashPopupTrayStuff(SESSION_INFO *si, GCEVENT *gce, BOOL bHighlight si->wState |= STATE_TALK;
db_set_w(si->hContact, si->pszModule, "ApparentMode", ID_STATUS_OFFLINE);
}
- if (chatApi.OnFlashWindow)
- chatApi.OnFlashWindow(si, bInactive);
+ if (g_chatApi.OnFlashWindow)
+ g_chatApi.OnFlashWindow(si, bInactive);
break;
}
@@ -413,7 +413,7 @@ BOOL LogToFile(SESSION_INFO *si, GCEVENT *gce) CreateDirectoryTreeW(tszFolder);
wchar_t szTime[100];
- mir_wstrncpy(szTime, chatApi.MakeTimeStamp(g_Settings->pszTimeStampLog, gce->time), 99);
+ mir_wstrncpy(szTime, g_chatApi.MakeTimeStamp(g_Settings->pszTimeStampLog, gce->time), 99);
FILE *hFile = _wfopen(si->pszLogFileName, L"ab+");
if (hFile == nullptr)
@@ -441,12 +441,12 @@ BOOL LogToFile(SESSION_INFO *si, GCEVENT *gce) case GC_EVENT_MESSAGE:
case GC_EVENT_MESSAGE | GC_EVENT_HIGHLIGHT:
p = '*';
- mir_snwprintf(szBuffer, L"%s: %s", gce->ptszNick, chatApi.RemoveFormatting(gce->ptszText));
+ mir_snwprintf(szBuffer, L"%s: %s", gce->ptszNick, g_chatApi.RemoveFormatting(gce->ptszText));
break;
case GC_EVENT_ACTION:
case GC_EVENT_ACTION | GC_EVENT_HIGHLIGHT:
p = '*';
- mir_snwprintf(szBuffer, L"%s %s", gce->ptszNick, chatApi.RemoveFormatting(gce->ptszText));
+ mir_snwprintf(szBuffer, L"%s %s", gce->ptszNick, g_chatApi.RemoveFormatting(gce->ptszText));
break;
case GC_EVENT_JOIN:
p = '>';
@@ -457,14 +457,14 @@ BOOL LogToFile(SESSION_INFO *si, GCEVENT *gce) if (!gce->ptszText)
mir_snwprintf(szBuffer, TranslateT("%s has left"), pszNick);
else
- mir_snwprintf(szBuffer, TranslateT("%s has left (%s)"), pszNick, chatApi.RemoveFormatting(gce->ptszText));
+ mir_snwprintf(szBuffer, TranslateT("%s has left (%s)"), pszNick, g_chatApi.RemoveFormatting(gce->ptszText));
break;
case GC_EVENT_QUIT:
p = '<';
if (!gce->ptszText)
mir_snwprintf(szBuffer, TranslateT("%s has disconnected"), pszNick);
else
- mir_snwprintf(szBuffer, TranslateT("%s has disconnected (%s)"), pszNick, chatApi.RemoveFormatting(gce->ptszText));
+ mir_snwprintf(szBuffer, TranslateT("%s has disconnected (%s)"), pszNick, g_chatApi.RemoveFormatting(gce->ptszText));
break;
case GC_EVENT_NICK:
p = '^';
@@ -475,22 +475,22 @@ BOOL LogToFile(SESSION_INFO *si, GCEVENT *gce) if (!gce->ptszText)
mir_snwprintf(szBuffer, TranslateT("%s kicked %s"), gce->ptszStatus, gce->ptszNick);
else
- mir_snwprintf(szBuffer, TranslateT("%s kicked %s (%s)"), gce->ptszStatus, gce->ptszNick, chatApi.RemoveFormatting(gce->ptszText));
+ mir_snwprintf(szBuffer, TranslateT("%s kicked %s (%s)"), gce->ptszStatus, gce->ptszNick, g_chatApi.RemoveFormatting(gce->ptszText));
break;
case GC_EVENT_NOTICE:
p = 'o';
- mir_snwprintf(szBuffer, TranslateT("Notice from %s: %s"), gce->ptszNick, chatApi.RemoveFormatting(gce->ptszText));
+ mir_snwprintf(szBuffer, TranslateT("Notice from %s: %s"), gce->ptszNick, g_chatApi.RemoveFormatting(gce->ptszText));
break;
case GC_EVENT_TOPIC:
p = '#';
if (!gce->ptszNick)
- mir_snwprintf(szBuffer, TranslateT("The topic is '%s'"), chatApi.RemoveFormatting(gce->ptszText));
+ mir_snwprintf(szBuffer, TranslateT("The topic is '%s'"), g_chatApi.RemoveFormatting(gce->ptszText));
else
- mir_snwprintf(szBuffer, TranslateT("The topic is '%s' (set by %s)"), chatApi.RemoveFormatting(gce->ptszText), gce->ptszNick);
+ mir_snwprintf(szBuffer, TranslateT("The topic is '%s' (set by %s)"), g_chatApi.RemoveFormatting(gce->ptszText), gce->ptszNick);
break;
case GC_EVENT_INFORMATION:
p = '!';
- wcsncpy_s(szBuffer, chatApi.RemoveFormatting(gce->ptszText), _TRUNCATE);
+ wcsncpy_s(szBuffer, g_chatApi.RemoveFormatting(gce->ptszText), _TRUNCATE);
break;
case GC_EVENT_ADDSTATUS:
p = '+';
@@ -613,7 +613,7 @@ wchar_t* GetChatLogsFilename(SESSION_INFO *si, time_t tTime) // check whether relevant parts of the timestamp have changed and
// we have to reparse the filename
- wchar_t *tszNow = chatApi.MakeTimeStamp(L"%a%d%m%Y", tTime); // once a day
+ wchar_t *tszNow = g_chatApi.MakeTimeStamp(L"%a%d%m%Y", tTime); // once a day
if (mir_wstrcmp(tszOldTimeStamp, tszNow)) {
wcsncpy_s(tszOldTimeStamp, tszNow, _TRUNCATE);
*si->pszLogFileName = 0;
@@ -622,34 +622,34 @@ wchar_t* GetChatLogsFilename(SESSION_INFO *si, time_t tTime) if (si->pszLogFileName[0] == 0) {
REPLACEVARSARRAY rva[11];
rva[0].key.w = L"d";
- rva[0].value.w = mir_wstrdup(chatApi.MakeTimeStamp(L"%#d", tTime));
+ rva[0].value.w = mir_wstrdup(g_chatApi.MakeTimeStamp(L"%#d", tTime));
// day 01-31
rva[1].key.w = L"dd";
- rva[1].value.w = mir_wstrdup(chatApi.MakeTimeStamp(L"%d", tTime));
+ rva[1].value.w = mir_wstrdup(g_chatApi.MakeTimeStamp(L"%d", tTime));
// month 1-12
rva[2].key.w = L"m";
- rva[2].value.w = mir_wstrdup(chatApi.MakeTimeStamp(L"%#m", tTime));
+ rva[2].value.w = mir_wstrdup(g_chatApi.MakeTimeStamp(L"%#m", tTime));
// month 01-12
rva[3].key.w = L"mm";
- rva[3].value.w = mir_wstrdup(chatApi.MakeTimeStamp(L"%m", tTime));
+ rva[3].value.w = mir_wstrdup(g_chatApi.MakeTimeStamp(L"%m", tTime));
// month text short
rva[4].key.w = L"mon";
- rva[4].value.w = mir_wstrdup(chatApi.MakeTimeStamp(L"%b", tTime));
+ rva[4].value.w = mir_wstrdup(g_chatApi.MakeTimeStamp(L"%b", tTime));
// month text
rva[5].key.w = L"month";
- rva[5].value.w = mir_wstrdup(chatApi.MakeTimeStamp(L"%B", tTime));
+ rva[5].value.w = mir_wstrdup(g_chatApi.MakeTimeStamp(L"%B", tTime));
// year 01-99
rva[6].key.w = L"yy";
- rva[6].value.w = mir_wstrdup(chatApi.MakeTimeStamp(L"%y", tTime));
+ rva[6].value.w = mir_wstrdup(g_chatApi.MakeTimeStamp(L"%y", tTime));
// year 1901-9999
rva[7].key.w = L"yyyy";
- rva[7].value.w = mir_wstrdup(chatApi.MakeTimeStamp(L"%Y", tTime));
+ rva[7].value.w = mir_wstrdup(g_chatApi.MakeTimeStamp(L"%Y", tTime));
// weekday short
rva[8].key.w = L"wday";
- rva[8].value.w = mir_wstrdup(chatApi.MakeTimeStamp(L"%a", tTime));
+ rva[8].value.w = mir_wstrdup(g_chatApi.MakeTimeStamp(L"%a", tTime));
// weekday
rva[9].key.w = L"weekday";
- rva[9].value.w = mir_wstrdup(chatApi.MakeTimeStamp(L"%A", tTime));
+ rva[9].value.w = mir_wstrdup(g_chatApi.MakeTimeStamp(L"%A", tTime));
// end of array
rva[10].key.w = nullptr;
rva[10].value.w = nullptr;
@@ -662,8 +662,8 @@ wchar_t* GetChatLogsFilename(SESSION_INFO *si, time_t tTime) else ptszVarPath = g_Settings->pszLogDir;
wchar_t *tszParsedName = Utils_ReplaceVarsW(ptszVarPath, si->hContact, rva);
- if (chatApi.OnGetLogName)
- chatApi.OnGetLogName(si, tszParsedName);
+ if (g_chatApi.OnGetLogName)
+ g_chatApi.OnGetLogName(si, tszParsedName);
else
PathToAbsoluteW(tszParsedName, si->pszLogFileName);
mir_free(tszParsedName);
diff --git a/src/mir_app/src/mir_app.def b/src/mir_app/src/mir_app.def index 80b82ab300..6c61e2026e 100644 --- a/src/mir_app/src/mir_app.def +++ b/src/mir_app/src/mir_app.def @@ -281,7 +281,7 @@ Profile_GetPathW @293 Profile_SetDefault @294
FindDatabasePlugin @296
RegisterDatabasePlugin @298
-Chat_GetInterface @299
+Chat_CustomizeApi @299
Chat_Event @300
Chat_GetInfo @301
Chat_NewSession @302
@@ -613,3 +613,4 @@ UnregisterPlugin @633 ?addFont@CMPluginBase@@QAEHPAUFontIDW@@@Z @642 NONAME
?addTTB@CMPluginBase@@QAEPAXPBUTTBButton@@@Z @643 NONAME
?g_CLI@@3UCLIST_INTERFACE@@A @644 NONAME
+?g_chatApi@@3UCHAT_MANAGER@@A @645 NONAME
diff --git a/src/mir_app/src/mir_app64.def b/src/mir_app/src/mir_app64.def index 2f15988949..c0b7131851 100644 --- a/src/mir_app/src/mir_app64.def +++ b/src/mir_app/src/mir_app64.def @@ -281,7 +281,7 @@ Profile_GetPathW @293 Profile_SetDefault @294
FindDatabasePlugin @296
RegisterDatabasePlugin @298
-Chat_GetInterface @299
+Chat_CustomizeApi @299
Chat_Event @300
Chat_GetInfo @301
Chat_NewSession @302
@@ -613,3 +613,4 @@ UnregisterPlugin @633 ?addFont@CMPluginBase@@QEAAHPEAUFontIDW@@@Z @642 NONAME
?addTTB@CMPluginBase@@QEAAPEAXPEBUTTBButton@@@Z @643 NONAME
?g_CLI@@3UCLIST_INTERFACE@@A @644 NONAME
+?g_chatApi@@3UCHAT_MANAGER@@A @645 NONAME
diff --git a/src/mir_app/src/miranda.h b/src/mir_app/src/miranda.h index d49ebbab17..3798094951 100644 --- a/src/mir_app/src/miranda.h +++ b/src/mir_app/src/miranda.h @@ -48,10 +48,6 @@ typedef HRESULT (STDAPICALLTYPE *pfnDwmIsCompositionEnabled)(BOOL *); extern pfnDwmExtendFrameIntoClientArea dwmExtendFrameIntoClientArea;
extern pfnDwmIsCompositionEnabled dwmIsCompositionEnabled;
-/**** chat.cpp *************************************************************************/
-
-extern struct CHAT_MANAGER chatApi;
-
/**** database.cpp *********************************************************************/
extern MDatabaseCommon *currDb;
diff --git a/src/mir_app/src/srmm_base.cpp b/src/mir_app/src/srmm_base.cpp index c5ec59056b..b189320ce3 100644 --- a/src/mir_app/src/srmm_base.cpp +++ b/src/mir_app/src/srmm_base.cpp @@ -66,7 +66,7 @@ CSrmmBaseDialog::CSrmmBaseDialog(CMPluginBase &pPlugin, int idDialog, SESSION_IN if (si) { m_hContact = si->hContact; - MODULEINFO *mi = chatApi.MM_FindModule(si->pszModule); + MODULEINFO *mi = g_chatApi.MM_FindModule(si->pszModule); if (mi != nullptr) { if (mi->bColor) { m_iFG = 4; @@ -256,7 +256,7 @@ LRESULT CSrmmBaseDialog::WndProc_Log(UINT msg, WPARAM wParam, LPARAM lParam) case IDM_CLEAR: m_log.SetText(L""); - chatApi.LM_RemoveAll(&m_si->pLog, &m_si->pLogEnd); + g_chatApi.LM_RemoveAll(&m_si->pLog, &m_si->pLogEnd); m_si->iEventCount = 0; m_si->LastTime = 0; PostMessage(m_hwnd, WM_MOUSEACTIVATE, 0, 0); @@ -425,7 +425,7 @@ static void ProcessNickListHovering(HWND hwnd, int hoveredItem, SESSION_INFO *pa CMStringW wszBuf; - USERINFO *ui1 = chatApi.SM_GetUserFromIndex(parentdat->ptszID, parentdat->pszModule, currentHovered); + USERINFO *ui1 = g_chatApi.SM_GetUserFromIndex(parentdat->ptszID, parentdat->pszModule, currentHovered); if (ui1) { if (ProtoServiceExists(parentdat->pszModule, MS_GC_PROTO_GETTOOLTIPTEXT)) { wchar_t *p = (wchar_t*)CallProtoService(parentdat->pszModule, MS_GC_PROTO_GETTOOLTIPTEXT, (WPARAM)parentdat->ptszID, (LPARAM)ui1->pszUID); @@ -439,7 +439,7 @@ static void ProcessNickListHovering(HWND hwnd, int hoveredItem, SESSION_INFO *pa wszBuf.Format(L"%s: %s\r\n%s: %s\r\n%s: %s", TranslateT("Nickname"), ui1->pszNick, TranslateT("Unique ID"), ui1->pszUID, - TranslateT("Status"), chatApi.TM_WordToString(parentdat->pStatuses, ui1->Status)); + TranslateT("Status"), g_chatApi.TM_WordToString(parentdat->pStatuses, ui1->Status)); ti.lpszText = wszBuf.GetBuffer(); } @@ -466,7 +466,7 @@ static void CALLBACK ChatTimerProc(HWND hwnd, UINT, UINT_PTR idEvent, DWORD) return; } - USERINFO *ui1 = chatApi.SM_GetUserFromIndex(si->ptszID, si->pszModule, si->currentHovered); + USERINFO *ui1 = g_chatApi.SM_GetUserFromIndex(si->ptszID, si->pszModule, si->currentHovered); if (ui1) { CMStringW wszBuf; if (ProtoServiceExists(si->pszModule, MS_GC_PROTO_GETTOOLTIPTEXT)) { @@ -480,7 +480,7 @@ static void CALLBACK ChatTimerProc(HWND hwnd, UINT, UINT_PTR idEvent, DWORD) wszBuf.Format(L"<b>%s:</b>\t%s\n<b>%s:</b>\t%s\n<b>%s:</b>\t%s", TranslateT("Nick"), ui1->pszNick, TranslateT("Unique ID"), ui1->pszUID, - TranslateT("Status"), chatApi.TM_WordToString(si->pStatuses, ui1->Status)); + TranslateT("Status"), g_chatApi.TM_WordToString(si->pStatuses, ui1->Status)); CLCINFOTIP ti = { sizeof(ti) }; if (CallService("mToolTip/ShowTipW", (WPARAM)wszBuf.c_str(), (LPARAM)&ti)) @@ -591,7 +591,7 @@ LRESULT CSrmmBaseDialog::WndProc_Nicklist(UINT msg, WPARAM wParam, LPARAM lParam int items = m_si->nUsersInNicklist - index; if (rc.bottom - rc.top > items * height) { rc.top = items * height; - FillRect(dc, &rc, chatApi.hListBkgBrush); + FillRect(dc, &rc, g_chatApi.hListBkgBrush); } } return 1; @@ -612,7 +612,7 @@ LRESULT CSrmmBaseDialog::WndProc_Nicklist(UINT msg, WPARAM wParam, LPARAM lParam else ScreenToClient(m_nickList.GetHwnd(), &pt); int item = LOWORD(m_nickList.SendMsg(LB_ITEMFROMPOINT, 0, MAKELPARAM(pt.x, pt.y))); - USERINFO *ui = chatApi.SM_GetUserFromIndex(m_si->ptszID, m_si->pszModule, item); + USERINFO *ui = g_chatApi.SM_GetUserFromIndex(m_si->ptszID, m_si->pszModule, item); if (ui != nullptr) { if (pt.x == -1 && pt.y == -1) pt.y += height - 4; @@ -844,9 +844,9 @@ void CSrmmBaseDialog::onClick_History(CCtrlButton *pButton) return; if (m_si != nullptr) { - MODULEINFO *pInfo = chatApi.MM_FindModule(m_si->pszModule); + MODULEINFO *pInfo = g_chatApi.MM_FindModule(m_si->pszModule); if (pInfo) - ShellExecute(m_hwnd, nullptr, chatApi.GetChatLogsFilename(m_si, 0), nullptr, nullptr, SW_SHOW); + ShellExecute(m_hwnd, nullptr, g_chatApi.GetChatLogsFilename(m_si, 0), nullptr, nullptr, SW_SHOW); } else CallService(MS_HISTORY_SHOWCONTACTHISTORY, m_hContact, 0); } @@ -865,7 +865,7 @@ void CSrmmBaseDialog::onDblClick_List(CCtrlListBox *pList) ScreenToClient(pList->GetHwnd(), &hti.pt); int item = LOWORD(pList->SendMsg(LB_ITEMFROMPOINT, 0, MAKELPARAM(hti.pt.x, hti.pt.y))); - USERINFO *ui = chatApi.UM_FindUserFromIndex(m_si->pUsers, item); + USERINFO *ui = g_chatApi.UM_FindUserFromIndex(m_si->pUsers, item); if (ui == nullptr) return; @@ -967,7 +967,7 @@ void CSrmmBaseDialog::RefreshButtonStatus(void) cf.dwMask = CFM_BOLD | CFM_ITALIC | CFM_UNDERLINE | CFM_BACKCOLOR | CFM_COLOR; m_message.SendMsg(EM_GETCHARFORMAT, SCF_SELECTION, (LPARAM)&cf); - MODULEINFO *mi = chatApi.MM_FindModule(m_si->pszModule); + MODULEINFO *mi = g_chatApi.MM_FindModule(m_si->pszModule); if (mi == nullptr) return; diff --git a/src/mir_app/src/srmm_util.cpp b/src/mir_app/src/srmm_util.cpp index ab5b9a1ae1..0cf6bd4b0c 100644 --- a/src/mir_app/src/srmm_util.cpp +++ b/src/mir_app/src/srmm_util.cpp @@ -33,7 +33,7 @@ MIR_APP_DLL(DWORD) CALLBACK Srmm_LogStreamCallback(DWORD_PTR dwCookie, LPBYTE pb // create the RTF if (lstrdat->buffer == nullptr) { lstrdat->bufferOffset = 0; - lstrdat->buffer = chatApi.Log_CreateRTF(lstrdat); + lstrdat->buffer = g_chatApi.Log_CreateRTF(lstrdat); lstrdat->bufferLen = (int)mir_strlen(lstrdat->buffer); } |