From f3ff9ad5341bb0b0a0453e61a2d419e8c02f14b0 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Thu, 9 Mar 2017 20:45:04 +0300 Subject: cosmetic fixes --- src/mir_app/src/chat_log.cpp | 18 +-- src/mir_app/src/chat_manager.cpp | 234 +++++++++++++++++++-------------------- src/mir_app/src/chat_svc.cpp | 98 ++++++++-------- 3 files changed, 175 insertions(+), 175 deletions(-) (limited to 'src/mir_app') diff --git a/src/mir_app/src/chat_log.cpp b/src/mir_app/src/chat_log.cpp index 2a7ab9234f..d60428a28b 100644 --- a/src/mir_app/src/chat_log.cpp +++ b/src/mir_app/src/chat_log.cpp @@ -194,7 +194,7 @@ static void AddEventToBuffer(CMStringA &buf, LOGSTREAMDATA *streamData) LOGINFO *lin = streamData->lin; wchar_t szTemp[512], szTemp2[512]; - wchar_t* pszNick = NULL; + wchar_t* pszNick = nullptr; if (lin->ptszNick) { if (g_Settings->bLogLimitNames && mir_wstrlen(lin->ptszNick) > 20) { mir_wstrncpy(szTemp2, lin->ptszNick, 20); @@ -312,7 +312,7 @@ char* Log_CreateRTF(LOGSTREAMDATA *streamData) continue; // create new line, and set font and color - if (lin->next != NULL) + if (lin->next != nullptr) buf.Append("\\par "); buf.AppendFormat("%s ", Log_SetStyle(0)); @@ -388,10 +388,10 @@ char* Log_CreateRtfHeader(MODULEINFO *mi) CMStringA buf; // get the number of pixels per logical inch - HDC hdc = GetDC(NULL); + HDC hdc = GetDC(nullptr); chatApi.logPixelSY = GetDeviceCaps(hdc, LOGPIXELSY); chatApi.logPixelSX = GetDeviceCaps(hdc, LOGPIXELSX); - ReleaseDC(NULL, hdc); + ReleaseDC(nullptr, hdc); // ### RTF HEADER @@ -449,7 +449,7 @@ void LoadMsgLogBitmaps(void) rc.right = bih.biWidth; rc.bottom = bih.biHeight; - HDC hdc = GetDC(NULL); + HDC hdc = GetDC(nullptr); HBITMAP hBmp = CreateCompatibleBitmap(hdc, bih.biWidth, bih.biHeight); HDC hdcMem = CreateCompatibleDC(hdc); PBYTE pBmpBits = (PBYTE)mir_alloc(widthBytes * bih.biHeight); @@ -461,7 +461,7 @@ void LoadMsgLogBitmaps(void) HICON hIcon = chatApi.hIcons[i]; HBITMAP hoBmp = (HBITMAP)SelectObject(hdcMem, hBmp); FillRect(hdcMem, &rc, hBkgBrush); - DrawIconEx(hdcMem, 0, 0, hIcon, bih.biWidth, bih.biHeight, 0, NULL, DI_NORMAL); + DrawIconEx(hdcMem, 0, 0, hIcon, bih.biWidth, bih.biHeight, 0, nullptr, DI_NORMAL); SelectObject(hdcMem, hoBmp); GetDIBits(hdc, hBmp, 0, bih.biHeight, pBmpBits, (BITMAPINFO *)& bih, DIB_RGB_COLORS); @@ -473,14 +473,14 @@ void LoadMsgLogBitmaps(void) mir_free(pBmpBits); DeleteDC(hdcMem); DeleteObject(hBmp); - ReleaseDC(NULL, hdc); + ReleaseDC(nullptr, hdc); DeleteObject(hBkgBrush); if (chatApi.logPixelSY == 0) { - hdc = GetDC(NULL); + hdc = GetDC(nullptr); chatApi.logPixelSY = GetDeviceCaps(hdc, LOGPIXELSY); chatApi.logPixelSX = GetDeviceCaps(hdc, LOGPIXELSX); - ReleaseDC(NULL, hdc); + ReleaseDC(nullptr, hdc); } for (int i = 0; i < OPTIONS_FONTCOUNT; i++) { diff --git a/src/mir_app/src/chat_manager.cpp b/src/mir_app/src/chat_manager.cpp index 1ff2b061e2..bdd3604861 100644 --- a/src/mir_app/src/chat_manager.cpp +++ b/src/mir_app/src/chat_manager.cpp @@ -96,7 +96,7 @@ static void SM_FreeSession(SESSION_INFO *si) mir_free(si->ptszStatusbarText); mir_free(si->ptszTopic); - while (si->lpCommands != NULL) { + while (si->lpCommands != nullptr) { COMMANDINFO *pNext = si->lpCommands->next; mir_free(si->lpCommands->lpCommand); mir_free(si->lpCommands); @@ -117,7 +117,7 @@ int SM_RemoveSession(const wchar_t *pszID, const char *pszModule, BOOL removeCon if ((!pszID && si->iType != GCW_SERVER || !mir_wstrcmpi(si->ptszID, pszID)) && !mir_strcmpi(si->pszModule, pszModule)) { if (si->pDlg) SendMessage(si->pDlg->GetHwnd(), GC_CONTROL_MSG, SESSION_TERMINATE, 0); - DoEventHook(si, GC_SESSION_TERMINATE, NULL, NULL, (INT_PTR)si->pItemData); + DoEventHook(si, GC_SESSION_TERMINATE, nullptr, nullptr, (INT_PTR)si->pItemData); // 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 @@ -158,7 +158,7 @@ BOOL SM_SetOffline(const wchar_t *pszID, const char *pszModule) continue; chatApi.UM_RemoveAll(&si->pUsers); - si->pMe = NULL; + si->pMe = nullptr; si->nUsersInNicklist = 0; if (si->iType != GCW_SERVER) si->bInitDone = false; @@ -173,10 +173,10 @@ BOOL SM_SetOffline(const wchar_t *pszID, const char *pszModule) static HICON SM_GetStatusIcon(SESSION_INFO *si, USERINFO * ui) { if (!ui || !si) - return NULL; + return nullptr; STATUSINFO *ti = chatApi.TM_FindStatus(si->pStatuses, chatApi.TM_WordToString(si->pStatuses, ui->Status)); - if (ti != NULL) { + if (ti != nullptr) { if ((UINT_PTR)ti->hIcon >= STATUSICONCOUNT) return ti->hIcon; @@ -188,7 +188,7 @@ static HICON SM_GetStatusIcon(SESSION_INFO *si, USERINFO * ui) BOOL SM_AddEvent(const wchar_t *pszID, const char *pszModule, GCEVENT *gce, bool bIsHighlighted) { SESSION_INFO *p = SM_FindSession(pszID, pszModule); - if (p == NULL) + if (p == nullptr) return TRUE; LOGINFO *li = chatApi.LM_AddEvent(&p->pLog, &p->pLogEnd); @@ -219,7 +219,7 @@ BOOL SM_MoveUser(const wchar_t *pszID, const char *pszModule, const wchar_t *psz return FALSE; SESSION_INFO *si = SM_FindSession(pszID, pszModule); - if (si == NULL) + if (si == nullptr) return FALSE; chatApi.UM_SortUser(&si->pUsers, pszUID); @@ -243,7 +243,7 @@ BOOL SM_RemoveUser(const wchar_t *pszID, const char *pszModule, const wchar_t *p chatApi.OnRemoveUser(si, ui); if (si->pMe == ui) - si->pMe = NULL; + si->pMe = nullptr; chatApi.UM_RemoveUser(&si->pUsers, pszUID); if (si->pDlg) @@ -260,13 +260,13 @@ 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 == NULL) ? NULL : chatApi.UM_FindUserFromIndex(si->pUsers, index); + return (si == nullptr) ? nullptr : chatApi.UM_FindUserFromIndex(si->pUsers, index); } BOOL SM_GiveStatus(const wchar_t *pszID, const char *pszModule, const wchar_t *pszUID, const wchar_t *pszStatus) { SESSION_INFO *si = SM_FindSession(pszID, pszModule); - if (si == NULL) + if (si == nullptr) return FALSE; USERINFO *ui = chatApi.UM_GiveStatus(si->pUsers, pszUID, chatApi.TM_StringToWord(si->pStatuses, pszStatus)); @@ -281,7 +281,7 @@ BOOL SM_GiveStatus(const wchar_t *pszID, const char *pszModule, const wchar_t *p BOOL SM_SetContactStatus(const wchar_t *pszID, const char *pszModule, const wchar_t *pszUID, WORD wStatus) { SESSION_INFO *si = SM_FindSession(pszID, pszModule); - if (si == NULL) + if (si == nullptr) return FALSE; USERINFO *ui = chatApi.UM_SetContactStatus(si->pUsers, pszUID, wStatus); @@ -296,7 +296,7 @@ BOOL SM_SetContactStatus(const wchar_t *pszID, const char *pszModule, const wcha BOOL SM_TakeStatus(const wchar_t *pszID, const char *pszModule, const wchar_t *pszUID, const wchar_t *pszStatus) { SESSION_INFO *si = SM_FindSession(pszID, pszModule); - if (si == NULL) + if (si == nullptr) return FALSE; USERINFO *ui = chatApi.UM_TakeStatus(si->pUsers, pszUID, chatApi.TM_StringToWord(si->pStatuses, pszStatus)); @@ -310,7 +310,7 @@ BOOL SM_TakeStatus(const wchar_t *pszID, const char *pszModule, const wchar_t *p LRESULT SM_SendMessage(const wchar_t *pszID, const char *pszModule, UINT msg, WPARAM wParam, LPARAM lParam) { - if (pszModule == NULL) + if (pszModule == nullptr) return 0; for (int i = 0; i < g_arSessions.getCount(); i++) { @@ -405,7 +405,7 @@ void SM_RemoveAll(void) if (si->pDlg) SendMessage(si->pDlg->GetHwnd(), GC_CONTROL_MSG, SESSION_TERMINATE, 0); - DoEventHook(si, GC_SESSION_TERMINATE, NULL, NULL, (INT_PTR)si->pItemData); + DoEventHook(si, GC_SESSION_TERMINATE, nullptr, nullptr, (INT_PTR)si->pItemData); SM_FreeSession(si); } @@ -415,16 +415,16 @@ void SM_RemoveAll(void) static void SM_AddCommand(const wchar_t *pszID, const char *pszModule, const char* lpNewCommand) { SESSION_INFO *si = SM_FindSession(pszID, pszModule); - if (si == NULL) + if (si == nullptr) return; COMMANDINFO *node = (COMMANDINFO *)mir_alloc(sizeof(COMMANDINFO)); node->lpCommand = mir_strdup(lpNewCommand); - node->last = NULL; // always added at beginning! + node->last = nullptr; // always added at beginning! // new commands are added at start - if (si->lpCommands == NULL) { - node->next = NULL; + if (si->lpCommands == nullptr) { + node->next = nullptr; si->lpCommands = node; } else { @@ -432,30 +432,30 @@ static void SM_AddCommand(const wchar_t *pszID, const char *pszModule, const cha si->lpCommands->last = node; // hmm, weird si->lpCommands = node; } - si->lpCurrentCommand = NULL; // current command + si->lpCurrentCommand = nullptr; // current command si->wCommandsNum++; if (si->wCommandsNum > WINDOWS_COMMANDS_MAX) { COMMANDINFO *pCurComm = si->lpCommands; - while (pCurComm->next != NULL) { pCurComm = pCurComm->next; } + while (pCurComm->next != nullptr) { pCurComm = pCurComm->next; } COMMANDINFO *pLast = pCurComm->last; mir_free(pCurComm->lpCommand); mir_free(pCurComm); - pLast->next = NULL; + pLast->next = nullptr; // done si->wCommandsNum--; } } -static char* SM_GetPrevCommand(const wchar_t *pszID, const char *pszModule) // get previous command. returns NULL if previous command does not exist. current command remains as it was. +static char* SM_GetPrevCommand(const wchar_t *pszID, const char *pszModule) // get previous command. returns nullptr if previous command does not exist. current command remains as it was. { SESSION_INFO *si = SM_FindSession(pszID, pszModule); - if (si == NULL) - return NULL; + if (si == nullptr) + return nullptr; - COMMANDINFO *pPrevCmd = NULL; - if (si->lpCurrentCommand != NULL) { - if (si->lpCurrentCommand->next != NULL) // not NULL + COMMANDINFO *pPrevCmd = nullptr; + if (si->lpCurrentCommand != nullptr) { + if (si->lpCurrentCommand->next != nullptr) // not nullptr pPrevCmd = si->lpCurrentCommand->next; // next command (newest at beginning) else pPrevCmd = si->lpCurrentCommand; @@ -463,21 +463,21 @@ static char* SM_GetPrevCommand(const wchar_t *pszID, const char *pszModule) // g else pPrevCmd = si->lpCommands; si->lpCurrentCommand = pPrevCmd; // make it the new command - return (pPrevCmd) ? pPrevCmd->lpCommand : NULL; + return (pPrevCmd) ? pPrevCmd->lpCommand : nullptr; } -static char* SM_GetNextCommand(const wchar_t *pszID, const char *pszModule) // get next command. returns NULL if next command does not exist. current command becomes NULL (a prev command after this one will get you the last command) +static char* SM_GetNextCommand(const wchar_t *pszID, const char *pszModule) // get next command. returns nullptr if next command does not exist. current command becomes nullptr (a prev command after this one will get you the last command) { SESSION_INFO *si = SM_FindSession(pszID, pszModule); - if (si == NULL) - return NULL; + if (si == nullptr) + return nullptr; - COMMANDINFO *pNextCmd = NULL; - if (si->lpCurrentCommand != NULL) + COMMANDINFO *pNextCmd = nullptr; + if (si->lpCurrentCommand != nullptr) pNextCmd = si->lpCurrentCommand->last; // last command (newest at beginning) si->lpCurrentCommand = pNextCmd; // make it the new command - return (pNextCmd) ? pNextCmd->lpCommand : NULL; + return (pNextCmd) ? pNextCmd->lpCommand : nullptr; } static int SM_GetCount(const char *pszModule) @@ -505,29 +505,29 @@ static SESSION_INFO* SM_FindSessionByIndex(const char *pszModule, int iItem) count++; } } - return NULL; + return nullptr; } char* SM_GetUsers(SESSION_INFO *si) { - if (si == NULL) - return NULL; + if (si == nullptr) + return nullptr; - USERINFO *utemp = NULL; + USERINFO *utemp = nullptr; for (int i = 0; i < g_arSessions.getCount(); i++) { SESSION_INFO *p = g_arSessions[i]; if (si == p) { - if ((utemp = p->pUsers) == NULL) - return NULL; + if ((utemp = p->pUsers) == nullptr) + return nullptr; break; } } - if (utemp == NULL) - return NULL; + if (utemp == nullptr) + return nullptr; - char* p = NULL; + char* p = nullptr; size_t alloced = 0; do { size_t pLen = mir_strlen(p), nameLen = mir_wstrlen(utemp->pszUID); @@ -538,7 +538,7 @@ char* SM_GetUsers(SESSION_INFO *si) mir_strcpy(p + pLen + nameLen, " "); utemp = utemp->next; } - while (utemp != NULL); + while (utemp != nullptr); return p; } @@ -559,20 +559,20 @@ static void SM_InvalidateLogDirectories() static MODULEINFO* MM_AddModule(const char *pszModule) { - if (pszModule == NULL) - return NULL; + if (pszModule == nullptr) + return nullptr; if (chatApi.MM_FindModule(pszModule)) - return NULL; + return nullptr; MODULEINFO *node = (MODULEINFO*)mir_calloc(g_cbModuleInfo); replaceStr(node->pszModule, pszModule); if (chatApi.OnCreateModule) chatApi.OnCreateModule(node); - if (m_ModList == NULL) { // list is empty + if (m_ModList == nullptr) { // list is empty m_ModList = node; - node->next = NULL; + node->next = nullptr; } else { node->next = m_ModList; @@ -585,7 +585,7 @@ static void MM_IconsChanged() { LoadChatIcons(); - for (MODULEINFO *mi = m_ModList; mi != NULL; mi = mi->next) { + for (MODULEINFO *mi = m_ModList; mi != nullptr; mi = mi->next) { Safe_DestroyIcon(mi->hOnlineIcon); Safe_DestroyIcon(mi->hOfflineIcon); Safe_DestroyIcon(mi->hOnlineTalkIcon); @@ -598,32 +598,32 @@ static void MM_IconsChanged() static void MM_FontsChanged() { - for (MODULEINFO *mi = m_ModList; mi != NULL; mi = mi->next) + for (MODULEINFO *mi = m_ModList; mi != nullptr; mi = mi->next) mi->pszHeader = chatApi.Log_CreateRtfHeader(mi); } static MODULEINFO* MM_FindModule(const char *pszModule) { if (!pszModule) - return NULL; + return nullptr; - for (MODULEINFO *mi = m_ModList; mi != NULL; mi = mi->next) + for (MODULEINFO *mi = m_ModList; mi != nullptr; mi = mi->next) if (mir_strcmpi(mi->pszModule, pszModule) == 0) return mi; - return NULL; + return nullptr; } // stupid thing.. static void MM_FixColors() { - for (MODULEINFO *mi = m_ModList; mi != NULL; mi = mi->next) + for (MODULEINFO *mi = m_ModList; mi != nullptr; mi = mi->next) CheckColorsInModule(mi->pszModule); } static BOOL MM_RemoveAll(void) { - while (m_ModList != NULL) { + while (m_ModList != nullptr) { MODULEINFO *pLast = m_ModList->next; mir_free(m_ModList->pszModule); mir_free(m_ModList->ptszModDispName); @@ -638,7 +638,7 @@ static BOOL MM_RemoveAll(void) mir_free(m_ModList); m_ModList = pLast; } - m_ModList = NULL; + m_ModList = nullptr; return TRUE; } @@ -652,7 +652,7 @@ static BOOL MM_RemoveAll(void) static STATUSINFO* TM_AddStatus(STATUSINFO **ppStatusList, const wchar_t *pszStatus, int *iCount) { if (!ppStatusList || !pszStatus) - return NULL; + return nullptr; if (!chatApi.TM_FindStatus(*ppStatusList, pszStatus)) { STATUSINFO *node = (STATUSINFO*)mir_alloc(sizeof(STATUSINFO)); @@ -662,10 +662,10 @@ static STATUSINFO* TM_AddStatus(STATUSINFO **ppStatusList, const wchar_t *pszSta while ((INT_PTR)node->hIcon > STATUSICONCOUNT - 1) node->hIcon--; - if (*ppStatusList == NULL) { // list is empty + if (*ppStatusList == nullptr) { // list is empty node->Status = 1; *ppStatusList = node; - node->next = NULL; + node->next = nullptr; } else { node->Status = ppStatusList[0]->Status * 2; @@ -681,9 +681,9 @@ static STATUSINFO* TM_AddStatus(STATUSINFO **ppStatusList, const wchar_t *pszSta static STATUSINFO* TM_FindStatus(STATUSINFO *pStatusList, const wchar_t *pszStatus) { if (!pStatusList || !pszStatus) - return NULL; + return nullptr; - for (STATUSINFO *pTemp = pStatusList; pTemp != NULL; pTemp = pTemp->next) + for (STATUSINFO *pTemp = pStatusList; pTemp != nullptr; pTemp = pTemp->next) if (mir_wstrcmpi(pTemp->pszGroup, pszStatus) == 0) return pTemp; @@ -695,11 +695,11 @@ static WORD TM_StringToWord(STATUSINFO *pStatusList, const wchar_t *pszStatus) if (!pStatusList || !pszStatus) return 0; - for (STATUSINFO *pTemp = pStatusList; pTemp != NULL; pTemp = pTemp->next) { + for (STATUSINFO *pTemp = pStatusList; pTemp != nullptr; pTemp = pTemp->next) { if (mir_wstrcmpi(pTemp->pszGroup, pszStatus) == 0) return pTemp->Status; - if (pTemp->next == NULL) + if (pTemp->next == nullptr) return pStatusList->Status; } return 0; @@ -708,9 +708,9 @@ static WORD TM_StringToWord(STATUSINFO *pStatusList, const wchar_t *pszStatus) static wchar_t* TM_WordToString(STATUSINFO *pStatusList, WORD Status) { if (!pStatusList) - return NULL; + return nullptr; - for (STATUSINFO *pTemp = pStatusList; pTemp != NULL; pTemp = pTemp->next) { + for (STATUSINFO *pTemp = pStatusList; pTemp != nullptr; pTemp = pTemp->next) { if (pTemp->Status & Status) { Status -= pTemp->Status; if (Status == 0) @@ -725,7 +725,7 @@ static BOOL TM_RemoveAll(STATUSINFO **ppStatusList) if (!ppStatusList) return FALSE; - while (*ppStatusList != NULL) { + while (*ppStatusList != nullptr) { STATUSINFO *pLast = ppStatusList[0]->next; mir_free(ppStatusList[0]->pszGroup); if ((INT_PTR)ppStatusList[0]->hIcon > 10) @@ -733,7 +733,7 @@ static BOOL TM_RemoveAll(STATUSINFO **ppStatusList) mir_free(*ppStatusList); *ppStatusList = pLast; } - *ppStatusList = NULL; + *ppStatusList = nullptr; return TRUE; } @@ -765,17 +765,17 @@ static int UM_CompareItem(USERINFO *u1, const wchar_t *pszNick, WORD wStatus) static USERINFO* UM_SortUser(USERINFO **ppUserList, const wchar_t *pszUID) { - USERINFO *ui = *ppUserList, *pLast = NULL; + USERINFO *ui = *ppUserList, *pLast = nullptr; if (!ui || !pszUID) - return NULL; + return nullptr; while (ui && mir_wstrcmpi(ui->pszUID, pszUID)) { pLast = ui; ui = ui->next; } - if (ui == NULL) - return NULL; + if (ui == nullptr) + return nullptr; USERINFO *node = ui; if (pLast) @@ -784,16 +784,16 @@ static USERINFO* UM_SortUser(USERINFO **ppUserList, const wchar_t *pszUID) *ppUserList = ui->next; ui = *ppUserList; - pLast = NULL; + pLast = nullptr; while (ui && chatApi.UM_CompareItem(ui, node->pszNick, node->Status) <= 0) { pLast = ui; ui = ui->next; } - if (*ppUserList == NULL) { // list is empty + if (*ppUserList == nullptr) { // list is empty *ppUserList = node; - node->next = NULL; + node->next = nullptr; } else { if (pLast) { @@ -811,10 +811,10 @@ static USERINFO* UM_SortUser(USERINFO **ppUserList, const wchar_t *pszUID) USERINFO* UM_AddUser(STATUSINFO *pStatusList, USERINFO **ppUserList, const wchar_t *pszUID, const wchar_t *pszNick, WORD wStatus) { - if (pStatusList == NULL || ppUserList == NULL || pszNick == NULL) - return NULL; + if (pStatusList == nullptr || ppUserList == nullptr || pszNick == nullptr) + return nullptr; - USERINFO *ui = *ppUserList, *pLast = NULL; + USERINFO *ui = *ppUserList, *pLast = nullptr; while (ui && chatApi.UM_CompareItem(ui, pszNick, wStatus) <= 0) { pLast = ui; ui = ui->next; @@ -824,9 +824,9 @@ USERINFO* UM_AddUser(STATUSINFO *pStatusList, USERINFO **ppUserList, const wchar USERINFO *node = (USERINFO*)mir_calloc(sizeof(USERINFO)); replaceStrW(node->pszUID, pszUID); - if (*ppUserList == NULL) { // list is empty + if (*ppUserList == nullptr) { // list is empty *ppUserList = node; - node->next = NULL; + node->next = nullptr; } else { if (pLast) { @@ -845,34 +845,34 @@ USERINFO* UM_AddUser(STATUSINFO *pStatusList, USERINFO **ppUserList, const wchar static USERINFO* UM_FindUser(USERINFO *pUserList, const wchar_t *pszUID) { if (!pUserList || !pszUID) - return NULL; + return nullptr; - for (USERINFO *ui = pUserList; ui != NULL; ui = ui->next) + for (USERINFO *ui = pUserList; ui != nullptr; ui = ui->next) if (!mir_wstrcmpi(ui->pszUID, pszUID)) return ui; - return NULL; + return nullptr; } static USERINFO* UM_FindUserFromIndex(USERINFO *pUserList, int index) { if (!pUserList) - return NULL; + return nullptr; int i = 0; - for (USERINFO *ui = pUserList; ui != NULL; ui = ui->next) { + for (USERINFO *ui = pUserList; ui != nullptr; ui = ui->next) { if (i == index) return ui; i++; } - return NULL; + return nullptr; } static USERINFO* UM_GiveStatus(USERINFO *pUserList, const wchar_t *pszUID, WORD status) { USERINFO *ui = UM_FindUser(pUserList, pszUID); - if (ui == NULL) - return NULL; + if (ui == nullptr) + return nullptr; ui->Status |= status; return ui; @@ -881,8 +881,8 @@ static USERINFO* UM_GiveStatus(USERINFO *pUserList, const wchar_t *pszUID, WORD static USERINFO* UM_SetContactStatus(USERINFO *pUserList, const wchar_t *pszUID, WORD status) { USERINFO *ui = UM_FindUser(pUserList, pszUID); - if (ui == NULL) - return NULL; + if (ui == nullptr) + return nullptr; ui->ContactStatus = status; return ui; @@ -893,11 +893,11 @@ static BOOL UM_SetStatusEx(USERINFO *pUserList, const wchar_t* pszText, int flag int bOnlyMe = (flags & GC_SSE_ONLYLISTED) != 0, bSetStatus = (flags & GC_SSE_ONLINE) != 0; char cDelimiter = (flags & GC_SSE_TABDELIMITED) ? '\t' : ' '; - for (USERINFO *ui = pUserList; ui != NULL; ui = ui->next) { + for (USERINFO *ui = pUserList; ui != nullptr; ui = ui->next) { if (!bOnlyMe) ui->iStatusEx = 0; - if (pszText != NULL) { + if (pszText != nullptr) { wchar_t *s = (wchar_t *)wcsstr(pszText, ui->pszUID); if (s) { ui->iStatusEx = 0; @@ -915,8 +915,8 @@ static BOOL UM_SetStatusEx(USERINFO *pUserList, const wchar_t* pszText, int flag static USERINFO* UM_TakeStatus(USERINFO *pUserList, const wchar_t *pszUID, WORD status) { USERINFO *ui = UM_FindUser(pUserList, pszUID); - if (ui == NULL) - return NULL; + if (ui == nullptr) + return nullptr; ui->Status &= ~status; return ui; @@ -925,10 +925,10 @@ static USERINFO* UM_TakeStatus(USERINFO *pUserList, const wchar_t *pszUID, WORD static wchar_t* UM_FindUserAutoComplete(USERINFO *pUserList, const wchar_t* pszOriginal, const wchar_t* pszCurrent) { if (!pUserList || !pszOriginal || !pszCurrent) - return NULL; + return nullptr; - wchar_t *pszName = NULL; - for (USERINFO *ui = pUserList; ui != NULL; ui = ui->next) + wchar_t *pszName = nullptr; + for (USERINFO *ui = pUserList; ui != nullptr; ui = ui->next) if (ui->pszNick && my_strstri(ui->pszNick, pszOriginal) == ui->pszNick) if (mir_wstrcmpi(ui->pszNick, pszCurrent) > 0 && (!pszName || mir_wstrcmpi(ui->pszNick, pszName) < 0)) pszName = ui->pszNick; @@ -941,10 +941,10 @@ static BOOL UM_RemoveUser(USERINFO **ppUserList, const wchar_t *pszUID) if (!ppUserList || !pszUID) return FALSE; - USERINFO *ui = *ppUserList, *pLast = NULL; - while (ui != NULL) { + USERINFO *ui = *ppUserList, *pLast = nullptr; + while (ui != nullptr) { if (!mir_wstrcmpi(ui->pszUID, pszUID)) { - if (pLast == NULL) + if (pLast == nullptr) *ppUserList = ui->next; else pLast->next = ui->next; @@ -964,14 +964,14 @@ static BOOL UM_RemoveAll(USERINFO **ppUserList) if (!ppUserList) return FALSE; - while (*ppUserList != NULL) { + while (*ppUserList != nullptr) { USERINFO *pLast = ppUserList[0]->next; mir_free(ppUserList[0]->pszUID); mir_free(ppUserList[0]->pszNick); mir_free(*ppUserList); *ppUserList = pLast; } - *ppUserList = NULL; + *ppUserList = nullptr; return TRUE; } @@ -985,20 +985,20 @@ static BOOL UM_RemoveAll(USERINFO **ppUserList) static LOGINFO* LM_AddEvent(LOGINFO **ppLogListStart, LOGINFO** ppLogListEnd) { if (!ppLogListStart || !ppLogListEnd) - return NULL; + return nullptr; LOGINFO *node = (LOGINFO*)mir_calloc(sizeof(LOGINFO)); - if (*ppLogListStart == NULL) { // list is empty + if (*ppLogListStart == nullptr) { // list is empty *ppLogListStart = node; *ppLogListEnd = node; - node->next = NULL; - node->prev = NULL; + node->next = nullptr; + node->prev = nullptr; } else { ppLogListStart[0]->prev = node; node->next = *ppLogListStart; *ppLogListStart = node; - ppLogListStart[0]->prev = NULL; + ppLogListStart[0]->prev = nullptr; } return node; @@ -1007,10 +1007,10 @@ static LOGINFO* LM_AddEvent(LOGINFO **ppLogListStart, LOGINFO** ppLogListEnd) static BOOL LM_TrimLog(LOGINFO **ppLogListStart, LOGINFO **ppLogListEnd, int iCount) { LOGINFO *pTemp = *ppLogListEnd; - while (pTemp != NULL && iCount > 0) { + while (pTemp != nullptr && iCount > 0) { *ppLogListEnd = pTemp->prev; - if (*ppLogListEnd == NULL) - *ppLogListStart = NULL; + if (*ppLogListEnd == nullptr) + *ppLogListStart = nullptr; mir_free(pTemp->ptszNick); mir_free(pTemp->ptszUserInfo); @@ -1020,14 +1020,14 @@ static BOOL LM_TrimLog(LOGINFO **ppLogListStart, LOGINFO **ppLogListEnd, int iCo pTemp = *ppLogListEnd; iCount--; } - ppLogListEnd[0]->next = NULL; + ppLogListEnd[0]->next = nullptr; return TRUE; } static BOOL LM_RemoveAll(LOGINFO **ppLogListStart, LOGINFO **ppLogListEnd) { - while (*ppLogListStart != NULL) { + while (*ppLogListStart != nullptr) { LOGINFO *pLast = ppLogListStart[0]->next; mir_free(ppLogListStart[0]->ptszText); mir_free(ppLogListStart[0]->ptszNick); @@ -1036,8 +1036,8 @@ static BOOL LM_RemoveAll(LOGINFO **ppLogListStart, LOGINFO **ppLogListEnd) mir_free(*ppLogListStart); *ppLogListStart = pLast; } - *ppLogListStart = NULL; - *ppLogListEnd = NULL; + *ppLogListStart = nullptr; + *ppLogListEnd = nullptr; return TRUE; } @@ -1049,7 +1049,7 @@ static BOOL DoEventHook(const wchar_t *pszID, const char *pszModule, int iType, MIR_APP_DLL(CHAT_MANAGER*) Chat_GetInterface(CHAT_MANAGER_INITDATA *pInit, int _hLangpack) { - if (pInit == NULL) + if (pInit == nullptr) return &chatApi; // wipe out old junk @@ -1070,14 +1070,14 @@ MIR_APP_DLL(CHAT_MANAGER*) Chat_GetInterface(CHAT_MANAGER_INITDATA *pInit, int _ } if (g_cbModuleInfo) { // reallocate old modules mir_cslock lck(csChat); - MODULEINFO *pPrev = NULL; + MODULEINFO *pPrev = nullptr; for (MODULEINFO *p = m_ModList; p; p = p->next) { MODULEINFO *p1 = (MODULEINFO*)mir_realloc(p, pInit->cbModuleInfo); memset(PBYTE(p1) + sizeof(GCModuleInfoBase), 0, pInit->cbModuleInfo - sizeof(GCModuleInfoBase)); if (p1 != p) { // realloc could change a pointer, reinsert a structure if (m_ModList == p) m_ModList = p1; - if (pPrev != NULL) + if (pPrev != nullptr) pPrev->next = p1; p = p1; } diff --git a/src/mir_app/src/chat_svc.cpp b/src/mir_app/src/chat_svc.cpp index 8256520450..0446d8979d 100644 --- a/src/mir_app/src/chat_svc.cpp +++ b/src/mir_app/src/chat_svc.cpp @@ -30,17 +30,17 @@ HGENMENU hJoinMenuItem, hLeaveMenuItem; mir_cs csChat; static HANDLE - hServiceRegister = NULL, - hServiceNewChat = NULL, - hServiceAddEvent = NULL, - hServiceGetAddEventPtr = NULL, - hServiceGetInfo = NULL, - hServiceGetCount = NULL, - hEventPrebuildMenu = NULL, - hEventDoubleclicked = NULL, - hEventJoinChat = NULL, - hEventLeaveChat = NULL, - hHookEvent = NULL; + hServiceRegister = nullptr, + hServiceNewChat = nullptr, + hServiceAddEvent = nullptr, + hServiceGetAddEventPtr = nullptr, + hServiceGetInfo = nullptr, + hServiceGetCount = nullptr, + hEventPrebuildMenu = nullptr, + hEventDoubleclicked = nullptr, + hEventJoinChat = nullptr, + hEventLeaveChat = nullptr, + hHookEvent = nullptr; ///////////////////////////////////////////////////////////////////////////////////////// // Post-load event hooks @@ -81,11 +81,11 @@ static int FontsChanged(WPARAM, LPARAM) LoadMsgLogBitmaps(); SetIndentSize(); - g_Settings->bLogIndentEnabled = (db_get_b(NULL, CHAT_MODULE, "LogIndentEnabled", 1) != 0) ? TRUE : FALSE; + g_Settings->bLogIndentEnabled = (db_get_b(0, CHAT_MODULE, "LogIndentEnabled", 1) != 0) ? TRUE : FALSE; chatApi.MM_FontsChanged(); chatApi.MM_FixColors(); - chatApi.SM_BroadcastMessage(NULL, GC_SETWNDPROPS, 0, 0, TRUE); + chatApi.SM_BroadcastMessage(nullptr, GC_SETWNDPROPS, 0, 0, TRUE); return 0; } @@ -95,14 +95,14 @@ static int IconsChanged(WPARAM, LPARAM) LoadMsgLogBitmaps(); chatApi.MM_IconsChanged(); - chatApi.SM_BroadcastMessage(NULL, GC_SETWNDPROPS, 0, 0, FALSE); + chatApi.SM_BroadcastMessage(nullptr, GC_SETWNDPROPS, 0, 0, FALSE); return 0; } static int PreShutdown(WPARAM, LPARAM) { - if (g_Settings != NULL) { - chatApi.SM_BroadcastMessage(NULL, GC_CLOSEWINDOW, 0, 1, FALSE); + if (g_Settings != nullptr) { + chatApi.SM_BroadcastMessage(nullptr, GC_CLOSEWINDOW, 0, 1, FALSE); SM_RemoveAll(); chatApi.MM_RemoveAll(); @@ -115,7 +115,7 @@ static int PreShutdown(WPARAM, LPARAM) static int SmileyOptionsChanged(WPARAM, LPARAM) { - chatApi.SM_BroadcastMessage(NULL, GC_REDRAWLOG, 0, 1, FALSE); + chatApi.SM_BroadcastMessage(nullptr, GC_REDRAWLOG, 0, 1, FALSE); return 0; } @@ -134,7 +134,7 @@ EXTERN_C MIR_APP_DLL(int) Chat_GetInfo(GC_INFO *gci) si = chatApi.SM_FindSessionByIndex(gci->pszModule, gci->iItem); else si = chatApi.SM_FindSession(gci->pszID, gci->pszModule); - if (si == NULL) + if (si == nullptr) return 1; if (gci->Flags & GCF_DATA) gci->pItemData = si->pItemData; @@ -152,12 +152,12 @@ EXTERN_C MIR_APP_DLL(int) Chat_GetInfo(GC_INFO *gci) MIR_APP_DLL(int) Chat_Register(const GCREGISTER *gcr) { - if (gcr == NULL) + if (gcr == nullptr) return GC_ERROR; mir_cslock lck(csChat); MODULEINFO *mi = chatApi.MM_AddModule(gcr->pszModule); - if (mi == NULL) + if (mi == nullptr) return GC_ERROR; mi->ptszModDispName = mir_wstrdup(gcr->ptszDispName); @@ -196,19 +196,19 @@ EXTERN_C MIR_APP_DLL(GCSessionInfoBase*) Chat_NewSession( { mir_cslockfull lck(csChat); MODULEINFO *mi = chatApi.MM_FindModule(pszModule); - if (mi == NULL) - return NULL; + if (mi == nullptr) + return nullptr; // try to restart a session first SESSION_INFO *si = chatApi.SM_FindSession(ptszID, pszModule); - if (si != NULL) { + if (si != nullptr) { chatApi.UM_RemoveAll(&si->pUsers); chatApi.TM_RemoveAll(&si->pStatuses); lck.unlock(); si->iStatusCount = 0; si->nUsersInNicklist = 0; - si->pMe = NULL; + si->pMe = nullptr; if (chatApi.OnReplaceSession) chatApi.OnReplaceSession(si); @@ -289,7 +289,7 @@ static INT_PTR __stdcall stubRoomControl(void *param) case SESSION_INITDONE: if (SESSION_INFO *si = chatApi.SM_FindSession(p->wszId, p->szModule)) { SetInitDone(si); - if (p->command != SESSION_INITDONE || db_get_b(NULL, CHAT_MODULE, "PopupOnJoin", 0) == 0) + if (p->command != SESSION_INITDONE || db_get_b(0, CHAT_MODULE, "PopupOnJoin", 0) == 0) chatApi.ShowRoom(si); return 0; } @@ -369,13 +369,13 @@ static INT_PTR __stdcall stubFlash(void *param) static void AddUser(GCEVENT *gce) { SESSION_INFO *si = chatApi.SM_FindSession(gce->pDest->ptszID, gce->pDest->pszModule); - if (si == NULL) + if (si == nullptr) return; WORD status = chatApi.TM_StringToWord(si->pStatuses, gce->ptszStatus); USERINFO *ui = chatApi.UM_AddUser(si->pStatuses, &si->pUsers, gce->ptszUID, gce->ptszNick, status); - if (ui == NULL) + if (ui == nullptr) return; si->nUsersInNicklist++; @@ -429,11 +429,11 @@ static BOOL AddEventToAllMatchingUID(GCEVENT *gce) EXTERN_C MIR_APP_DLL(int) Chat_Event(GCEVENT *gce) { - if (gce == NULL) + if (gce == nullptr) return GC_EVENT_ERROR; GCDEST *gcd = gce->pDest; - if (gcd == NULL) + if (gcd == nullptr) return GC_EVENT_ERROR; if (!IsEventSupported(gcd->iType)) @@ -456,7 +456,7 @@ EXTERN_C MIR_APP_DLL(int) Chat_Event(GCEVENT *gce) return 0; replaceStrW(si->ptszTopic, pwszNew); - if (pwszNew != NULL) + if (pwszNew != nullptr) db_set_ws(si->hContact, si->pszModule, "Topic", si->ptszTopic); else db_unset(si->hContact, si->pszModule, "Topic"); @@ -464,8 +464,8 @@ EXTERN_C MIR_APP_DLL(int) Chat_Event(GCEVENT *gce) if (chatApi.OnSetTopic) chatApi.OnSetTopic(si); - if (db_get_b(NULL, CHAT_MODULE, "TopicOnClist", 0)) { - if (pwszNew != NULL) + if (db_get_b(0, CHAT_MODULE, "TopicOnClist", 0)) { + if (pwszNew != nullptr) db_set_ws(si->hContact, "CList", "StatusMsg", si->ptszTopic); else db_unset(si->hContact, "CList", "StatusMsg"); @@ -475,12 +475,12 @@ EXTERN_C MIR_APP_DLL(int) Chat_Event(GCEVENT *gce) case GC_EVENT_ADDSTATUS: SM_GiveStatus(gcd->ptszID, gcd->pszModule, gce->ptszUID, gce->ptszStatus); - bIsHighlighted = chatApi.IsHighlighted(NULL, gce); + bIsHighlighted = chatApi.IsHighlighted(nullptr, gce); break; case GC_EVENT_REMOVESTATUS: SM_TakeStatus(gcd->ptszID, gcd->pszModule, gce->ptszUID, gce->ptszStatus); - bIsHighlighted = chatApi.IsHighlighted(NULL, gce); + bIsHighlighted = chatApi.IsHighlighted(nullptr, gce); break; case GC_EVENT_MESSAGE: @@ -493,25 +493,25 @@ EXTERN_C MIR_APP_DLL(int) Chat_Event(GCEVENT *gce) case GC_EVENT_NICK: SM_ChangeNick(gcd->ptszID, gcd->pszModule, gce); - bIsHighlighted = chatApi.IsHighlighted(NULL, gce); + bIsHighlighted = chatApi.IsHighlighted(nullptr, gce); break; case GC_EVENT_JOIN: AddUser(gce); - bIsHighlighted = chatApi.IsHighlighted(NULL, gce); + bIsHighlighted = chatApi.IsHighlighted(nullptr, gce); break; case GC_EVENT_PART: case GC_EVENT_QUIT: case GC_EVENT_KICK: bRemoveFlag = TRUE; - bIsHighlighted = chatApi.IsHighlighted(NULL, gce); + bIsHighlighted = chatApi.IsHighlighted(nullptr, gce); break; } // Decide which window (log) should have the event - LPCTSTR pWnd = NULL; - LPCSTR pMod = NULL; + LPCTSTR pWnd = nullptr; + LPCSTR pMod = nullptr; if (gcd->ptszID) { pWnd = gcd->ptszID; pMod = gcd->pszModule; @@ -584,13 +584,13 @@ EXTERN_C MIR_APP_DLL(int) Chat_Event(GCEVENT *gce) MIR_APP_DLL(int) Chat_AddGroup(const char *szModule, const wchar_t *wszId, const wchar_t *wszText, HICON hIcon) { - if (wszText == NULL) + if (wszText == nullptr) return GC_EVENT_ERROR; mir_cslock lck(csChat); SESSION_INFO *si = SM_FindSession(wszId, szModule); - if (si == NULL) - return NULL; + if (si == nullptr) + return 0; STATUSINFO *ti = chatApi.TM_AddStatus(&si->pStatuses, wszText, &si->iStatusCount); if (ti) { @@ -606,7 +606,7 @@ MIR_APP_DLL(int) Chat_AddGroup(const char *szModule, const wchar_t *wszId, const MIR_APP_DLL(int) Chat_ChangeSessionName(const char *szModule, const wchar_t *wszId, const wchar_t *wszNewName) { - if (wszNewName == NULL) + if (wszNewName == nullptr) return GC_EVENT_ERROR; SESSION_INFO *si; @@ -629,7 +629,7 @@ MIR_APP_DLL(int) Chat_ChangeSessionName(const char *szModule, const wchar_t *wsz MIR_APP_DLL(int) Chat_ChangeUserId(const char *szModule, const wchar_t *wszId, const wchar_t *wszOldId, const wchar_t *wszNewId) { - if (szModule == NULL || wszNewId == NULL) + if (szModule == nullptr || wszNewId == nullptr) return GC_EVENT_ERROR; mir_cslock lck(csChat); @@ -652,12 +652,12 @@ MIR_APP_DLL(void*) Chat_GetUserInfo(const char *szModule, const wchar_t *wszId) mir_cslock lck(csChat); if (SESSION_INFO *si = chatApi.SM_FindSession(wszId, szModule)) return si->pItemData; - return NULL; + return nullptr; } MIR_APP_DLL(int) Chat_SendUserMessage(const char *szModule, const wchar_t *wszId, const wchar_t *wszText) { - if (wszText == NULL || szModule == NULL) + if (wszText == nullptr || szModule == nullptr) return GC_EVENT_ERROR; mir_cslock lck(csChat); @@ -667,7 +667,7 @@ MIR_APP_DLL(int) Chat_SendUserMessage(const char *szModule, const wchar_t *wszId continue; if (si->iType == GCW_CHATROOM || si->iType == GCW_PRIVMESS) - DoEventHook(si, GC_USER_MESSAGE, NULL, wszText, 0); + DoEventHook(si, GC_USER_MESSAGE, nullptr, wszText, 0); if (wszId) break; } @@ -707,7 +707,7 @@ MIR_APP_DLL(int) Chat_SetStatusEx(const char *szModule, const wchar_t *wszId, in chatApi.UM_SetStatusEx(si->pUsers, wszText, flags); if (si->pDlg) - RedrawWindow(GetDlgItem(si->pDlg->GetHwnd(), IDC_LIST), NULL, NULL, RDW_INVALIDATE); + RedrawWindow(GetDlgItem(si->pDlg->GetHwnd(), IDC_LIST), nullptr, nullptr, RDW_INVALIDATE); if (wszId) break; } @@ -753,7 +753,7 @@ static int ModulesLoaded(WPARAM, LPARAM) hLeaveMenuItem = Menu_AddContactMenuItem(&mi); CreateServiceFunction(mi.pszService, LeaveChat); - chatApi.SetAllOffline(TRUE, NULL); + chatApi.SetAllOffline(TRUE, nullptr); return 0; } -- cgit v1.2.3