summaryrefslogtreecommitdiff
path: root/plugins/Gender
diff options
context:
space:
mode:
authorGeorge Hazan <george.hazan@gmail.com>2012-11-03 20:16:42 +0000
committerGeorge Hazan <george.hazan@gmail.com>2012-11-03 20:16:42 +0000
commitf12d8b56f2894e94491bd7424d69f595d285f01f (patch)
tree3f54d66c8c248bb456da1cb0c5cc31661f144e5f /plugins/Gender
parent1b1a54dc156bec90be3ddc337c17b4e67179d4ea (diff)
no more MS_CLIST_EXTRA_ADD_ICON in the application code
git-svn-id: http://svn.miranda-ng.org/main/trunk@2175 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'plugins/Gender')
-rw-r--r--plugins/Gender/res/gender.rc6
-rw-r--r--plugins/Gender/src/commonheaders.h1
-rw-r--r--plugins/Gender/src/main.cpp141
-rw-r--r--plugins/Gender/src/options.cpp128
-rw-r--r--plugins/Gender/src/resource.h4
5 files changed, 59 insertions, 221 deletions
diff --git a/plugins/Gender/res/gender.rc b/plugins/Gender/res/gender.rc
index 7907593e0b..8497a110e9 100644
--- a/plugins/Gender/res/gender.rc
+++ b/plugins/Gender/res/gender.rc
@@ -79,15 +79,9 @@ IDD_GENDER_OPT DIALOGEX 0, 0, 314, 240
STYLE DS_SETFONT | DS_FIXEDSYS | WS_CHILD
FONT 8, "MS Shell Dlg", 0, 0, 0x0
BEGIN
- COMBOBOX IDC_ADVICON,95,102,78,81,CBS_DROPDOWNLIST | WS_VSCROLL |
- WS_TABSTOP,WS_EX_CLIENTEDGE
GROUPBOX "Plugin settings",IDC_STATIC,46,78,222,100
- RTEXT "Use",IDC_USE_L,56,104,33,12
- LTEXT "slot to draw the icon",IDC_SLOT_L,179,104,76,17
CONTROL "Enable menu items",IDC_MENUITEMS,"Button",
BS_AUTOCHECKBOX | WS_TABSTOP,76,122,167,12
- LTEXT "Note: if you still don't see the icons try changing icon slot. Perhaps its used by some other plugin.",
- IDC_NOTE_L,53,152,200,18
CONTROL "Draw an icon when gender info not found",
IDC_DRAWUNDEFICON,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,
76,138,167,12
diff --git a/plugins/Gender/src/commonheaders.h b/plugins/Gender/src/commonheaders.h
index bdea1613da..1971484888 100644
--- a/plugins/Gender/src/commonheaders.h
+++ b/plugins/Gender/src/commonheaders.h
@@ -59,7 +59,6 @@
#include "m_metacontacts.h"
#include "m_extraicons.h"
-static const int DefaultSlot = EXTRA_ICON_ADV2;
#define MODULENAME "Gender"
#endif //COMMHEADERS_H
diff --git a/plugins/Gender/src/main.cpp b/plugins/Gender/src/main.cpp
index 9f8c46f623..7a3d2297d7 100644
--- a/plugins/Gender/src/main.cpp
+++ b/plugins/Gender/src/main.cpp
@@ -27,19 +27,12 @@
HINSTANCE g_hInst;
-static HANDLE hHookModulesLoaded = NULL, hSystemOKToExit = NULL, hOptInitialise = NULL, hIcoLibIconsChanged = NULL;
-static HANDLE hHookExtraIconsRebuild = NULL, hHookExtraIconsApply = NULL, hContactMenu = NULL;
-static HANDLE hContactMenuMale = NULL, hContactMenuFemale = NULL, hContactMenuNotDef = NULL, hHookPrebuildContactMenu = NULL;
+static HANDLE hContactMenu = NULL, hContactMenuMale = NULL, hContactMenuFemale = NULL, hContactMenuNotDef = NULL;
static HANDLE hSetMale = NULL, hSetFemale = NULL, hSetUndef = NULL, hGenderGetIcon = NULL;
HANDLE g_hExtraIcon = NULL;
HANDLE g_hIconMale, g_hIconFemale, g_hIconMenu;
-IconExtraColumn g_IECMale = {0};
-IconExtraColumn g_IECFemale = {0};
-IconExtraColumn g_IECUndef = {0};
-IconExtraColumn g_IECClear = {0};
-int clistIcon = 0; // Icon slot to use
byte bEnableClistIcon = 1; // do we need clist icon?
byte bDrawNoGenderIcon = 0; // enable icon when no info?
byte bContactMenuItems = 1; // do we need a contact menu items?
@@ -79,74 +72,35 @@ extern "C" __declspec(dllexport) PLUGININFOEX* MirandaPluginInfoEx(DWORD miranda
void setIcon(HANDLE hContact, unsigned int gender)
{
- if (g_hExtraIcon != NULL)
- {
- char *ico;
- switch (gender)
- {
- case 77: ico = "male_icon"; break;
- case 70: ico = "female_icon"; break;
- default: ico = (bDrawNoGenderIcon ? "menu_icon" : NULL); break;
- }
- ExtraIcon_SetIcon(g_hExtraIcon, hContact, ico);
- }
- else
- {
- IconExtraColumn *col;
- switch (gender)
- {
- case 77: col = &g_IECMale; break;
- case 70: col = &g_IECFemale; break;
- default: col = (bDrawNoGenderIcon ? &g_IECUndef : &g_IECClear); break;
- }
- CallService(MS_CLIST_EXTRA_SET_ICON, (WPARAM)hContact, (LPARAM)col);
+ char *ico;
+ switch (gender) {
+ case 77: ico = "male_icon"; break;
+ case 70: ico = "female_icon"; break;
+ default: ico = (bDrawNoGenderIcon ? "menu_icon" : NULL); break;
}
+ ExtraIcon_SetIcon(g_hExtraIcon, hContact, ico);
}
-int onExtraImageApplying(WPARAM wParam, LPARAM lParam)
+int applyExtraImage(HANDLE hContact)
{
- if (g_hExtraIcon == NULL && !bEnableClistIcon) return 0;
+ if (!bEnableClistIcon) return 0;
- HANDLE hContact = (HANDLE)wParam;
- if (bMetaAvail)
- {
- HANDLE hMetacontact = (HANDLE)CallService(MS_MC_GETMOSTONLINECONTACT, wParam, 0);
- if (hMetacontact != NULL) hContact = hMetacontact;
+ if (bMetaAvail) {
+ HANDLE hMetacontact = (HANDLE)CallService(MS_MC_GETMOSTONLINECONTACT, (WPARAM)hContact, 0);
+ if (hMetacontact != NULL)
+ hContact = hMetacontact;
}
- char *proto = (char *)CallService(MS_PROTO_GETCONTACTBASEPROTO, wParam, 0);
- if (!proto) return 0;
+ char *proto = (char *)CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)hContact, 0);
+ if (!proto)
+ return 0;
- if (DBGetContactSettingByte((HANDLE)wParam, proto, "ChatRoom", 0)) return 0;
+ if ( DBGetContactSettingByte(hContact, proto, "ChatRoom", 0))
+ return 0;
unsigned int gender = DBGetContactSettingByte(hContact, "UserInfo", "Gender", DBGetContactSettingByte(hContact, proto, "Gender", 0));
setIcon(hContact, gender);
- if ((HANDLE)wParam != hContact)
- setIcon((HANDLE)wParam, gender);
-
- return 0;
-}
-
-int onExtraImageListRebuild(WPARAM wParam, LPARAM lParam)
-{
- g_IECMale.cbSize = sizeof(IconExtraColumn);
- g_IECMale.ColumnType = clistIcon;
- g_IECFemale.cbSize = sizeof(IconExtraColumn);
- g_IECFemale.ColumnType = clistIcon;
- g_IECUndef.cbSize = sizeof(IconExtraColumn);
- g_IECUndef.ColumnType = clistIcon;
-
- if (ServiceExists(MS_CLIST_EXTRA_ADD_ICON))
- {
- if(hIcoLibIconsChanged)
- {
- g_IECMale.hImage = (HANDLE)CallService(MS_CLIST_EXTRA_ADD_ICON, (WPARAM)Skin_GetIconByHandle(g_hIconMale), 0);
- g_IECFemale.hImage = (HANDLE)CallService(MS_CLIST_EXTRA_ADD_ICON, (WPARAM)Skin_GetIconByHandle(g_hIconFemale), 0);
- g_IECUndef.hImage = (HANDLE)CallService(MS_CLIST_EXTRA_ADD_ICON, (WPARAM)Skin_GetIconByHandle(g_hIconMenu), 0);
- }
- }
-
return 0;
}
@@ -240,14 +194,14 @@ INT_PTR onSetFemale(WPARAM wParam,LPARAM lParam)
INT_PTR onSetUndef(WPARAM wParam,LPARAM lParam)
{
DBDeleteContactSetting((HANDLE)wParam, "UserInfo", "Gender");
- onExtraImageApplying(wParam, 0);
+ applyExtraImage((HANDLE)wParam);
int metasnum = (bMetaAvail ? CallService(MS_MC_GETNUMCONTACTS,wParam,0) : 0);
for(int i=0; i<metasnum; i++)
{
HANDLE hContact = (HANDLE)CallService(MS_MC_GETSUBCONTACT, wParam, i);
DBDeleteContactSetting(hContact, "UserInfo", "Gender");
- onExtraImageApplying((WPARAM)hContact, 0);
+ applyExtraImage(hContact);
}
return 0;
@@ -255,8 +209,9 @@ INT_PTR onSetUndef(WPARAM wParam,LPARAM lParam)
int onModulesLoaded(WPARAM wParam,LPARAM lParam)
{
- hOptInitialise = HookEvent(ME_OPT_INITIALISE, onOptInitialise);
- if (bContactMenuItems) hHookPrebuildContactMenu = HookEvent(ME_CLIST_PREBUILDCONTACTMENU, onPrebuildContactMenu);
+ HookEvent(ME_OPT_INITIALISE, onOptInitialise);
+ if (bContactMenuItems)
+ HookEvent(ME_CLIST_PREBUILDCONTACTMENU, onPrebuildContactMenu);
bMetaAvail = (ServiceExists(MS_MC_GETMETACONTACT) != 0);
TCHAR szFile[MAX_PATH];
@@ -284,25 +239,13 @@ int onModulesLoaded(WPARAM wParam,LPARAM lParam)
sid.iDefaultIndex = -IDI_UNDEF;
g_hIconMenu = Skin_AddIcon(&sid);
- hIcoLibIconsChanged = HookEvent(ME_SKIN2_ICONSCHANGED, onExtraImageListRebuild);
-
+ // Adding clist extra icon
g_hExtraIcon = ExtraIcon_Register("gender", "Gender", "menu_icon");
- if (g_hExtraIcon != NULL)
- {
- HANDLE hContact = db_find_first();
- while (hContact != NULL)
- {
- onExtraImageApplying((WPARAM) hContact, 0);
- hContact = db_find_next(hContact);
- }
- }
- else
- {
- hHookExtraIconsRebuild = HookEvent(ME_CLIST_EXTRA_LIST_REBUILD, onExtraImageListRebuild);
- hHookExtraIconsApply = HookEvent(ME_CLIST_EXTRA_IMAGE_APPLY, onExtraImageApplying);
-
- onExtraImageListRebuild(0,0);
+ HANDLE hContact = db_find_first();
+ while (hContact != NULL) {
+ applyExtraImage(hContact);
+ hContact = db_find_next(hContact);
}
// Adding menu items, submenu even if clist supports that
@@ -371,53 +314,29 @@ int onModulesLoaded(WPARAM wParam,LPARAM lParam)
int onSystemOKToExit(WPARAM wParam,LPARAM lParam)
{
- UnhookEvent(hHookModulesLoaded);
- UnhookEvent(hHookExtraIconsRebuild);
- UnhookEvent(hHookExtraIconsApply);
- UnhookEvent(hHookPrebuildContactMenu);
- UnhookEvent(hOptInitialise);
- UnhookEvent(hSystemOKToExit);
- if (hIcoLibIconsChanged)
- UnhookEvent(hIcoLibIconsChanged);
-
DestroyServiceFunction(hSetMale);
DestroyServiceFunction(hSetFemale);
DestroyServiceFunction(hSetUndef);
DestroyServiceFunction(hGenderGetIcon);
-
- if (hIcoLibIconsChanged) {
- Skin_ReleaseIcon("menu_icon");
- Skin_ReleaseIcon("male_icon");
- Skin_ReleaseIcon("female_icon");
- }
-
return 0;
}
extern "C" int __declspec(dllexport) Load(void)
{
-
mir_getLP(&pluginInfo);
- hHookModulesLoaded = HookEvent(ME_SYSTEM_MODULESLOADED, onModulesLoaded);
- hSystemOKToExit = HookEvent(ME_SYSTEM_OKTOEXIT,onSystemOKToExit);
+ HookEvent(ME_SYSTEM_MODULESLOADED, onModulesLoaded);
+ HookEvent(ME_SYSTEM_OKTOEXIT,onSystemOKToExit);
bEnableClistIcon = DBGetContactSettingByte(NULL, MODULENAME, "ClistIcon", 1);
bContactMenuItems = DBGetContactSettingByte(NULL, MODULENAME, "MenuItems", 1);
bDrawNoGenderIcon = DBGetContactSettingByte(NULL, MODULENAME, "NoGenderIcon", 0);
-
hSetMale = CreateServiceFunction("Gender/MenuItemSetMale", onSetMale);
hSetFemale = CreateServiceFunction("Gender/MenuItemSetFemale", onSetFemale);
hSetUndef = CreateServiceFunction("Gender/MenuItemSetUndef", onSetUndef);
- clistIcon = DBGetContactSettingByte(NULL, MODULENAME, "AdvancedIcon", DefaultSlot);
- g_IECClear.cbSize = sizeof(IconExtraColumn);
- g_IECClear.ColumnType = clistIcon;
- g_IECClear.hImage = (HANDLE) -1;
-
hGenderGetIcon = CreateServiceFunction(MS_GENDER_GETICON, GetIcon);
-
return 0;
}
diff --git a/plugins/Gender/src/options.cpp b/plugins/Gender/src/options.cpp
index c6537e4ca2..a7c5c244bd 100644
--- a/plugins/Gender/src/options.cpp
+++ b/plugins/Gender/src/options.cpp
@@ -25,126 +25,56 @@
#include "commonheaders.h"
+int applyExtraImage(HANDLE hContact);
+
extern HINSTANCE g_hInst;
-extern int onExtraImageApplying(WPARAM wParam, LPARAM lParam);
-extern int onExtraImageListRebuild(WPARAM wParam, LPARAM lParam);
extern IconExtraColumn g_IECClear;
extern int clistIcon;
extern HANDLE g_hExtraIcon;
extern byte bContactMenuItems, bEnableClistIcon, bDrawNoGenderIcon;
-const TCHAR *szAdvancedIcons[] = {LPGENT("Email"), LPGENT("Protocol"), LPGENT("SMS"), LPGENT("Advanced 1"), LPGENT("Advanced 2"), LPGENT("Web"), LPGENT("Client"), LPGENT("Advanced 3"), LPGENT("Advanced 4"), LPGENT("Advanced 5")};
-const int cAdvancedIcons = sizeof(szAdvancedIcons) / sizeof(szAdvancedIcons[0]);
INT_PTR CALLBACK DlgProcOptions(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
{
static int bInitializing = 0;
- switch (msg)
- {
- case WM_INITDIALOG:
- {
- TranslateDialogDefault(hwndDlg);
- bInitializing = 1;
- if (g_hExtraIcon == NULL)
- {
- SendMessage(GetDlgItem(hwndDlg, IDC_ADVICON), CB_ADDSTRING, 0, (LPARAM) TranslateT("Disabled"));
- for (int i = 0; i < cAdvancedIcons; i++)
- {
- SendMessage(GetDlgItem(hwndDlg, IDC_ADVICON), CB_ADDSTRING, 0, (LPARAM) TranslateTS(szAdvancedIcons[i]));
- }
-
- if (bEnableClistIcon)
- SendMessage(GetDlgItem(hwndDlg, IDC_ADVICON), CB_SETCURSEL, clistIcon, 0);
- else
- SendMessage(GetDlgItem(hwndDlg, IDC_ADVICON), CB_SETCURSEL, 0, 0);
- }
- else
- {
- ShowWindow(GetDlgItem(hwndDlg, IDC_USE_L), SW_HIDE);
- ShowWindow(GetDlgItem(hwndDlg, IDC_ADVICON), SW_HIDE);
- ShowWindow(GetDlgItem(hwndDlg, IDC_SLOT_L), SW_HIDE);
- ShowWindow(GetDlgItem(hwndDlg, IDC_NOTE_L), SW_HIDE);
- }
- CheckDlgButton(hwndDlg, IDC_MENUITEMS, DBGetContactSettingByte(NULL, MODULENAME, "MenuItems", 1) ? BST_CHECKED : BST_UNCHECKED);
- CheckDlgButton(hwndDlg, IDC_DRAWUNDEFICON, bDrawNoGenderIcon ? BST_CHECKED : BST_UNCHECKED);
-
- bInitializing = 0;
- return TRUE;
- }
-
- case WM_COMMAND:
- {
- switch (LOWORD(wParam)) {
- case IDC_ADVICON:
- {
- if ((HIWORD(wParam) == EN_CHANGE) && (!bInitializing) || (HIWORD(wParam) == CBN_SELENDOK))
- {
- SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
- }
- }
- break;
- case IDC_MENUITEMS:
- case IDC_DRAWUNDEFICON:
- SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
- break;
- }
+ switch (msg) {
+ case WM_INITDIALOG:
+ TranslateDialogDefault(hwndDlg);
+ bInitializing = 1;
+
+ CheckDlgButton(hwndDlg, IDC_MENUITEMS, DBGetContactSettingByte(NULL, MODULENAME, "MenuItems", 1) ? BST_CHECKED : BST_UNCHECKED);
+ CheckDlgButton(hwndDlg, IDC_DRAWUNDEFICON, bDrawNoGenderIcon ? BST_CHECKED : BST_UNCHECKED);
+
+ bInitializing = 0;
+ return TRUE;
+
+ case WM_COMMAND:
+ switch (LOWORD(wParam)) {
+ case IDC_MENUITEMS:
+ case IDC_DRAWUNDEFICON:
+ SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
+ break;
}
break;
-
- case WM_NOTIFY:
- {
- if (((LPNMHDR)lParam)->idFrom == 0)
- switch (((LPNMHDR)lParam)->code)
- {
- case PSN_APPLY:
- {
- HANDLE hContact;
+ case WM_NOTIFY:
+ if (((LPNMHDR)lParam)->idFrom == 0)
+ switch (((LPNMHDR)lParam)->code) {
+ case PSN_APPLY:
+ {
bDrawNoGenderIcon = IsDlgButtonChecked(hwndDlg, IDC_DRAWUNDEFICON);
-
- if (g_hExtraIcon == NULL)
- {
- clistIcon = SendMessage(GetDlgItem(hwndDlg, IDC_ADVICON), CB_GETCURSEL, 0, 0);
- DBWriteContactSettingByte(NULL, MODULENAME, "AdvancedIcon", clistIcon);
-
- if (bEnableClistIcon)
- {
- hContact = db_find_first();
- while (hContact)
- {
- CallService(MS_CLIST_EXTRA_SET_ICON, (WPARAM)hContact, (LPARAM)&g_IECClear);
- hContact = db_find_next(hContact);
- }
- }
-
- bEnableClistIcon = (clistIcon != 0);
-
- if (bEnableClistIcon)
- {
- g_IECClear.ColumnType = clistIcon;
- onExtraImageListRebuild(0,0);
- }
- }
- if (g_hExtraIcon != NULL || bEnableClistIcon)
- {
- hContact = db_find_first();
- while (hContact)
- {
- onExtraImageApplying((WPARAM)hContact,0);
- hContact = db_find_next(hContact);
- }
+ HANDLE hContact = db_find_first();
+ while (hContact) {
+ applyExtraImage(hContact);
+ hContact = db_find_next(hContact);
}
-
+
DBWriteContactSettingByte(NULL, MODULENAME, "ClistIcon", bEnableClistIcon);
DBWriteContactSettingByte(NULL, MODULENAME, "NoGenderIcon", bDrawNoGenderIcon);
DBWriteContactSettingByte(NULL, MODULENAME, "MenuItems", IsDlgButtonChecked(hwndDlg, IDC_MENUITEMS));
}
return TRUE;
- }
}
-
- case WM_DESTROY:
- break;
}
return FALSE;
}
diff --git a/plugins/Gender/src/resource.h b/plugins/Gender/src/resource.h
index 8ea2786991..765b554966 100644
--- a/plugins/Gender/src/resource.h
+++ b/plugins/Gender/src/resource.h
@@ -6,12 +6,8 @@
#define IDI_MALE 101
#define IDI_FEMALE 102
#define IDI_UNDEF 103
-#define IDC_ADVICON 1001
#define IDC_MENUITEMS 1002
#define IDC_DRAWUNDEFICON 1003
-#define IDC_USE_L 1004
-#define IDC_SLOT_L 1005
-#define IDC_NOTE_L 1006
// Next default values for new objects
//