diff options
author | George Hazan <george.hazan@gmail.com> | 2014-01-02 15:32:39 +0000 |
---|---|---|
committer | George Hazan <george.hazan@gmail.com> | 2014-01-02 15:32:39 +0000 |
commit | 468976464c267ab9f7aa5964d1479c7d909a54a4 (patch) | |
tree | 6e4006a5c4d54dfb5a2487eeddca57b5058a175f /plugins/UserInfoEx/src | |
parent | c5392f2ac487b9c2bd525bc13a33fcf13f66ee5d (diff) |
unused code removed
git-svn-id: http://svn.miranda-ng.org/main/trunk@7457 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'plugins/UserInfoEx/src')
-rw-r--r-- | plugins/UserInfoEx/src/Flags/svc_flags.cpp | 153 | ||||
-rw-r--r-- | plugins/UserInfoEx/src/Flags/svc_flags.h | 3 | ||||
-rw-r--r-- | plugins/UserInfoEx/src/Flags/svc_flagsicons.cpp | 50 |
3 files changed, 35 insertions, 171 deletions
diff --git a/plugins/UserInfoEx/src/Flags/svc_flags.cpp b/plugins/UserInfoEx/src/Flags/svc_flags.cpp index a8589c9255..a0b350f1a9 100644 --- a/plugins/UserInfoEx/src/Flags/svc_flags.cpp +++ b/plugins/UserInfoEx/src/Flags/svc_flags.cpp @@ -26,119 +26,18 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #define M_ENABLE_SUBCTLS (WM_APP+1)
-bool g_bShowExtraImgFlag = false, g_bUseUnknownFlag = false, g_bShowStatusIconFlag = false;
+bool g_bUseUnknownFlag = false, g_bShowStatusIconFlag = false;
/* Misc */
int nCountriesCount;
struct CountryListEntry *countries;
-static HANDLE hExtraIconSvc = INVALID_HANDLE_VALUE;
-/* hook */
-static HANDLE hApplyIconHook = NULL;
-static HANDLE hSettingChangedHook = NULL;
+static HANDLE hExtraIconSvc;
static int OnContactSettingChanged(WPARAM wParam,LPARAM lParam);
static LIST<MsgWndData> gMsgWndList(10, HandleKeySortT);
/***********************************************************************************************************
- * Buffered functions
- ***********************************************************************************************************/
-
-struct BufferedCallData
-{
- DWORD startTick;
- UINT uElapse;
- BUFFEREDPROC pfnBuffProc;
- LPARAM lParam;
-};
-
-static UINT_PTR idBufferedTimer;
-static LIST<BufferedCallData> arCalls(10);
-static CRITICAL_SECTION csCalls;
-
-// always gets called in main message loop
-static void CALLBACK BufferedProcTimer(HWND hwnd, UINT /*msg*/, UINT idTimer, DWORD currentTick)
-{
- UINT uElapseNext = USER_TIMER_MAXIMUM;
-
- for (int i = 0; i < arCalls.getCount(); ++i) {
- BufferedCallData *p = arCalls[i];
-
- /* find elapsed procs */
- UINT uElapsed = currentTick - p->startTick; /* wraparound works */
- if ((uElapsed + USER_TIMER_MINIMUM) >= p->uElapse) {
- CallFunctionAsync((void (CALLBACK *)(void*))p->pfnBuffProc, (void*)p->lParam);
-
- mir_cslock lck(csCalls);
- arCalls.remove(i--);
- delete p;
- }
- /* find next timer delay */
- else if (p->uElapse - uElapsed < uElapseNext)
- uElapseNext = p->uElapse - uElapsed;
- }
-
- /* set next timer */
- if (arCalls.getCount())
- idBufferedTimer = SetTimer(hwnd, idBufferedTimer, uElapseNext, (TIMERPROC)BufferedProcTimer); /* will be reset */
- else {
- KillTimer(hwnd, idTimer);
- idBufferedTimer = 0;
- }
-}
-
-// assumes to be called in context of main thread
-void CallFunctionBuffered(BUFFEREDPROC pfnBuffProc, LPARAM lParam, BOOL fAccumulateSameParam, UINT uElapse)
-{
- struct BufferedCallData *data = NULL;
-
- /* find existing */
- for (int i = 0; i < arCalls.getCount(); ++i) {
- BufferedCallData *p = arCalls[i];
- if (p->pfnBuffProc == pfnBuffProc && (!fAccumulateSameParam || p->lParam == lParam)) {
- data = p;
- break;
- }
- }
-
- /* append new */
- if (data == NULL) {
- mir_cslock lck(csCalls);
- arCalls.insert(data = new BufferedCallData());
- }
-
- /* set delay */
- data->startTick = GetTickCount();
- data->uElapse = uElapse;
- data->lParam = lParam;
- data->pfnBuffProc = pfnBuffProc;
-
- /* set next timer */
- if (idBufferedTimer)
- uElapse = USER_TIMER_MINIMUM; /* will get recalculated */
- idBufferedTimer = SetTimer(NULL, idBufferedTimer, uElapse, (TIMERPROC)BufferedProcTimer);
-}
-
-// assumes to be called in context of main thread
-void PrepareBufferedFunctions()
-{
- idBufferedTimer = 0;
- InitializeCriticalSection(&csCalls);
-}
-
-// assumes to be called in context of main thread
-void KillBufferedFunctions()
-{
- if (idBufferedTimer)
- KillTimer(NULL,idBufferedTimer);
-
- for (int i=0; i < arCalls.getCount(); i++)
- delete arCalls[i];
- arCalls.destroy();
- DeleteCriticalSection(&csCalls);
-}
-
-/***********************************************************************************************************
* service functions
***********************************************************************************************************/
@@ -179,36 +78,6 @@ static int OnCListApplyIcons(WPARAM wParam, LPARAM) return 0;
}
-void SvcFlagsEnableExtraIcons(bool bEnable, bool bUpdateDB)
-{
- g_bShowExtraImgFlag = bEnable;
-
- if (bUpdateDB)
- db_set_b(NULL, MODNAMEFLAGS, "ShowExtraImgFlag", bEnable);
-
- // Flags is on
- if (g_bShowExtraImgFlag) {
- if (hExtraIconSvc == INVALID_HANDLE_VALUE) {
- // get local langID for descIcon (try to use user local Flag as icon)
- DWORD langid = 0;
- int r = GetLocaleInfo(LOCALE_USER_DEFAULT, LOCALE_ICOUNTRY | LOCALE_RETURN_NUMBER, (LPTSTR)&langid, sizeof(langid)/sizeof(TCHAR));
- if (!CallService(MS_UTILS_GETCOUNTRYBYNUMBER, langid, 0))
- langid = 1;
-
- char szId[20];
- mir_snprintf(szId, SIZEOF(szId), (langid == 0xFFFF) ? "%s_0x%X" : "%s_%i", "flags", langid); /* buffer safe */
- hExtraIconSvc = ExtraIcon_Register("Flags", LPGEN("Flags (uinfoex)"), szId);
- }
-
- // init hooks
- if (!hApplyIconHook)
- hApplyIconHook = HookEvent(ME_CLIST_EXTRA_IMAGE_APPLY, OnCListApplyIcons);
-
- if (!hSettingChangedHook)
- hSettingChangedHook = HookEvent(ME_DB_CONTACT_SETTINGCHANGED, OnContactSettingChanged);
- }
-}
-
/***********************************************************************************************************
* message winsow status icon functions
***********************************************************************************************************/
@@ -332,7 +201,6 @@ static int OnContactSettingChanged(WPARAM wParam, LPARAM lParam) void SvcFlagsLoadModule()
{
- PrepareBufferedFunctions();
if (CallService(MS_UTILS_GETCOUNTRYLIST, (WPARAM)&nCountriesCount, (LPARAM)&countries))
nCountriesCount = 0;
InitIcons(); /* load in iconlib */
@@ -341,7 +209,6 @@ void SvcFlagsLoadModule() // init settings
g_bUseUnknownFlag = db_get_b(NULL, MODNAMEFLAGS, "UseUnknownFlag", SETTING_USEUNKNOWNFLAG_DEFAULT) != 0;
- g_bShowExtraImgFlag = db_get_b(NULL, MODNAMEFLAGS, "ShowExtraImgFlag", SETTING_SHOWEXTRAIMGFLAG_DEFAULT) != 0;
g_bShowStatusIconFlag = db_get_b(NULL, MODNAMEFLAGS, "ShowStatusIconFlag", SETTING_SHOWSTATUSICONFLAG_DEFAULT) != 0;
HookEvent(ME_SKIN2_ICONSCHANGED, OnStatusIconsChanged);
@@ -357,7 +224,15 @@ void SvcFlagsLoadModule() void SvcFlagsOnModulesLoaded()
{
- SvcFlagsEnableExtraIcons(true, false);
+ // get local langID for descIcon (try to use user local Flag as icon)
+ DWORD langid = 0;
+ int r = GetLocaleInfo(LOCALE_USER_DEFAULT, LOCALE_ICOUNTRY | LOCALE_RETURN_NUMBER, (LPTSTR)&langid, sizeof(langid) / sizeof(TCHAR));
+ if (!CallService(MS_UTILS_GETCOUNTRYBYNUMBER, langid, 0))
+ langid = 1;
+
+ char szId[20];
+ mir_snprintf(szId, SIZEOF(szId), (langid == 0xFFFF) ? "%s_0x%X" : "%s_%i", "flags", langid); /* buffer safe */
+ hExtraIconSvc = ExtraIcon_Register("Flags", LPGEN("Flags (uinfoex)"), szId);
/* Status Icon */
StatusIconData sid = { sizeof(sid) };
@@ -366,6 +241,8 @@ void SvcFlagsOnModulesLoaded() sid.flags = MBF_HIDDEN;
Srmm_AddIcon(&sid);
+ HookEvent(ME_DB_CONTACT_SETTINGCHANGED, OnContactSettingChanged);
+ HookEvent(ME_CLIST_EXTRA_IMAGE_APPLY, OnCListApplyIcons);
HookEvent(ME_MSG_WINDOWEVENT, OnMsgWndEvent);
}
@@ -379,8 +256,6 @@ void SvcFlagsOnModulesLoaded() void SvcFlagsUnloadModule()
{
- KillBufferedFunctions();
-
//Uninit message winsow
for (int i = 0; i < gMsgWndList.getCount(); i++) {
//this should not happen
@@ -390,7 +265,5 @@ void SvcFlagsUnloadModule() gMsgWndList.destroy();
// Uninit misc
- UnhookEvent(hApplyIconHook);
- UnhookEvent(hSettingChangedHook);
UninitIcons();
}
diff --git a/plugins/UserInfoEx/src/Flags/svc_flags.h b/plugins/UserInfoEx/src/Flags/svc_flags.h index 61b3696466..71c0cb5bee 100644 --- a/plugins/UserInfoEx/src/Flags/svc_flags.h +++ b/plugins/UserInfoEx/src/Flags/svc_flags.h @@ -28,7 +28,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #define EXTRAIMAGE_REFRESHDELAY 100 /* time for which setting changes are buffered */
#define STATUSICON_REFRESHDELAY 100 /* time for which setting changes are buffered */
-extern bool g_bShowExtraImgFlag, g_bUseUnknownFlag, g_bShowStatusIconFlag;
+extern bool g_bUseUnknownFlag, g_bShowStatusIconFlag;
extern bool g_eiGender, g_eiHome, g_eiEmail, g_eiPhone;
struct MsgWndData
@@ -51,7 +51,6 @@ struct MsgWndData typedef void (CALLBACK *BUFFEREDPROC)(LPARAM lParam);
void CallFunctionBuffered(BUFFEREDPROC pfnBuffProc, LPARAM lParam, BOOL fAccumulateSameParam, UINT uElapse);
-void SvcFlagsEnableExtraIcons(bool bEnable, bool bUpdateDB);
void UpdateStatusIcons();
void SvcFlagsLoadModule();
diff --git a/plugins/UserInfoEx/src/Flags/svc_flagsicons.cpp b/plugins/UserInfoEx/src/Flags/svc_flagsicons.cpp index 0e82631427..535f1b7a55 100644 --- a/plugins/UserInfoEx/src/Flags/svc_flagsicons.cpp +++ b/plugins/UserInfoEx/src/Flags/svc_flagsicons.cpp @@ -26,8 +26,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. /************************* Bitmap Access **************************/
-static HANDLE *phIconHandles = NULL;
-
static int CountryNumberToBitmapIndex(int countryNumber)
{
/* country number indices (same order as in flags.bmp) */
@@ -125,6 +123,8 @@ static int CountryNumberToBitmapIndex(int countryNumber) /************************* Utils **********************************/
+static HANDLE *phIconHandles = NULL;
+
HICON LoadFlag(int countryNumber)
{
/* create identifier */
@@ -147,7 +147,7 @@ HANDLE LoadFlagHandle(int countryNumber) int CountryNumberToIndex(int countryNumber)
{
- int nf=0;
+ int nf = 0;
for(int i=0; i < nCountriesCount; i++) {
if (countries[i].id == countryNumber) return i;
if (countries[i].id == 0xFFFF) nf=i;
@@ -287,34 +287,26 @@ static INT_PTR ServiceCreateMergedFlagIcon(WPARAM wParam,LPARAM lParam) void InitIcons()
{
- HIMAGELIST himl = {0};
- HBITMAP hScrBM = 0;
- HBITMAP hbmMask = 0;
- FIBITMAP *dib = NULL,
- *dib_ico = NULL;
- UINT bitDest = ILC_COLOR8,
- bit = 24;
-
-// BOOL res;
-// FREE_IMAGE_FORMAT fif = FIP->FI_GetFIFFromFilename("dummy.bmp");
-
/* all those flag icons storing in a large 24bit opaque bitmap to reduce file size */
- if (NULL == (dib = LoadResource(IDB_FLAGSPNG,_T("PNG"))))
+ FIBITMAP *dib = LoadResource(IDB_FLAGSPNG, _T("PNG"));
+ if (dib == NULL)
return;
- bitDest = bit = ILC_COLOR32;
+ UINT bit = ILC_COLOR32, bitDest = ILC_COLOR32;
if (FIP->FI_GetBPP(dib) != bit)
- if (NULL == (dib = ConvertTo(dib, bit, 0))) return;
+ if (NULL == (dib = ConvertTo(dib, bit, 0)))
+ return;
//create new dib
- if (NULL == (dib_ico = FIP->FI_Allocate(FIP->FI_GetWidth(dib), 16, bit,0,0,0))) {
+ FIBITMAP *dib_ico = FIP->FI_Allocate(FIP->FI_GetWidth(dib), 16, bit, 0, 0, 0);
+ if (dib_ico == NULL) {
FIP->FI_Unload(dib);
return;
}
-// res = FIP->FI_IsTransparent(dib_ico);
- if (bit<32) {
+ // res = FIP->FI_IsTransparent(dib_ico);
+ if (bit < 32) {
//disable transparency
FIP->FI_SetTransparent(dib, FALSE);
FIP->FI_SetTransparent(dib_ico, FALSE);
@@ -322,18 +314,18 @@ void InitIcons() UINT h = FIP->FI_GetHeight(dib_ico);
UINT w = FIP->FI_GetWidth(dib_ico);
- UINT t = ((h - FIP->FI_GetHeight(dib))/2)+1;
+ UINT t = ((h - FIP->FI_GetHeight(dib)) / 2) + 1;
UINT b = t + FIP->FI_GetHeight(dib);
+ HBITMAP hbmMask = 0;
//copy dib to new dib_ico (centered)
- if (FIP->FI_Paste(dib_ico, dib, 0, t-1, 255+1)) {
+ if (FIP->FI_Paste(dib_ico, dib, 0, t - 1, 255 + 1)) {
FIP->FI_Unload(dib); dib = NULL;
switch (bitDest) {
- case 8:
- case 16:
- case 24:
+ case 8:
+ case 16:
+ case 24:
{//transparency by 1bit monocrome icon mask (for bit < 32)
- BYTE value;
FIBITMAP *dib_mask;
if (NULL == (dib_mask = FIP->FI_Allocate(w, h, 1, 0, 0, 0))) {
FIP->FI_Unload(dib_ico);
@@ -341,7 +333,7 @@ void InitIcons() }
for(unsigned y = 0; y < h; y++)
for(unsigned x = 0; x < w; x++) {
- value = ((y<t || y>=b)? 0:1);
+ BYTE value = ((y<t || y >= b) ? 0 : 1);
FIP->FI_SetPixelIndex(dib_mask, x, y, &value);
}
hbmMask = FIP->FI_CreateHBITMAPFromDIB(dib_mask);
@@ -379,7 +371,7 @@ void InitIcons() return;
}
- hScrBM = FIP->FI_CreateHBITMAPFromDIB(dib_ico);
+ HBITMAP hScrBM = FIP->FI_CreateHBITMAPFromDIB(dib_ico);
FIP->FI_Unload(dib_ico);
if (!hScrBM) {
@@ -388,7 +380,7 @@ void InitIcons() }
//create ImageList
- himl = ImageList_Create(16, 16 , bitDest | ILC_MASK, 0, nCountriesCount);
+ HIMAGELIST himl = ImageList_Create(16, 16, bitDest | ILC_MASK, 0, nCountriesCount);
ImageList_Add(himl, hScrBM, hbmMask);
DeleteObject(hScrBM); hScrBM = NULL;
DeleteObject(hbmMask); hbmMask = NULL;
|