From 7205e006b83f8cbeb70c10507cfc2de7698cc4e9 Mon Sep 17 00:00:00 2001 From: Kirill Volinsky Date: Wed, 14 Nov 2012 13:36:09 +0000 Subject: tabs and spaces cleaning git-svn-id: http://svn.miranda-ng.org/main/trunk@2310 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- src/modules/clist/clc.cpp | 13 +-- src/modules/clist/clcfiledrop.cpp | 10 +- src/modules/clist/clcitems.cpp | 24 +++-- src/modules/clist/clcmsgs.cpp | 20 ++-- src/modules/clist/clcutils.cpp | 25 +++-- src/modules/clist/clistevents.cpp | 60 ++++++------ src/modules/clist/clistmenus.cpp | 90 ++++++++++-------- src/modules/clist/clistsettings.cpp | 17 ++-- src/modules/clist/clisttray.cpp | 180 ++++++++++++++++++------------------ 9 files changed, 242 insertions(+), 197 deletions(-) diff --git a/src/modules/clist/clc.cpp b/src/modules/clist/clc.cpp index 8f44d7bf5e..3c530cff57 100644 --- a/src/modules/clist/clc.cpp +++ b/src/modules/clist/clc.cpp @@ -208,7 +208,7 @@ static void SortClcByTimer(HWND hwnd) int LoadCLCModule(void) { bModuleInitialized = TRUE; - + g_IconWidth = GetSystemMetrics(SM_CXSMICON); g_IconHeight = GetSystemMetrics(SM_CYSMICON); @@ -236,7 +236,7 @@ int LoadCLCModule(void) void UnloadClcModule() { if ( !bModuleInitialized) return; - + UnhookEvent(hAckHook); UnhookEvent(hClcSettingsChanged); @@ -609,7 +609,7 @@ LRESULT CALLBACK fnContactListControlWndProc(HWND hwnd, UINT msg, WPARAM wParam, char *szProto = (char *) CallService(MS_PROTO_GETCONTACTBASEPROTO, wParam, 0); if (szProto == NULL) break; - + WORD apparentMode = DBGetContactSettingWord((HANDLE)wParam, szProto, "ApparentMode", 0); contact->flags &= ~(CONTACTF_INVISTO | CONTACTF_VISTO); if (apparentMode == ID_STATUS_OFFLINE) @@ -634,7 +634,7 @@ LRESULT CALLBACK fnContactListControlWndProc(HWND hwnd, UINT msg, WPARAM wParam, contact->flags &= ~CONTACTF_IDLE; if (db_get_dw((HANDLE)wParam, szProto, "IdleTS", 0)) contact->flags |= CONTACTF_IDLE; - + cli.pfnInvalidateRect(hwnd, NULL, FALSE); } break; @@ -867,7 +867,7 @@ LRESULT CALLBACK fnContactListControlWndProc(HWND hwnd, UINT msg, WPARAM wParam, cli.pfnScrollTo(hwnd, dat, dat->yScroll + dat->dragAutoScrolling * dat->rowHeight * 2, 0); break; case TIMERID_INFOTIP: - { + { CLCINFOTIP it; RECT clRect; POINT ptClientOffset = { 0 }; @@ -935,7 +935,8 @@ LRESULT CALLBACK fnContactListControlWndProc(HWND hwnd, UINT msg, WPARAM wParam, dat->dragStage = DRAGSTAGE_NOTMOVED | DRAGSTAGEF_MAYBERENAME; dat->dragAutoScrolling = 0; break; - } } + } + } if (hit != -1 && contact->type == CLCIT_GROUP) { if (hitFlags & CLCHT_ONITEMICON) { diff --git a/src/modules/clist/clcfiledrop.cpp b/src/modules/clist/clcfiledrop.cpp index 411705f6c8..aedf412c02 100644 --- a/src/modules/clist/clcfiledrop.cpp +++ b/src/modules/clist/clcfiledrop.cpp @@ -33,10 +33,10 @@ struct CDropTarget : IDropTarget ULONG STDMETHODCALLTYPE Release(void); HRESULT STDMETHODCALLTYPE QueryInterface(REFIID iid, void ** ppvObject); - HRESULT STDMETHODCALLTYPE DragEnter(IDataObject *pDataObj, DWORD grfKeyState, POINTL pt, DWORD *pdwEffect); - HRESULT STDMETHODCALLTYPE DragOver(DWORD grfKeyState, POINTL pt, DWORD *pdwEffect); - HRESULT STDMETHODCALLTYPE DragLeave(void); - HRESULT STDMETHODCALLTYPE Drop(IDataObject *pDataObj, DWORD grfKeyState, POINTL pt, DWORD *pdwEffect); + HRESULT STDMETHODCALLTYPE DragEnter(IDataObject *pDataObj, DWORD grfKeyState, POINTL pt, DWORD *pdwEffect); + HRESULT STDMETHODCALLTYPE DragOver(DWORD grfKeyState, POINTL pt, DWORD *pdwEffect); + HRESULT STDMETHODCALLTYPE DragLeave(void); + HRESULT STDMETHODCALLTYPE Drop(IDataObject *pDataObj, DWORD grfKeyState, POINTL pt, DWORD *pdwEffect); } static dropTarget; @@ -79,7 +79,7 @@ static HANDLE HContactFromPoint(HWND hwnd, struct ClcData *dat, int x, int y, in char *szProto = (char *) CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM) contact->hContact, 0); if (szProto == NULL) return NULL; - + DWORD protoCaps = CallProtoServiceInt(NULL,szProto, PS_GETCAPS, PFLAGNUM_1, 0); if ( !(protoCaps & PF1_FILESEND)) return NULL; diff --git a/src/modules/clist/clcitems.cpp b/src/modules/clist/clcitems.cpp index 52cdae7b27..16587acc02 100644 --- a/src/modules/clist/clcitems.cpp +++ b/src/modules/clist/clcitems.cpp @@ -126,7 +126,8 @@ void fnFreeContact(ClcContact* p) cli.pfnFreeGroup(p->group); mir_free(p->group); p->group = NULL; -} } + } +} void fnFreeGroup(ClcGroup *group) { @@ -226,7 +227,7 @@ void fnAddContactToTree(HWND hwnd, struct ClcData *dat, HANDLE hContact, int upd if (szProto != NULL) status = DBGetContactSettingWord(hContact, szProto, "Status", ID_STATUS_OFFLINE); - if ( DBGetContactSettingTString(hContact, "CList", "Group", &dbv)) + if (DBGetContactSettingTString(hContact, "CList", "Group", &dbv)) group = &dat->list; else { group = cli.pfnAddGroup(hwnd, dat, dbv.ptszVal, (DWORD) - 1, 0, 0); @@ -487,7 +488,9 @@ static void InsertionSort(ClcContact **pContactArray, int nArray, int (*CompareP j++; memmove(&pContactArray[j + 1], &pContactArray[j], sizeof(void*) * (i - j)); pContactArray[j] = testElement; -} } } + } + } +} static void SortGroup(struct ClcData *dat, ClcGroup *group, int useInsertionSort) { @@ -497,7 +500,8 @@ static void SortGroup(struct ClcData *dat, ClcGroup *group, int useInsertionSort if (group->cl.items[i]->type == CLCIT_DIVIDER) { mir_free(group->cl.items[i]); List_Remove((SortedList*)&group->cl, i); - } } + } + } for (i=0; i < group->cl.count; i++) if (group->cl.items[i]->type != CLCIT_INFO) @@ -539,7 +543,10 @@ static void SortGroup(struct ClcData *dat, ClcGroup *group, int useInsertionSort lstrcpy(group->cl.items[i]->szText, TranslateT("Offline")); } break; -} } } } + } + } + } +} void fnSortCLC(HWND hwnd, struct ClcData *dat, int useInsertionSort) { @@ -571,8 +578,8 @@ void fnSortCLC(HWND hwnd, struct ClcData *dat, int useInsertionSort) if (hSelItem) if (cli.pfnFindItem(hwnd, dat, hSelItem, &selcontact, &selgroup, NULL)) dat->selection = cli.pfnGetRowsPriorTo(&dat->list, selgroup, List_IndexOf((SortedList*)&selgroup->cl, selcontact)); - - cli.pfnRecalcScrollBar(hwnd, dat); + + cli.pfnRecalcScrollBar(hwnd, dat); } dat->needsResort = 0; cli.pfnInvalidateRect(hwnd, NULL, FALSE); @@ -675,7 +682,8 @@ void fnSaveStateAndRebuildList(HWND hwnd, struct ClcData *dat) memcpy(group->cl.items[group->scanIndex]->iExtraImage, p->iExtraImage, sizeof(p->iExtraImage)); if (p->checked) group->cl.items[group->scanIndex]->flags |= CONTACTF_CHECKED; - } } + } + } group->scanIndex++; } diff --git a/src/modules/clist/clcmsgs.cpp b/src/modules/clist/clcmsgs.cpp index b34eafc52c..d6245b49cb 100644 --- a/src/modules/clist/clcmsgs.cpp +++ b/src/modules/clist/clcmsgs.cpp @@ -232,19 +232,19 @@ LRESULT fnProcessExternalMessages(HWND hwnd, struct ClcData *dat, UINT msg, WPAR return group->groupId | HCONTACT_ISGROUP; case CLGN_NEXT: - do { - if (++i >= group->cl.count) - return NULL; - } - while (group->cl.items[i]->type == CLCIT_DIVIDER); + do { + if (++i >= group->cl.count) + return NULL; + } + while (group->cl.items[i]->type == CLCIT_DIVIDER); return (LRESULT)cli.pfnContactToHItem(group->cl.items[i]); case CLGN_PREVIOUS: - do { - if (--i < 0) - return NULL; - } - while (group->cl.items[i]->type == CLCIT_DIVIDER); + do { + if (--i < 0) + return NULL; + } + while (group->cl.items[i]->type == CLCIT_DIVIDER); return (LRESULT)cli.pfnContactToHItem(group->cl.items[i]); case CLGN_NEXTCONTACT: diff --git a/src/modules/clist/clcutils.cpp b/src/modules/clist/clcutils.cpp index 19367af5ad..a6326e05fa 100644 --- a/src/modules/clist/clcutils.cpp +++ b/src/modules/clist/clcutils.cpp @@ -453,7 +453,8 @@ void fnDeleteFromContactList(HWND hwnd, struct ClcData *dat) case CLCIT_CONTACT: CallService("CList/DeleteContactCommand", (WPARAM)contact->hContact, (LPARAM)hwnd); break; -} } + } +} static WNDPROC OldRenameEditWndProc; static LRESULT CALLBACK RenameEditSubclassProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) @@ -685,7 +686,8 @@ void fnGetDefaultFontSetting(int i, LOGFONT* lf, COLORREF* colour) case FONTID_NOTONLIST: *colour = GetSysColor(COLOR_3DSHADOW); break; -} } + } +} void fnGetFontSetting(int i, LOGFONT* lf, COLORREF* colour) { @@ -721,7 +723,7 @@ void fnGetFontSetting(int i, LOGFONT* lf, COLORREF* colour) void fnLoadClcOptions(HWND hwnd, struct ClcData *dat) { dat->rowHeight = db_get_b(NULL, "CLC", "RowHeight", CLCDEFAULT_ROWHEIGHT); - + LOGFONT lf; SIZE fontSize; @@ -775,7 +777,7 @@ void fnLoadClcOptions(HWND hwnd, struct ClcData *dat) dat->hotTextColour = db_get_dw(NULL, "CLC", "HotTextColour", CLCDEFAULT_HOTTEXTCOLOUR); dat->quickSearchColour = db_get_dw(NULL, "CLC", "QuickSearchColour", CLCDEFAULT_QUICKSEARCHCOLOUR); dat->useWindowsColours = db_get_b(NULL, "CLC", "UseWinColours", CLCDEFAULT_USEWINDOWSCOLOURS); - + NMHDR hdr; hdr.code = CLN_OPTIONSCHANGED; hdr.hwndFrom = hwnd; @@ -856,23 +858,28 @@ void fnInvalidateItem(HWND hwnd, struct ClcData *dat, int iItem) // row coord functions int fnGetRowTopY(struct ClcData *dat, int item) -{ return item * dat->rowHeight; +{ + return item * dat->rowHeight; } int fnGetRowBottomY(struct ClcData *dat, int item) -{ return (item+1) * dat->rowHeight; +{ + return (item+1) * dat->rowHeight; } int fnGetRowTotalHeight(struct ClcData *dat) -{ return dat->rowHeight * cli.pfnGetGroupContentsCount(&dat->list, 1); +{ + return dat->rowHeight * cli.pfnGetGroupContentsCount(&dat->list, 1); } int fnGetRowHeight(struct ClcData *dat, int) -{ return dat->rowHeight; +{ + return dat->rowHeight; } int fnRowHitTest(struct ClcData *dat, int y) -{ if ( !dat->rowHeight) +{ + if ( !dat->rowHeight) return y; return y / dat->rowHeight; } diff --git a/src/modules/clist/clistevents.cpp b/src/modules/clist/clistevents.cpp index f374fbacb5..7dae6a7713 100644 --- a/src/modules/clist/clistevents.cpp +++ b/src/modules/clist/clistevents.cpp @@ -92,11 +92,11 @@ static void ShowEventsInTray() int nTrayCnt = cli.trayIconCount; if ( !cli.events.count || !nTrayCnt) return; if (cli.events.count == 1 || nTrayCnt == 1) - { + { ShowOneEventInTray(0); //for only one icon in tray show topmost event return; } - + // in case if we have several icons in tray and several events with different protocols // lets use several icon to show events from protocols in different icons cli.pfnLockTray(); @@ -104,8 +104,8 @@ static void ShowEventsInTray() nTrayProtoCnt = 0; for (i=0; icle.flags & CLEF_ONLYAFEW) { if (0 >= --cli.events.items[i]->flashesDone) cli.pfnRemoveEvent(cli.events.items[i]->cle.hContact, cli.events.items[i]->cle.hDbEvent); - } } + } + } if (cli.events.count == 0) { KillTimer(NULL, idEvent); @@ -239,7 +240,7 @@ int fnRemoveEvent(HANDLE hContact, HANDLE dbEvent) } if (cli.events.count == 0 || nSameProto == 0) { - if (cli.events.count == 0) + if (cli.events.count == 0) KillTimer(NULL, flashTimerId); cli.pfnTrayIconSetToBase(hContact == NULL ? NULL : szProto); } @@ -277,7 +278,8 @@ int fnEventsProcessContactDoubleClick(HANDLE hContact) CallService(cli.events.items[i]->cle.pszService, (WPARAM) (HWND) NULL, (LPARAM) & cli.events.items[i]->cle); cli.pfnRemoveEvent(hContact, hDbEvent); return 0; - } } + } + } return 1; } @@ -289,34 +291,35 @@ int fnEventsProcessTrayDoubleClick(int index) HANDLE hContact, hDbEvent; int eventIndex = 0; cli.pfnLockTray(); - if (cli.trayIconCount>1 && index>0) { + if (cli.trayIconCount>1 && index>0) { int i; char * szProto = NULL; for (i=0; icle.hContact) eventProto = (char *)CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)cli.events.items[i]->cle.hContact, 0); if ( !eventProto) eventProto = cli.events.items[i]->cle.lpszProtocol; - - if ( !eventProto || !_strcmpi(eventProto, szProto)) { + + if ( !eventProto || !_strcmpi(eventProto, szProto)) { eventIndex = i; break; - } } - + } + } + if (i == cli.events.count) { //EventNotFound //lets process backward try to find first event without desired proto in tray int j; if (click_in_first_icon) for (i=0; icle.hContact) eventProto = (char *)CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)cli.events.items[i]->cle.hContact, 0); if ( !eventProto) @@ -325,17 +328,22 @@ int fnEventsProcessTrayDoubleClick(int index) for (j = 0; jcle.hContact; hDbEvent = cli.events.items[eventIndex]->cle.hDbEvent; //if ( !ServiceExists(cli.events.items[eventIndex]->cle.pszService)) @@ -394,9 +402,9 @@ INT_PTR GetEventStub(WPARAM wParam, LPARAM lParam) { return (INT_PTR)cli.pfnGetE int InitCListEvents(void) { - memset(&cli.events, 0, sizeof(cli.events)); + memset(&cli.events, 0, sizeof(cli.events)); cli.events.increment = 10; - + disableTrayFlash = db_get_b(NULL, "CList", "DisableTrayFlash", 0); disableIconFlash = db_get_b(NULL, "CList", "NoIconBlink", 0); CreateServiceFunction(MS_CLIST_ADDEVENT, AddEventSyncStub); //need to be called through sync to keep flash timer workable @@ -415,10 +423,10 @@ struct CListEvent* fnCreateEvent(void) void fnFreeEvent(struct CListEvent* p) { - if (p->cle.pszService) - mir_free(p->cle.pszService); - if (p->cle.pszTooltip) - mir_free(p->cle.pszTooltip); + if (p->cle.pszService) + mir_free(p->cle.pszService); + if (p->cle.pszTooltip) + mir_free(p->cle.pszTooltip); mir_free(p); } diff --git a/src/modules/clist/clistmenus.cpp b/src/modules/clist/clistmenus.cpp index eae1b44499..094baafc67 100644 --- a/src/modules/clist/clistmenus.cpp +++ b/src/modules/clist/clistmenus.cpp @@ -174,11 +174,11 @@ int GetAverageMode(int* pNetProtoCount = NULL) averageMode = CallProtoServiceInt(NULL,pa->szModuleName, PS_GETSTATUS, 0, 0); else if (averageMode > 0 && averageMode != CallProtoServiceInt(NULL,pa->szModuleName, PS_GETSTATUS, 0, 0)) { averageMode = -1; - if (pNetProtoCount == NULL) break; - } - } + if (pNetProtoCount == NULL) break; + } + } - if (pNetProtoCount) *pNetProtoCount = netProtoCount; + if (pNetProtoCount) *pNetProtoCount = netProtoCount; return averageMode; } @@ -431,7 +431,9 @@ BOOL FindMenuHandleByGlobalID(HMENU hMenu, PMO_IntMenuItem id, MenuItemData* itd itdat->OwnerMenu = hMenu; itdat->position = i; return TRUE; - } } } + } + } + } return FALSE; } @@ -507,7 +509,9 @@ INT_PTR StatusMenuCheckService(WPARAM wParam, LPARAM) timiParent->iconId = timi->iconId; if (timiParent->hBmp) DeleteObject(timiParent->hBmp); timiParent->hBmp = NULL; - } } } + } + } + } } else if (smep && smep->status && !smep->custom) { int curProtoStatus = (smep->proto) ? CallProtoServiceInt(NULL,smep->proto, PS_GETSTATUS, 0, 0) : GetAverageMode(); @@ -552,7 +556,8 @@ INT_PTR StatusMenuCheckService(WPARAM wParam, LPARAM) timi->mi.hIcon = NULL; } else IcoLib_ReleaseIcon(timi->mi.hIcon, 0); - } } + } + } return TRUE; } @@ -605,27 +610,29 @@ INT_PTR StatusMenuExecService(WPARAM wParam, LPARAM) NotifyEventHooks(hStatusModeChangeEvent, smep->status, (LPARAM)smep->proto); } else { - int MenusProtoCount = 0; + int MenusProtoCount = 0; - for (int i=0; i < accounts.getCount(); i++) - if (cli.pfnGetProtocolVisibility(accounts[i]->szModuleName)) - MenusProtoCount++; + for (int i=0; i < accounts.getCount(); i++) + if (cli.pfnGetProtocolVisibility(accounts[i]->szModuleName)) + MenusProtoCount++; - cli.currentDesiredStatusMode = smep->status; + cli.currentDesiredStatusMode = smep->status; - for (int j=0; j < accounts.getCount(); j++) { - PROTOACCOUNT* pa = accounts[j]; - if ( !Proto_IsAccountEnabled(pa)) - continue; - if (MenusProtoCount > 1 && Proto_IsAccountLocked(pa)) - continue; + for (int j=0; j < accounts.getCount(); j++) { + PROTOACCOUNT* pa = accounts[j]; + if ( !Proto_IsAccountEnabled(pa)) + continue; + if (MenusProtoCount > 1 && Proto_IsAccountLocked(pa)) + continue; Proto_SetStatus(pa->szModuleName, cli.currentDesiredStatusMode); - } - NotifyEventHooks(hStatusModeChangeEvent, cli.currentDesiredStatusMode, 0); - DBWriteContactSettingWord(NULL, "CList", "Status", (WORD)cli.currentDesiredStatusMode); + } + NotifyEventHooks(hStatusModeChangeEvent, cli.currentDesiredStatusMode, 0); + DBWriteContactSettingWord(NULL, "CList", "Status", (WORD)cli.currentDesiredStatusMode); return 1; - } } } + } + } + } return 0; } @@ -666,7 +673,8 @@ INT_PTR MenuProcessCommand(WPARAM wParam, LPARAM lParam) int pos = statustopos(hst); if (pos != -1 && hStatusMainMenuHandles != NULL) return MO_ProcessCommand(hStatusMainMenuHandles[ pos ], lParam); - } } + } + } if ( !(cmd >= CLISTMENUIDMIN && cmd <= CLISTMENUIDMAX)) return 0; // DO NOT process ids outside from clist menu id range v0.7.0.27+ @@ -707,22 +715,24 @@ BOOL FindMenuHanleByGlobalID(HMENU hMenu, PMO_IntMenuItem id, MenuItemData* itda itdat->OwnerMenu = hMenu; itdat->position = i; return TRUE; - } } } + } + } + } return FALSE; } static INT_PTR MenuProcessHotkey(WPARAM vKey, LPARAM) { - prochotkey = true; + prochotkey = true; - bool res = - MO_ProcessHotKeys(hStatusMenuObject, vKey) || - MO_ProcessHotKeys(hMainMenuObject, vKey); + bool res = + MO_ProcessHotKeys(hStatusMenuObject, vKey) || + MO_ProcessHotKeys(hMainMenuObject, vKey); - prochotkey = false; + prochotkey = false; - return res; + return res; } static int MenuIconsChanged(WPARAM, LPARAM) @@ -784,7 +794,7 @@ int fnGetProtocolVisibility(const char* accName) if (accName) { PROTOACCOUNT* pa = Proto_GetAccount(accName); return pa && pa->bIsVisible && Proto_IsAccountEnabled(pa) && - pa->ppro && (pa->ppro->GetCaps(PFLAGNUM_2, 0) & ~pa->ppro->GetCaps(PFLAGNUM_5, 0)); + pa->ppro && (pa->ppro->GetCaps(PFLAGNUM_2, 0) & ~pa->ppro->GetCaps(PFLAGNUM_5, 0)); } return FALSE; @@ -802,7 +812,8 @@ int fnGetProtoIndexByPos(PROTOCOLDESCRIPTOR ** proto, int protoCnt, int Pos) if (lstrcmpA(proto[p]->szName, dbv.pszVal) == 0) { DBFreeVariant(&dbv); return p; - } } + } + } DBFreeVariant(&dbv); } @@ -963,7 +974,8 @@ void RebuildMenuOrder(void) MO_SetOptionsMenuItem(hStatusMenuHandles[i].menuhandle[j], OPT_MENUITEMSETUNIQNAME, (INT_PTR)buf); } IcoLib_ReleaseIcon(tmi.hIcon, 0); - } } + } + } NotifyEventHooks(cli.hPreBuildStatusMenuEvent, 0, 0); int pos = 200000; @@ -1013,7 +1025,8 @@ void RebuildMenuOrder(void) } IcoLib_ReleaseIcon(tmi.hIcon, 0); break; - } } + } + } BuildStatusMenu(0, 0); } @@ -1104,7 +1117,8 @@ static int MenuProtoAck(WPARAM, LPARAM lParam) for (pos = 0; pos < SIZEOF(statusModeList); pos++) { tmi.flags = CMIM_FLAGS | CMIF_ROOTHANDLE; MO_ModifyMenuItem(hStatusMenuHandles[i].menuhandle[pos], &tmi); - } } + } + } if (ack->lParam >= ID_STATUS_OFFLINE && ack->lParam < ID_STATUS_OFFLINE + SIZEOF(statusModeList)) { int pos = statustopos((int)ack->lParam); @@ -1114,7 +1128,8 @@ static int MenuProtoAck(WPARAM, LPARAM lParam) } } break; - } } + } + } //BuildStatusMenu(0, 0); return 0; @@ -1204,7 +1219,8 @@ static INT_PTR AddStatusMenuItem(WPARAM wParam, LPARAM lParam) tmi.flags |= CMIF_ROOTHANDLE; tmi.root = pRoot; - } } + } + } if (wParam) { int * res = (int*)wParam; diff --git a/src/modules/clist/clistsettings.cpp b/src/modules/clist/clistsettings.cpp index 4535781588..00b85a2194 100644 --- a/src/modules/clist/clistsettings.cpp +++ b/src/modules/clist/clistsettings.cpp @@ -48,7 +48,8 @@ void FreeDisplayNameCache(void) List_Destroy(clistCache); mir_free(clistCache); clistCache = NULL; -} } + } +} // default handlers for the cache item creation and destruction @@ -111,7 +112,8 @@ void fnInvalidateDisplayNameCacheEntry(HANDLE hContact) int idx; if (List_GetIndex(clistCache, &hContact, &idx)) cli.pfnFreeCacheItem((ClcCacheEntry*)clistCache->items[idx]); -} } + } +} TCHAR* fnGetContactDisplayName(HANDLE hContact, int mode) { @@ -145,7 +147,8 @@ TCHAR* fnGetContactDisplayName(HANDLE hContact, int mode) if (cacheEntry != NULL) cacheEntry->tszName = buffer; return buffer; - } } + } + } CallContactService(hContact, PSS_GETINFO, SGIF_MINIMAL, 0); TCHAR *buffer = TranslateT("(Unknown Contact)"); @@ -184,7 +187,7 @@ INT_PTR GetContactDisplayName(WPARAM wParam, LPARAM lParam) mir_free(ci.pszVal); return (INT_PTR)mir_strdup(retVal); } - + cacheEntry->tszName = ci.pszVal; return (INT_PTR)retVal; } @@ -260,7 +263,8 @@ int ContactSettingChanged(WPARAM wParam, LPARAM lParam) return 0; } cli.pfnSortContacts(); - } } + } + } if ( !strcmp(cws->szModule, "CList")) { if ( !strcmp(cws->szSetting, "Hidden")) { @@ -286,7 +290,8 @@ int ContactSettingChanged(WPARAM wParam, LPARAM lParam) cli.pfnIconFromStatusMode(szProto, szProto == NULL ? ID_STATUS_OFFLINE : DBGetContactSettingWord(hContact, szProto, "Status", ID_STATUS_OFFLINE), hContact), 0); - } } + } + } // Clean up if (dbv.pszVal) diff --git a/src/modules/clist/clisttray.cpp b/src/modules/clist/clisttray.cpp index e2833d27fc..65ca28a352 100644 --- a/src/modules/clist/clisttray.cpp +++ b/src/modules/clist/clisttray.cpp @@ -66,7 +66,10 @@ static TCHAR* sttGetXStatus(const char* szProto) if (dbv.ptszVal[0] != 0) result = mir_tstrdup(dbv.ptszVal); DBFreeVariant(&dbv); - } } } } + } + } + } + } return result; } @@ -151,7 +154,7 @@ TCHAR* fnTrayIconMakeTooltip(const TCHAR *szPrefix, const char *szProto) _tcsncat(cli.szTip, szStatus, MAX_TIP_SIZE - _tcslen(cli.szTip)); } mir_free(ProtoXStatus); - } + } } else { if ((pa = Proto_GetAccount(szProto)) != NULL) { @@ -179,7 +182,8 @@ TCHAR* fnTrayIconMakeTooltip(const TCHAR *szPrefix, const char *szProto) else mir_sntprintf(cli.szTip, MAX_TIP_SIZE, _T("%s %s"), pa->tszAccountName, szStatus); } mir_free(ProtoXStatus); - } } + } + } ulock; return cli.szTip; @@ -220,7 +224,8 @@ int fnTrayIconAdd(HWND hwnd, const char *szProto, const char *szIconProto, int s if (cli.trayIconCount == 1) SetTaskBarIcon(cli.trayIcon[0].hBaseIcon, cli.szTip); - ulock; return i; + ulock; + return i; } void fnTrayIconRemove(HWND hwnd, const char *szProto) @@ -241,7 +246,8 @@ void fnTrayIconRemove(HWND hwnd, const char *szProto) mir_free(pii->ptszToolTip); pii->ptszToolTip = NULL; pii->id = 0; break; - } } + } + } if (cli.trayIconCount == 1) SetTaskBarIcon(NULL, NULL); @@ -251,11 +257,11 @@ void fnTrayIconRemove(HWND hwnd, const char *szProto) int fnTrayIconInit(HWND hwnd) { - int netProtoCount = 0; + int netProtoCount = 0; initcheck 0; lock; - int averageMode = GetAverageMode(&netProtoCount); + int averageMode = GetAverageMode(&netProtoCount); mToolTipTrayTips = ServiceExists("mToolTip/ShowTip") != 0; if (cli.cycleTimerId) { @@ -265,56 +271,50 @@ int fnTrayIconInit(HWND hwnd) cli.trayIconCount = 1; - if (netProtoCount) - { - cli.trayIcon = (trayIconInfo_t *) mir_calloc(sizeof(trayIconInfo_t) * accounts.getCount()); - - int trayIconSetting = db_get_b(NULL, "CList", "TrayIcon", SETTING_TRAYICON_DEFAULT); - - if (trayIconSetting == SETTING_TRAYICON_SINGLE) - { - DBVARIANT dbv = { DBVT_DELETED }; - char *szProto; - if ( !DBGetContactSettingString(NULL, "CList", "PrimaryStatus", &dbv) - && (averageMode < 0 || db_get_b(NULL, "CList", "AlwaysPrimary", 0))) - szProto = dbv.pszVal; - else - szProto = NULL; - - cli.pfnTrayIconAdd(hwnd, NULL, szProto, szProto ? CallProtoServiceInt(NULL,szProto, PS_GETSTATUS, 0, 0) : CallService(MS_CLIST_GETSTATUSMODE, 0, 0)); - DBFreeVariant(&dbv); - } - else if (trayIconSetting == SETTING_TRAYICON_MULTI && - (averageMode < 0 || db_get_b(NULL, "CList", "AlwaysMulti", SETTING_ALWAYSMULTI_DEFAULT))) - { + if (netProtoCount) { + cli.trayIcon = (trayIconInfo_t *) mir_calloc(sizeof(trayIconInfo_t) * accounts.getCount()); + + int trayIconSetting = db_get_b(NULL, "CList", "TrayIcon", SETTING_TRAYICON_DEFAULT); + + if (trayIconSetting == SETTING_TRAYICON_SINGLE) { + DBVARIANT dbv = { DBVT_DELETED }; + char *szProto; + if ( !DBGetContactSettingString(NULL, "CList", "PrimaryStatus", &dbv) + && (averageMode < 0 || db_get_b(NULL, "CList", "AlwaysPrimary", 0))) + szProto = dbv.pszVal; + else + szProto = NULL; + + cli.pfnTrayIconAdd(hwnd, NULL, szProto, szProto ? CallProtoServiceInt(NULL,szProto, PS_GETSTATUS, 0, 0) : CallService(MS_CLIST_GETSTATUSMODE, 0, 0)); + DBFreeVariant(&dbv); + } + else if (trayIconSetting == SETTING_TRAYICON_MULTI && + (averageMode < 0 || db_get_b(NULL, "CList", "AlwaysMulti", SETTING_ALWAYSMULTI_DEFAULT))) + { cli.trayIconCount = netProtoCount; - for (int i=0; i < accounts.getCount(); i++) - { - int j = cli.pfnGetAccountIndexByPos(i); - if (j >= 0) - { - PROTOACCOUNT* pa = accounts[j]; - if (cli.pfnGetProtocolVisibility(pa->szModuleName)) - cli.pfnTrayIconAdd(hwnd, pa->szModuleName, NULL, CallProtoServiceInt(NULL,pa->szModuleName, PS_GETSTATUS, 0, 0)); - } - } - } - else - { - cli.pfnTrayIconAdd(hwnd, NULL, NULL, averageMode); - - if (trayIconSetting == SETTING_TRAYICON_CYCLE && averageMode < 0) - cli.cycleTimerId = SetTimer(NULL, 0, DBGetContactSettingWord(NULL, "CList", "CycleTime", SETTING_CYCLETIME_DEFAULT) * 1000, cli.pfnTrayCycleTimerProc); - } - } - else - { - cli.trayIcon = (trayIconInfo_t *) mir_calloc(sizeof(trayIconInfo_t)); - cli.pfnTrayIconAdd(hwnd, NULL, NULL, CallService(MS_CLIST_GETSTATUSMODE, 0, 0)); - } - - ulock; - return 0; + for (int i=0; i < accounts.getCount(); i++) { + int j = cli.pfnGetAccountIndexByPos(i); + if (j >= 0) { + PROTOACCOUNT* pa = accounts[j]; + if (cli.pfnGetProtocolVisibility(pa->szModuleName)) + cli.pfnTrayIconAdd(hwnd, pa->szModuleName, NULL, CallProtoServiceInt(NULL,pa->szModuleName, PS_GETSTATUS, 0, 0)); + } + } + } + else { + cli.pfnTrayIconAdd(hwnd, NULL, NULL, averageMode); + + if (trayIconSetting == SETTING_TRAYICON_CYCLE && averageMode < 0) + cli.cycleTimerId = SetTimer(NULL, 0, DBGetContactSettingWord(NULL, "CList", "CycleTime", SETTING_CYCLETIME_DEFAULT) * 1000, cli.pfnTrayCycleTimerProc); + } + } + else { + cli.trayIcon = (trayIconInfo_t *) mir_calloc(sizeof(trayIconInfo_t)); + cli.pfnTrayIconAdd(hwnd, NULL, NULL, CallService(MS_CLIST_GETSTATUSMODE, 0, 0)); + } + + ulock; + return 0; } int fnTrayIconDestroy(HWND hwnd) @@ -342,7 +342,7 @@ int fnTrayIconDestroy(HWND hwnd) cli.trayIconCount = 0; ulock; - return 0; + return 0; } //called when Explorer crashes and the taskbar is remade @@ -422,8 +422,7 @@ int fnTrayIconUpdate(HICON hNewIcon, const TCHAR *szNewTip, const char *szPrefer SetTaskBarIcon(NULL, NULL); cli.trayIcon[i].isBase = isBase; - if (db_get_b(NULL, "CList", "TrayIcon", SETTING_TRAYICON_DEFAULT) == SETTING_TRAYICON_MULTI) - { + if (db_get_b(NULL, "CList", "TrayIcon", SETTING_TRAYICON_DEFAULT) == SETTING_TRAYICON_MULTI) { DWORD time1 = DBGetContactSettingWord(NULL, "CList", "CycleTime", SETTING_CYCLETIME_DEFAULT)*200; DWORD time2 = DBGetContactSettingWord(NULL, "CList", "IconFlashTime", 550)+1000; DWORD time = max(max(2000, time1), time2); @@ -454,9 +453,9 @@ int fnTrayIconSetBaseInfo(HICON hIcon, const char *szPreferredProto) ulock; return i; } if ((cli.pfnGetProtocolVisibility(szPreferredProto)) - && (GetAverageMode() == -1) - && (db_get_b(NULL, "CList", "TrayIcon", SETTING_TRAYICON_DEFAULT) == SETTING_TRAYICON_MULTI) - && !(db_get_b(NULL, "CList", "AlwaysMulti", SETTING_ALWAYSMULTI_DEFAULT))) + && (GetAverageMode() == -1) + && (db_get_b(NULL, "CList", "TrayIcon", SETTING_TRAYICON_DEFAULT) == SETTING_TRAYICON_MULTI) + && !(db_get_b(NULL, "CList", "AlwaysMulti", SETTING_ALWAYSMULTI_DEFAULT))) goto LBL_Error; } @@ -487,23 +486,22 @@ VOID CALLBACK fnTrayCycleTimerProc(HWND, UINT, UINT_PTR, DWORD) initcheck; lock; - int i; - for (i = accounts.getCount() + 1; --i;) { - cycleStep = (cycleStep + 1) % accounts.getCount(); - if (cli.pfnGetProtocolVisibility(accounts[cycleStep]->szModuleName)) - break; - } - - if (i) - { - DestroyIcon(cli.trayIcon[0].hBaseIcon); - cli.trayIcon[0].hBaseIcon = cli.pfnGetIconFromStatusMode(NULL, accounts[cycleStep]->szModuleName, - CallProtoServiceInt(NULL,accounts[cycleStep]->szModuleName, PS_GETSTATUS, 0, 0)); - if (cli.trayIcon[0].isBase) - cli.pfnTrayIconUpdate(cli.trayIcon[0].hBaseIcon, NULL, NULL, 1); - } - - ulock; + int i; + for (i = accounts.getCount() + 1; --i;) { + cycleStep = (cycleStep + 1) % accounts.getCount(); + if (cli.pfnGetProtocolVisibility(accounts[cycleStep]->szModuleName)) + break; + } + + if (i) { + DestroyIcon(cli.trayIcon[0].hBaseIcon); + cli.trayIcon[0].hBaseIcon = cli.pfnGetIconFromStatusMode(NULL, accounts[cycleStep]->szModuleName, + CallProtoServiceInt(NULL,accounts[cycleStep]->szModuleName, PS_GETSTATUS, 0, 0)); + if (cli.trayIcon[0].isBase) + cli.pfnTrayIconUpdate(cli.trayIcon[0].hBaseIcon, NULL, NULL, 1); + } + + ulock; } void fnTrayIconUpdateBase(const char *szChangedProto) @@ -516,7 +514,7 @@ void fnTrayIconUpdateBase(const char *szChangedProto) lock; int averageMode = GetAverageMode(&netProtoCount); - if (cli.cycleTimerId) { + if (cli.cycleTimerId) { KillTimer(NULL, cli.cycleTimerId); cli.cycleTimerId = 0; } @@ -525,10 +523,9 @@ void fnTrayIconUpdateBase(const char *szChangedProto) if ( !lstrcmpA(szChangedProto, accounts[i]->szModuleName)) cycleStep = i - 1; } - - if (netProtoCount > 0) - { - int trayIconSetting = db_get_b(NULL, "CList", "TrayIcon", SETTING_TRAYICON_DEFAULT); + + if (netProtoCount > 0) { + int trayIconSetting = db_get_b(NULL, "CList", "TrayIcon", SETTING_TRAYICON_DEFAULT); if (averageMode > 0) { if (trayIconSetting == SETTING_TRAYICON_MULTI) { @@ -594,7 +591,7 @@ void fnTrayIconSetToBase(char *szPreferredProto) int i; initcheck; lock; - + for (i=0; i < cli.trayIconCount; i++) { if (cli.trayIcon[i].id == 0) continue; @@ -693,15 +690,16 @@ static void CALLBACK TrayToolTipTimerProc(HWND hwnd, UINT, UINT_PTR id, DWORD) ti.cbSize = sizeof(ti); ti.isTreeFocused = GetFocus() == cli.hwndContactList ? 1 : 0; if (CallService("mToolTip/ShowTipW", (WPARAM)szTipCur, (LPARAM)&ti) == CALLSERVICE_NOTFOUND) - { + { char* p = mir_u2a(szTipCur); - CallService("mToolTip/ShowTip", (WPARAM)p, (LPARAM)&ti); + CallService("mToolTip/ShowTip", (WPARAM)p, (LPARAM)&ti); mir_free(p); } GetCursorPos(&tray_hover_pos); SetTimer(cli.hwndContactList, TIMERID_TRAYHOVER_2, 600, TrayHideToolTipTimerProc); g_trayTooltipActive = TRUE; - } } + } + } KillTimer(hwnd, id); } @@ -876,7 +874,8 @@ int fnCListTrayNotify(MIRANDASYSTRAYNOTIFY* msn) else if (cli.trayIcon[j].isBase) { iconId = cli.trayIcon[j].id; break; - } } + } + } } else iconId = cli.trayIcon[0].id; @@ -907,7 +906,8 @@ int fnCListTrayNotify(MIRANDASYSTRAYNOTIFY* msn) nid.uTimeout = msn->uTimeout; nid.dwInfoFlags = msn->dwInfoFlags; return Shell_NotifyIconA(NIM_MODIFY, &nid) == 0; -} } + } +} ///////////////////////////////////////////////////////////////////////////////////////// -- cgit v1.2.3