diff options
author | George Hazan <george.hazan@gmail.com> | 2024-10-14 14:46:11 +0300 |
---|---|---|
committer | George Hazan <george.hazan@gmail.com> | 2024-10-14 14:46:11 +0300 |
commit | b05ce4acd28f460336dc33d32e5dd503574da29c (patch) | |
tree | 53e8b13a29be6c85345dde764e88fc57c7970c55 | |
parent | c93680973f803dde52de0669d05671ea4afe0cb3 (diff) |
code cleaning
-rw-r--r-- | include/m_chat_int.h | 3 | ||||
-rw-r--r-- | src/mir_app/src/chat.h | 4 | ||||
-rw-r--r-- | src/mir_app/src/chat_clist.cpp | 8 | ||||
-rw-r--r-- | src/mir_app/src/chat_manager.cpp | 7 | ||||
-rw-r--r-- | src/mir_app/src/chat_svc.cpp | 4 | ||||
-rw-r--r-- | src/mir_app/src/clc.cpp | 2 | ||||
-rw-r--r-- | src/mir_app/src/clcitems.cpp | 2 | ||||
-rw-r--r-- | src/mir_app/src/ei_defaulticons.cpp | 21 |
8 files changed, 22 insertions, 29 deletions
diff --git a/include/m_chat_int.h b/include/m_chat_int.h index 599218c258..c05b4599cc 100644 --- a/include/m_chat_int.h +++ b/include/m_chat_int.h @@ -291,9 +291,6 @@ struct CHAT_MANAGER USERINFO* (*UM_TakeStatus)(SESSION_INFO *si, const wchar_t *pszUID, uint16_t status);
wchar_t* (*UM_FindUserAutoComplete)(SESSION_INFO *si, const wchar_t* pszOriginal, const wchar_t* pszCurrent);
- BOOL (*SetOffline)(MCONTACT hContact, BOOL bHide);
- BOOL (*SetAllOffline)(BOOL bHide, const char *pszModule);
-
void (*LoadMsgDlgFont)(int i, LOGFONT *lf, COLORREF *color);
wchar_t* (*MakeTimeStamp)(wchar_t *pszStamp, time_t time);
diff --git a/src/mir_app/src/chat.h b/src/mir_app/src/chat.h index 84e9be92d9..2f620c2e56 100644 --- a/src/mir_app/src/chat.h +++ b/src/mir_app/src/chat.h @@ -98,8 +98,8 @@ void UM_SortKeys(SESSION_INFO *si); // clist.c
MCONTACT AddRoom(const char *pszModule, const wchar_t *pszRoom, const wchar_t *pszDisplayName, int iType);
-BOOL SetAllOffline(BOOL bHide, const char *pszModule);
-BOOL SetOffline(MCONTACT hContact, BOOL bHide);
+BOOL SetAllOffline(const char *pszModule);
+BOOL SetOffline(MCONTACT hContact);
int RoomDoubleclicked(WPARAM wParam,LPARAM lParam);
diff --git a/src/mir_app/src/chat_clist.cpp b/src/mir_app/src/chat_clist.cpp index 7c84b57d28..6e90497932 100644 --- a/src/mir_app/src/chat_clist.cpp +++ b/src/mir_app/src/chat_clist.cpp @@ -88,11 +88,11 @@ MCONTACT AddRoom(const char *pszModule, const wchar_t *pszRoom, const wchar_t *p return hContact;
}
-BOOL SetOffline(MCONTACT hContact, BOOL)
+BOOL SetOffline(MCONTACT hContact)
{
if (hContact) {
char *szProto = Proto_GetBaseAccountName(hContact);
- db_set_w(hContact, szProto, "ApparentMode", 0);
+ db_unset(hContact, szProto, "ApparentMode");
db_set_w(hContact, szProto, "Status", ID_STATUS_OFFLINE);
return TRUE;
}
@@ -100,7 +100,7 @@ BOOL SetOffline(MCONTACT hContact, BOOL) return FALSE;
}
-BOOL SetAllOffline(BOOL, const char *pszModule)
+BOOL SetAllOffline(const char *pszModule)
{
for (auto &hContact : Contacts(pszModule)) {
char *szProto = Proto_GetBaseAccountName(hContact);
@@ -108,7 +108,7 @@ BOOL SetAllOffline(BOOL, const char *pszModule) continue;
if (Contact::IsGroupChat(hContact, szProto)) {
- db_set_w(hContact, szProto, "ApparentMode", 0);
+ db_unset(hContact, szProto, "ApparentMode");
db_set_w(hContact, szProto, "Status", ID_STATUS_OFFLINE);
}
}
diff --git a/src/mir_app/src/chat_manager.cpp b/src/mir_app/src/chat_manager.cpp index cf3dcfba39..700e48c14f 100644 --- a/src/mir_app/src/chat_manager.cpp +++ b/src/mir_app/src/chat_manager.cpp @@ -108,7 +108,7 @@ void SM_FreeSession(SESSION_INFO *si) if (Clist_GetEvent(si->hContact, 0))
Clist_RemoveEvent(si->hContact, GC_FAKE_EVENT);
si->wState &= ~STATE_TALK;
- db_set_w(si->hContact, si->pszModule, "ApparentMode", 0);
+ db_unset(si->hContact, si->pszModule, "ApparentMode");
if (si->pDlg)
si->pDlg->CloseTab();
@@ -118,7 +118,7 @@ void SM_FreeSession(SESSION_INFO *si) // 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 && Contact::IsGroupChat(si->hContact, si->pszModule)) {
- g_chatApi.SetOffline(si->hContact, (si->iType == GCW_CHATROOM || si->iType == GCW_PRIVMESS) ? TRUE : FALSE);
+ SetOffline(si->hContact);
db_set_s(si->hContact, si->pszModule, "Topic", "");
db_set_s(si->hContact, si->pszModule, "StatusBar", "");
db_unset(si->hContact, "CList", "StatusMsg");
@@ -772,9 +772,6 @@ static void ResetApi() g_chatApi.UM_TakeStatus = ::UM_TakeStatus;
g_chatApi.UM_FindUserAutoComplete = ::UM_FindUserAutoComplete;
- g_chatApi.SetOffline = ::SetOffline;
- g_chatApi.SetAllOffline = ::SetAllOffline;
-
g_chatApi.LoadMsgDlgFont = ::LoadMsgDlgFont;
g_chatApi.MakeTimeStamp = ::MakeTimeStamp;
diff --git a/src/mir_app/src/chat_svc.cpp b/src/mir_app/src/chat_svc.cpp index ec7b44be06..3387d9d7b9 100644 --- a/src/mir_app/src/chat_svc.cpp +++ b/src/mir_app/src/chat_svc.cpp @@ -186,7 +186,7 @@ MIR_APP_DLL(int) Chat_Register(const GCREGISTER *gcr) mi->bPersistent = (gcr->dwFlags & GC_PERSISTENT) != 0;
mi->iMaxText = gcr->iMaxText;
- g_chatApi.SetAllOffline(TRUE, gcr->pszModule);
+ SetAllOffline(gcr->pszModule);
return 0;
}
@@ -985,7 +985,7 @@ static int ModulesLoaded(WPARAM, LPARAM) hMute2MenuItem = Menu_AddContactMenuItem(&mi);
Menu_ConfigureItem(hMute2MenuItem, MCI_OPT_EXECPARAM, INT_PTR(CHATMODE_UNMUTE));
- g_chatApi.SetAllOffline(TRUE, nullptr);
+ SetAllOffline(nullptr);
return 0;
}
diff --git a/src/mir_app/src/clc.cpp b/src/mir_app/src/clc.cpp index 90b8b56232..7b6cce41e8 100644 --- a/src/mir_app/src/clc.cpp +++ b/src/mir_app/src/clc.cpp @@ -550,7 +550,7 @@ LRESULT CALLBACK fnContactListControlWndProc(HWND hwnd, UINT uMsg, WPARAM wParam if (szProto == nullptr)
break;
- uint16_t apparentMode = db_get_w(wParam, szProto, "ApparentMode", 0);
+ uint16_t apparentMode = db_get_w(wParam, szProto, "ApparentMode");
contact->flags &= ~(CONTACTF_INVISTO | CONTACTF_VISTO);
if (apparentMode == ID_STATUS_OFFLINE)
contact->flags |= CONTACTF_INVISTO;
diff --git a/src/mir_app/src/clcitems.cpp b/src/mir_app/src/clcitems.cpp index 48483f3c72..a37efdeefe 100644 --- a/src/mir_app/src/clcitems.cpp +++ b/src/mir_app/src/clcitems.cpp @@ -195,7 +195,7 @@ ClcContact* fnAddContactToGroup(ClcData *dat, ClcGroup *group, MCONTACT hContact cc->pce = pce;
if (szProto != nullptr && !Clist_IsHiddenMode(dat, db_get_w(hContact, szProto, "Status", ID_STATUS_OFFLINE)))
cc->flags |= CONTACTF_ONLINE;
- uint16_t apparentMode = szProto != nullptr ? db_get_w(hContact, szProto, "ApparentMode", 0) : 0;
+ uint16_t apparentMode = szProto != nullptr ? db_get_w(hContact, szProto, "ApparentMode") : 0;
if (apparentMode == ID_STATUS_OFFLINE)
cc->flags |= CONTACTF_INVISTO;
else if (apparentMode == ID_STATUS_ONLINE)
diff --git a/src/mir_app/src/ei_defaulticons.cpp b/src/mir_app/src/ei_defaulticons.cpp index dea63a7409..6f503644f5 100644 --- a/src/mir_app/src/ei_defaulticons.cpp +++ b/src/mir_app/src/ei_defaulticons.cpp @@ -41,19 +41,18 @@ static void SetVisibility(MCONTACT hContact, int apparentMode, bool clear) return;
if (apparentMode <= 0)
- apparentMode = db_get_w(hContact, proto, "ApparentMode", 0);
+ apparentMode = db_get_w(hContact, proto, "ApparentMode");
- HANDLE hExtraIcon = nullptr, hIcolib = nullptr;
+ HANDLE hIcolib = nullptr;
// Is chat
if (Contact::IsGroupChat(hContact, proto)) {
- hExtraIcon = hExtraChat;
if (apparentMode == ID_STATUS_OFFLINE)
- hIcolib = IcoLib_GetIconHandle("ChatActivity");
+ hIcolib = g_plugin.getIconHandle(IDI_CHAT);
}
if (hIcolib != nullptr || clear)
- ExtraIcon_SetIcon(hExtraIcon, hContact, hIcolib);
+ ExtraIcon_SetIcon(hExtraChat, hContact, hIcolib);
}
static void SetGender(MCONTACT hContact, int gender, bool clear)
@@ -70,16 +69,16 @@ static void SetGender(MCONTACT hContact, int gender, bool clear) if (gender <= 0)
gender = db_get_b(hContact, "UserInfo", "Gender", 0);
- const char *ico;
+ HANDLE hIcolib;
if (gender == 'M')
- ico = "gender_male";
+ hIcolib = g_plugin.getIconHandle(IDI_MALE);
else if (gender == 'F')
- ico = "gender_female";
+ hIcolib = g_plugin.getIconHandle(IDI_FEMALE);
else
- ico = nullptr;
+ hIcolib = nullptr;
- if (ico != nullptr || clear)
- ExtraIcon_SetIconByName(hExtraGender, hContact, ico);
+ if (hIcolib != nullptr || clear)
+ ExtraIcon_SetIcon(hExtraGender, hContact, hIcolib);
}
static void SetChatMute(MCONTACT hContact, int mode)
|