diff options
author | George Hazan <ghazan@miranda.im> | 2018-03-13 22:25:26 +0300 |
---|---|---|
committer | George Hazan <ghazan@miranda.im> | 2018-03-13 22:25:26 +0300 |
commit | 1202cf04c667c72fb30bd01608585283b9cc1914 (patch) | |
tree | f48627e3269cbde16d08d8ac37359647141f6e59 | |
parent | 25c7aab043ce803362898d211319ebac4474af4e (diff) |
chat engine:
- fixes #1174 (Group chat icons became "blank exe" icons if role cound exceeds 10);
- unused chat api members removed;
-rw-r--r-- | include/m_chat.h | 2 | ||||
-rw-r--r-- | include/m_chat_int.h | 6 | ||||
-rw-r--r-- | libs/win32/mir_app.lib | bin | 130624 -> 130624 bytes | |||
-rw-r--r-- | plugins/Scriver/src/chat_manager.cpp | 23 | ||||
-rw-r--r-- | plugins/TabSRMM/src/chat_tools.cpp | 6 | ||||
-rw-r--r-- | src/mir_app/src/chat.h | 3 | ||||
-rw-r--r-- | src/mir_app/src/chat_manager.cpp | 42 | ||||
-rw-r--r-- | src/mir_app/src/chat_svc.cpp | 17 |
8 files changed, 40 insertions, 59 deletions
diff --git a/include/m_chat.h b/include/m_chat.h index e5fa914151..c302e1e5b5 100644 --- a/include/m_chat.h +++ b/include/m_chat.h @@ -372,7 +372,7 @@ EXTERN_C MIR_APP_DLL(int) Chat_Event(GCEVENT*); EXTERN_C MIR_APP_DLL(void*) Chat_GetUserInfo(const char *szModule, const wchar_t *wszId);
EXTERN_C MIR_APP_DLL(int) Chat_SetUserInfo(const char *szModule, const wchar_t *wszId, void *pItemData);
-EXTERN_C MIR_APP_DLL(int) Chat_AddGroup(const char *szModule, const wchar_t *wszId, const wchar_t *wszText, HICON hIcon = nullptr);
+EXTERN_C MIR_APP_DLL(int) Chat_AddGroup(const char *szModule, const wchar_t *wszId, const wchar_t *wszText);
EXTERN_C MIR_APP_DLL(int) Chat_ChangeSessionName(const char *szModule, const wchar_t *wszId, const wchar_t *wszNewName);
EXTERN_C MIR_APP_DLL(int) Chat_ChangeUserId(const char *szModule, const wchar_t *wszId, const wchar_t *wszOldId, const wchar_t *wszNewId);
EXTERN_C MIR_APP_DLL(int) Chat_SendUserMessage(const char *szModule, const wchar_t *wszId, const wchar_t *wszText);
diff --git a/include/m_chat_int.h b/include/m_chat_int.h index f90c7082a9..f3168a7fba 100644 --- a/include/m_chat_int.h +++ b/include/m_chat_int.h @@ -126,8 +126,8 @@ struct LOGINFO struct STATUSINFO
{
wchar_t *pszGroup;
- HICON hIcon;
- WORD Status;
+ int iIconIndex;
+ int iStatus;
STATUSINFO *next;
};
@@ -276,9 +276,7 @@ struct CHAT_MANAGER void (*MM_IconsChanged)(void);
BOOL (*MM_RemoveAll)(void);
- STATUSINFO* (*TM_AddStatus)(STATUSINFO **ppStatusList, const wchar_t *pszStatus, int* iCount);
STATUSINFO* (*TM_FindStatus)(STATUSINFO *pStatusList, const wchar_t *pszStatus);
- WORD (*TM_StringToWord)(STATUSINFO *pStatusList, const wchar_t *pszStatus);
wchar_t* (*TM_WordToString)(STATUSINFO *pStatusList, WORD Status);
BOOL (*TM_RemoveAll)(STATUSINFO** pStatusList);
diff --git a/libs/win32/mir_app.lib b/libs/win32/mir_app.lib Binary files differindex e98e8153b9..4333d58e28 100644 --- a/libs/win32/mir_app.lib +++ b/libs/win32/mir_app.lib diff --git a/plugins/Scriver/src/chat_manager.cpp b/plugins/Scriver/src/chat_manager.cpp index 0995b28b74..0bfadfeb7e 100644 --- a/plugins/Scriver/src/chat_manager.cpp +++ b/plugins/Scriver/src/chat_manager.cpp @@ -52,23 +52,14 @@ char SM_GetStatusIndicator(SESSION_INFO *si, USERINFO *ui) STATUSINFO *ti = pci->TM_FindStatus(si->pStatuses, pci->TM_WordToString(si->pStatuses, ui->Status));
if (ti) {
- if ((INT_PTR)ti->hIcon < STATUSICONCOUNT) {
- INT_PTR id = si->iStatusCount - (INT_PTR)ti->hIcon - 1;
- if (id == 0)
- return '\0';
- if (id == 1)
- return '+';
- if (id == 2)
- return '%';
- if (id == 3)
- return '@';
- if (id == 4)
- return '!';
- if (id == 5)
- return '*';
+ switch (si->iStatusCount - ti->iIconIndex - 1) {
+ case 0: return '\0';
+ case 1: return '+';
+ case 2: return '%';
+ case 3: return '@';
+ case 4: return '!';
+ case 5: return '*';
}
- else
- return '\0';
}
return '\0';
}
diff --git a/plugins/TabSRMM/src/chat_tools.cpp b/plugins/TabSRMM/src/chat_tools.cpp index bde0070409..333b857f17 100644 --- a/plugins/TabSRMM/src/chat_tools.cpp +++ b/plugins/TabSRMM/src/chat_tools.cpp @@ -538,10 +538,10 @@ char GetIndicator(SESSION_INFO *si, LPCTSTR ptszNick, int *iNickIndex) for (USERINFO *ui = si->pUsers; ui; ui = ui->next) {
if (!mir_wstrcmp(ui->pszNick, ptszNick)) {
STATUSINFO *ti = pci->TM_FindStatus(si->pStatuses, pci->TM_WordToString(si->pStatuses, ui->Status));
- if (ti && (INT_PTR)ti->hIcon < si->iStatusCount) {
+ if (ti) {
if (iNickIndex)
- *iNickIndex = (INT_PTR)ti->hIcon; // color table's index is not zero-based
- return szIndicators[(INT_PTR)ti->hIcon];
+ *iNickIndex = ti->iIconIndex; // color table's index is not zero-based
+ return szIndicators[ti->iIconIndex];
}
break;
}
diff --git a/src/mir_app/src/chat.h b/src/mir_app/src/chat.h index 69ee4bde3e..fbb6fcf539 100644 --- a/src/mir_app/src/chat.h +++ b/src/mir_app/src/chat.h @@ -76,6 +76,9 @@ BOOL SM_TakeStatus(const wchar_t *pszID, const char *pszModule, const wchar_ SESSION_INFO* SM_FindSession(const wchar_t *pszID, const char *pszModule);
+STATUSINFO* TM_AddStatus(STATUSINFO **ppStatusList, const wchar_t *pszStatus, int *iCount);
+WORD TM_StringToWord(STATUSINFO *pStatusList, const wchar_t *pszStatus);
+
// 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);
diff --git a/src/mir_app/src/chat_manager.cpp b/src/mir_app/src/chat_manager.cpp index 64e206bcc6..17a34ec221 100644 --- a/src/mir_app/src/chat_manager.cpp +++ b/src/mir_app/src/chat_manager.cpp @@ -188,12 +188,9 @@ static HICON SM_GetStatusIcon(SESSION_INFO *si, USERINFO *ui) return nullptr;
STATUSINFO *ti = chatApi.TM_FindStatus(si->pStatuses, chatApi.TM_WordToString(si->pStatuses, ui->Status));
- if (ti != nullptr) {
- if ((UINT_PTR)ti->hIcon >= STATUSICONCOUNT)
- return ti->hIcon;
-
- return chatApi.hIcons[ICON_STATUS0 + (INT_PTR)ti->hIcon];
- }
+ if (ti != nullptr)
+ return chatApi.hIcons[ICON_STATUS0 + ti->iIconIndex];
+
return chatApi.hIcons[ICON_STATUS0];
}
@@ -280,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, chatApi.TM_StringToWord(si->pStatuses, pszStatus));
+ USERINFO *ui = chatApi.UM_GiveStatus(si->pUsers, pszUID, TM_StringToWord(si->pStatuses, pszStatus));
if (ui) {
SM_MoveUser(si->ptszID, si->pszModule, ui->pszUID);
if (si->pDlg)
@@ -310,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, chatApi.TM_StringToWord(si->pStatuses, pszStatus));
+ USERINFO *ui = chatApi.UM_TakeStatus(si->pUsers, pszUID, TM_StringToWord(si->pStatuses, pszStatus));
if (ui) {
SM_MoveUser(si->ptszID, si->pszModule, ui->pszUID);
if (si->pDlg)
@@ -590,26 +587,25 @@ static BOOL MM_RemoveAll(void) // Status manager functions
// Necessary to keep track of what user statuses per window nicklist that is available
-static STATUSINFO* TM_AddStatus(STATUSINFO **ppStatusList, const wchar_t *pszStatus, int *iCount)
+STATUSINFO* TM_AddStatus(STATUSINFO **ppStatusList, const wchar_t *pszStatus, int *iCount)
{
if (!ppStatusList || !pszStatus)
return nullptr;
if (!chatApi.TM_FindStatus(*ppStatusList, pszStatus)) {
- STATUSINFO *node = (STATUSINFO*)mir_alloc(sizeof(STATUSINFO));
- memset(node, 0, sizeof(STATUSINFO));
+ STATUSINFO *node = (STATUSINFO*)mir_calloc(sizeof(STATUSINFO));
replaceStrW(node->pszGroup, pszStatus);
- node->hIcon = (HICON)(*iCount);
- while ((INT_PTR)node->hIcon > STATUSICONCOUNT - 1)
- node->hIcon--;
+ node->iIconIndex = *iCount;
+ while (node->iIconIndex > STATUSICONCOUNT - 1)
+ node->iIconIndex--;
if (*ppStatusList == nullptr) { // list is empty
- node->Status = 1;
+ node->iStatus = 1;
*ppStatusList = node;
node->next = nullptr;
}
else {
- node->Status = ppStatusList[0]->Status * 2;
+ node->iStatus = ppStatusList[0]->iStatus * 2;
node->next = *ppStatusList;
*ppStatusList = node;
}
@@ -631,17 +627,17 @@ static STATUSINFO* TM_FindStatus(STATUSINFO *pStatusList, const wchar_t *pszStat return nullptr;
}
-static WORD TM_StringToWord(STATUSINFO *pStatusList, const wchar_t *pszStatus)
+WORD TM_StringToWord(STATUSINFO *pStatusList, const wchar_t *pszStatus)
{
if (!pStatusList || !pszStatus)
return 0;
for (STATUSINFO *pTemp = pStatusList; pTemp != nullptr; pTemp = pTemp->next) {
if (mir_wstrcmpi(pTemp->pszGroup, pszStatus) == 0)
- return pTemp->Status;
+ return pTemp->iStatus;
if (pTemp->next == nullptr)
- return pStatusList->Status;
+ return pStatusList->iStatus;
}
return 0;
}
@@ -652,8 +648,8 @@ static wchar_t* TM_WordToString(STATUSINFO *pStatusList, WORD Status) return nullptr;
for (STATUSINFO *pTemp = pStatusList; pTemp != nullptr; pTemp = pTemp->next) {
- if (pTemp->Status & Status) {
- Status -= pTemp->Status;
+ if (pTemp->iStatus & Status) {
+ Status -= pTemp->iStatus;
if (Status == 0)
return pTemp->pszGroup;
}
@@ -669,8 +665,6 @@ static BOOL TM_RemoveAll(STATUSINFO **ppStatusList) while (*ppStatusList != nullptr) {
STATUSINFO *pLast = ppStatusList[0]->next;
mir_free(ppStatusList[0]->pszGroup);
- if ((INT_PTR)ppStatusList[0]->hIcon > 10)
- DestroyIcon(ppStatusList[0]->hIcon);
mir_free(*ppStatusList);
*ppStatusList = pLast;
}
@@ -1035,9 +1029,7 @@ MIR_APP_DLL(CHAT_MANAGER*) Chat_GetInterface(CHAT_MANAGER_INITDATA *pInit, int _ chatApi.MM_IconsChanged = MM_IconsChanged;
chatApi.MM_RemoveAll = MM_RemoveAll;
- chatApi.TM_AddStatus = TM_AddStatus;
chatApi.TM_FindStatus = TM_FindStatus;
- chatApi.TM_StringToWord = TM_StringToWord;
chatApi.TM_WordToString = TM_WordToString;
chatApi.TM_RemoveAll = TM_RemoveAll;
diff --git a/src/mir_app/src/chat_svc.cpp b/src/mir_app/src/chat_svc.cpp index 7b70998612..a6e17cb81b 100644 --- a/src/mir_app/src/chat_svc.cpp +++ b/src/mir_app/src/chat_svc.cpp @@ -261,8 +261,8 @@ static void SetInitDone(SESSION_INFO *si) si->bInitDone = true;
for (STATUSINFO *p = si->pStatuses; p; p = p->next)
- if ((UINT_PTR)p->hIcon < STATUSICONCOUNT)
- p->hIcon = HICON(si->iStatusCount - (INT_PTR)p->hIcon - 1);
+ if (p->iIconIndex < STATUSICONCOUNT)
+ p->iIconIndex = si->iStatusCount - p->iIconIndex - 1;
}
static INT_PTR __stdcall stubRoomControl(void *param)
@@ -369,7 +369,7 @@ static void AddUser(GCEVENT *gce) if (si == nullptr)
return;
- WORD status = chatApi.TM_StringToWord(si->pStatuses, gce->ptszStatus);
+ WORD status = TM_StringToWord(si->pStatuses, gce->ptszStatus);
USERINFO *ui = chatApi.UM_AddUser(si->pStatuses, &si->pUsers, gce->ptszUID, gce->ptszNick, status);
if (ui == nullptr)
@@ -383,7 +383,7 @@ static void AddUser(GCEVENT *gce) if (gce->bIsMe)
si->pMe = ui;
ui->Status = status;
- ui->Status |= si->pStatuses->Status;
+ ui->Status |= si->pStatuses->iStatus;
if (si->pDlg)
si->pDlg->UpdateNickList();
@@ -579,7 +579,7 @@ EXTERN_C MIR_APP_DLL(int) Chat_Event(GCEVENT *gce) /////////////////////////////////////////////////////////////////////////////////////////
// chat control functions
-MIR_APP_DLL(int) Chat_AddGroup(const char *szModule, const wchar_t *wszId, const wchar_t *wszText, HICON hIcon)
+MIR_APP_DLL(int) Chat_AddGroup(const char *szModule, const wchar_t *wszId, const wchar_t *wszText)
{
if (wszText == nullptr)
return GC_EVENT_ERROR;
@@ -589,12 +589,9 @@ MIR_APP_DLL(int) Chat_AddGroup(const char *szModule, const wchar_t *wszId, const if (si == nullptr)
return 0;
- STATUSINFO *ti = chatApi.TM_AddStatus(&si->pStatuses, wszText, &si->iStatusCount);
- if (ti) {
+ STATUSINFO *ti = TM_AddStatus(&si->pStatuses, wszText, &si->iStatusCount);
+ if (ti)
si->iStatusCount++;
- if (hIcon)
- ti->hIcon = CopyIcon(hIcon);
- }
if (chatApi.OnAddStatus)
chatApi.OnAddStatus(si, ti);
|