diff options
author | George Hazan <george.hazan@gmail.com> | 2014-12-05 15:06:15 +0000 |
---|---|---|
committer | George Hazan <george.hazan@gmail.com> | 2014-12-05 15:06:15 +0000 |
commit | 7c3775ae24f772f37ee69632f11292bd59ebccd2 (patch) | |
tree | 2f8fa62167b13207986f564cea10e12f3d0f5939 /src | |
parent | ae10177eb1e515eada4aa2b4295aab02d1f7c176 (diff) |
useless function removed
git-svn-id: http://svn.miranda-ng.org/main/trunk@11252 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'src')
-rw-r--r-- | src/modules/clist/clc.h | 4 | ||||
-rw-r--r-- | src/modules/clist/clistcore.cpp | 2 | ||||
-rw-r--r-- | src/modules/clist/clistevents.cpp | 129 | ||||
-rw-r--r-- | src/modules/clist/clisttray.cpp | 36 |
4 files changed, 77 insertions, 94 deletions
diff --git a/src/modules/clist/clc.h b/src/modules/clist/clc.h index 35c3a4b004..19002bdf59 100644 --- a/src/modules/clist/clc.h +++ b/src/modules/clist/clc.h @@ -157,10 +157,10 @@ TCHAR* fnGetStatusModeDescription(int wParam, int lParam); int fnGetWindowVisibleState(HWND hWnd, int iStepX, int iStepY);
/* clisttray.c */
+extern mir_cs trayLockCS;
+
void fnInitTray(void);
void fnUninitTray(void);
-void fnLockTray(void);
-void fnUnlockTray(void);
int fnCListTrayNotify(MIRANDASYSTRAYNOTIFY *msn);
int fnTrayIconAdd(HWND hwnd, const char *szProto, const char *szIconProto, int status);
int fnTrayIconDestroy(HWND hwnd);
diff --git a/src/modules/clist/clistcore.cpp b/src/modules/clist/clistcore.cpp index 156f1149f7..b5970a7627 100644 --- a/src/modules/clist/clistcore.cpp +++ b/src/modules/clist/clistcore.cpp @@ -154,8 +154,6 @@ static INT_PTR srvRetrieveInterface(WPARAM, LPARAM) cli.szTip = szTip;
cli.pfnInitTray = fnInitTray;
cli.pfnUninitTray = fnUninitTray;
- cli.pfnLockTray = fnLockTray;
- cli.pfnUnlockTray = fnUnlockTray;
cli.pfnTrayCycleTimerProc = fnTrayCycleTimerProc;
cli.pfnTrayIconAdd = fnTrayIconAdd;
diff --git a/src/modules/clist/clistevents.cpp b/src/modules/clist/clistevents.cpp index 92397503c9..7968fb4a43 100644 --- a/src/modules/clist/clistevents.cpp +++ b/src/modules/clist/clistevents.cpp @@ -89,13 +89,12 @@ static void ShowEventsInTray() // 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();
+ mir_cslock lck(trayLockCS);
char **pTrayProtos = (char**)_alloca(sizeof(char*)*cli.trayIconCount);
int nTrayProtoCnt = 0;
- for (int i = 0; i < cli.trayIconCount; i++) {
- if (cli.trayIcon[i].id == 0 || !cli.trayIcon[i].szProto) continue;
- pTrayProtos[nTrayProtoCnt++] = cli.trayIcon[i].szProto;
- }
+ for (int i = 0; i < cli.trayIconCount; i++)
+ if (cli.trayIcon[i].id != 0 && cli.trayIcon[i].szProto)
+ pTrayProtos[nTrayProtoCnt++] = cli.trayIcon[i].szProto;
for (int i = 0; i < cli.events.count; i++) {
char *iEventProto = GetEventProtocol(i);
@@ -110,7 +109,6 @@ static void ShowEventsInTray() ShowOneEventInTray(i); // show it
pTrayProtos[j] = NULL; // and clear slot
}
- cli.pfnUnlockTray();
}
static VOID CALLBACK IconFlashTimer(HWND, UINT, UINT_PTR idEvent, DWORD)
@@ -255,7 +253,7 @@ CLISTEVENT* fnGetEvent(MCONTACT hContact, int idx) int fnEventsProcessContactDoubleClick(MCONTACT hContact)
{
- for (int i=0; i < cli.events.count; i++) {
+ for (int i = 0; i < cli.events.count; i++) {
if (cli.events.items[i]->cle.hContact == hContact) {
HANDLE hDbEvent = cli.events.items[i]->cle.hDbEvent;
CallService(cli.events.items[i]->cle.pszService, (WPARAM)(HWND)NULL, (LPARAM)& cli.events.items[i]->cle);
@@ -270,72 +268,73 @@ int fnEventsProcessContactDoubleClick(MCONTACT hContact) int fnEventsProcessTrayDoubleClick(int index)
{
BOOL click_in_first_icon = FALSE;
- if (cli.events.count) {
- MCONTACT hContact;
- HANDLE hDbEvent;
- int eventIndex = 0;
- cli.pfnLockTray();
- if (cli.trayIconCount > 1 && index > 0) {
- int i;
- char *szProto = NULL;
- for (i = 0; i < cli.trayIconCount; i++)
- if (cli.trayIcon[i].id == index) {
- szProto = cli.trayIcon[i].szProto;
- if (i == 0) click_in_first_icon = TRUE;
+ if (cli.events.count == 0)
+ return 1;
+
+ int eventIndex = 0;
+
+ mir_cslockfull lck(trayLockCS);
+ if (cli.trayIconCount > 1 && index > 0) {
+ int i;
+ char *szProto = NULL;
+ for (i = 0; i < cli.trayIconCount; i++) {
+ if (cli.trayIcon[i].id == index) {
+ szProto = cli.trayIcon[i].szProto;
+ if (i == 0)
+ click_in_first_icon = TRUE;
+ break;
+ }
+ }
+ if (szProto) {
+ for (i = 0; i < cli.events.count; i++) {
+ char *eventProto = NULL;
+ if (cli.events.items[i]->cle.hContact)
+ eventProto = GetContactProto(cli.events.items[i]->cle.hContact);
+ if (!eventProto)
+ eventProto = cli.events.items[i]->cle.lpszProtocol;
+
+ if (!eventProto || !_strcmpi(eventProto, szProto)) {
+ eventIndex = i;
break;
}
- if (szProto) {
- for (i = 0; i < cli.events.count; i++) {
- char * eventProto = NULL;
- if (cli.events.items[i]->cle.hContact)
- eventProto = GetContactProto(cli.events.items[i]->cle.hContact);
- if (!eventProto)
- eventProto = cli.events.items[i]->cle.lpszProtocol;
-
- 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; i < cli.events.count; i++) {
- char *eventProto = NULL;
- if (cli.events.items[i]->cle.hContact)
- eventProto = GetContactProto(cli.events.items[i]->cle.hContact);
- if (!eventProto)
- eventProto = cli.events.items[i]->cle.lpszProtocol;
- if (eventProto) {
- for (j = 0; j < cli.trayIconCount; j++)
- if (cli.trayIcon[j].szProto && !_strcmpi(eventProto, cli.trayIcon[j].szProto))
- break;
-
- if (j == cli.trayIconCount) {
- eventIndex = i;
- break;
- }
- }
+ // let's process backward try to find first event without desired proto in tray
+ if (i == cli.events.count) {
+ if (click_in_first_icon) {
+ for (i = 0; i < cli.events.count; i++) {
+ char *eventProto = NULL;
+ if (cli.events.items[i]->cle.hContact)
+ eventProto = GetContactProto(cli.events.items[i]->cle.hContact);
+ if (!eventProto)
+ eventProto = cli.events.items[i]->cle.lpszProtocol;
+ if (!eventProto)
+ continue;
+
+ int j;
+ for (j = 0; j < cli.trayIconCount; j++)
+ if (cli.trayIcon[j].szProto && !_strcmpi(eventProto, cli.trayIcon[j].szProto))
+ break;
+
+ if (j == cli.trayIconCount) {
+ eventIndex = i;
+ break;
}
- if (i == cli.events.count) { //not found
- cli.pfnUnlockTray();
- return 1; //continue processing to show contact list
}
}
+ if (i == cli.events.count) //not found
+ return 1; //continue processing to show contact list
}
}
-
- cli.pfnUnlockTray();
- hContact = cli.events.items[eventIndex]->cle.hContact;
- hDbEvent = cli.events.items[eventIndex]->cle.hDbEvent;
- // ; may be better to show send msg?
- CallService(cli.events.items[eventIndex]->cle.pszService, (WPARAM)NULL, (LPARAM)& cli.events.items[eventIndex]->cle);
- cli.pfnRemoveEvent(hContact, hDbEvent);
- return 0;
}
- return 1;
+ lck.unlock();
+
+ MCONTACT hContact = cli.events.items[eventIndex]->cle.hContact;
+ HANDLE hDbEvent = cli.events.items[eventIndex]->cle.hDbEvent;
+ // ; may be better to show send msg?
+ CallService(cli.events.items[eventIndex]->cle.pszService, 0, (LPARAM)& cli.events.items[eventIndex]->cle);
+ cli.pfnRemoveEvent(hContact, hDbEvent);
+ return 0;
}
static int RemoveEventsForContact(WPARAM wParam, LPARAM)
@@ -403,7 +402,7 @@ CListEvent* fnCreateEvent(void) return (CListEvent*)mir_calloc(sizeof(CListEvent));
}
-void fnFreeEvent(CListEvent* p)
+void fnFreeEvent(CListEvent *p)
{
mir_free(p->cle.pszService);
mir_free(p->cle.pszTooltip);
diff --git a/src/modules/clist/clisttray.cpp b/src/modules/clist/clisttray.cpp index 2bfbb8906d..9144a1c694 100644 --- a/src/modules/clist/clisttray.cpp +++ b/src/modules/clist/clisttray.cpp @@ -33,7 +33,8 @@ static UINT WM_TASKBARCREATED; static UINT WM_TASKBARBUTTONCREATED;
static BOOL mToolTipTrayTips = FALSE;
static UINT_PTR RefreshTimerId = 0; /////by FYR
-static CRITICAL_SECTION trayLockCS;
+
+mir_cs trayLockCS;
// don't move to win2k.h, need new and old versions to work on 9x/2000/XP
#define NIF_STATE 0x00000008
@@ -47,18 +48,16 @@ static BOOL fTrayInited = FALSE; static TCHAR* sttGetXStatus(const char *szProto)
{
- TCHAR* result = NULL;
-
- if (CallProtoServiceInt(NULL,szProto, PS_GETSTATUS, 0, 0) > ID_STATUS_OFFLINE) {
+ if (CallProtoServiceInt(NULL, szProto, PS_GETSTATUS, 0, 0) > ID_STATUS_OFFLINE) {
TCHAR tszStatus[512];
CUSTOM_STATUS cs = { sizeof(cs) };
cs.flags = CSSF_MASK_MESSAGE | CSSF_TCHAR;
cs.ptszMessage = tszStatus;
- if ( CallProtoServiceInt(NULL, szProto, PS_GETCUSTOMSTATUSEX, 0, (LPARAM)&cs) == 0)
- result = mir_tstrdup(tszStatus);
+ if (CallProtoServiceInt(NULL, szProto, PS_GETCUSTOMSTATUSEX, 0, (LPARAM)&cs) == 0)
+ return mir_tstrdup(tszStatus);
}
- return result;
+ return NULL;
}
static HICON lastTaskBarIcon;
@@ -391,7 +390,7 @@ int fnTrayIconUpdate(HICON hNewIcon, const TCHAR *szNewTip, const char *szPrefer int fnTrayIconSetBaseInfo(HICON hIcon, const char *szPreferredProto)
{
if (!fTrayInited) {
-LBL_Error:
+ LBL_Error:
DestroyIcon(hIcon);
return -1;
}
@@ -410,9 +409,9 @@ LBL_Error: return i;
}
if ((cli.pfnGetProtocolVisibility(szPreferredProto)) &&
- (cli.pfnGetAverageMode(NULL) == -1) &&
- (db_get_b(NULL, "CList", "TrayIcon", SETTING_TRAYICON_DEFAULT) == SETTING_TRAYICON_MULTI) &&
- !(db_get_b(NULL, "CList", "AlwaysMulti", SETTING_ALWAYSMULTI_DEFAULT)))
+ (cli.pfnGetAverageMode(NULL) == -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;
}
@@ -860,7 +859,7 @@ void fnInitTray(void) }
FreeLibrary(hLib);
}
- InitializeCriticalSection(&trayLockCS);
+
if (cli.shellVersion >= 5)
CreateServiceFunction(MS_CLIST_SYSTRAY_NOTIFY, pfnCListTrayNotifyStub);
fTrayInited = TRUE;
@@ -869,19 +868,6 @@ void fnInitTray(void) void fnUninitTray(void)
{
fTrayInited = FALSE;
- DeleteCriticalSection(&trayLockCS);
-}
-
-void fnLockTray(void)
-{
- initcheck;
- EnterCriticalSection(&trayLockCS);
-}
-
-void fnUnlockTray(void)
-{
- initcheck;
- LeaveCriticalSection(&trayLockCS);
}
#undef initcheck
|