From 1559d8356c07eedd8207a8badd709c0effcce923 Mon Sep 17 00:00:00 2001 From: Vadim Dashevskiy Date: Fri, 20 Jul 2012 06:26:45 +0000 Subject: Gender: changed folder structure git-svn-id: http://svn.miranda-ng.org/main/trunk@1063 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- plugins/Gender/commonheaders.h | 65 ----- plugins/Gender/docs/gender-translation.txt | 34 +++ plugins/Gender/gender-translation.txt | 34 --- plugins/Gender/gender.rc | 129 --------- plugins/Gender/gender_10.vcxproj | 12 +- plugins/Gender/icons/female.ico | Bin 2550 -> 0 bytes plugins/Gender/icons/gender.ico | Bin 2550 -> 0 bytes plugins/Gender/icons/male.ico | Bin 2550 -> 0 bytes plugins/Gender/main.cpp | 427 ----------------------------- plugins/Gender/options.cpp | 165 ----------- plugins/Gender/res/female.ico | Bin 0 -> 2550 bytes plugins/Gender/res/gender.ico | Bin 0 -> 2550 bytes plugins/Gender/res/gender.rc | 129 +++++++++ plugins/Gender/res/male.ico | Bin 0 -> 2550 bytes plugins/Gender/resource.h | 25 -- plugins/Gender/src/commonheaders.h | 65 +++++ plugins/Gender/src/main.cpp | 427 +++++++++++++++++++++++++++++ plugins/Gender/src/options.cpp | 165 +++++++++++ plugins/Gender/src/resource.h | 25 ++ 19 files changed, 850 insertions(+), 852 deletions(-) delete mode 100644 plugins/Gender/commonheaders.h create mode 100644 plugins/Gender/docs/gender-translation.txt delete mode 100644 plugins/Gender/gender-translation.txt delete mode 100644 plugins/Gender/gender.rc delete mode 100644 plugins/Gender/icons/female.ico delete mode 100644 plugins/Gender/icons/gender.ico delete mode 100644 plugins/Gender/icons/male.ico delete mode 100644 plugins/Gender/main.cpp delete mode 100644 plugins/Gender/options.cpp create mode 100644 plugins/Gender/res/female.ico create mode 100644 plugins/Gender/res/gender.ico create mode 100644 plugins/Gender/res/gender.rc create mode 100644 plugins/Gender/res/male.ico delete mode 100644 plugins/Gender/resource.h create mode 100644 plugins/Gender/src/commonheaders.h create mode 100644 plugins/Gender/src/main.cpp create mode 100644 plugins/Gender/src/options.cpp create mode 100644 plugins/Gender/src/resource.h (limited to 'plugins') diff --git a/plugins/Gender/commonheaders.h b/plugins/Gender/commonheaders.h deleted file mode 100644 index bdea1613da..0000000000 --- a/plugins/Gender/commonheaders.h +++ /dev/null @@ -1,65 +0,0 @@ -/* - Show Contact Gender plugin for Miranda-IM (www.miranda-im.org) - (c) 2006-2011 by Thief - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - - File name : $URL: http://svn.miranda.im/mainrepo/gender/trunk/commonheaders.h $ - Revision : $Rev: 1687 $ - Last change on : $Date: 2011-01-22 18:44:21 +0200 (Сб, 22 янв 2011) $ - Last change by : $Author: Thief $ - -*/ - -#ifndef COMMHEADERS_H -#define COMMHEADERS_H - -#define _CRT_SECURE_NO_WARNINGS -#define MIRANDA_VER 0x0A00 - -#include //needed by m_utils.h -#include // needed by m_icolib.h > r9256 - -#include -#include - -//Miranda API headers -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -//Gender SDK -#include "m_gender.h" - -//Resources -#include "resource.h" - -//external SDK headers -#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/docs/gender-translation.txt b/plugins/Gender/docs/gender-translation.txt new file mode 100644 index 0000000000..e7085dfd0b --- /dev/null +++ b/plugins/Gender/docs/gender-translation.txt @@ -0,0 +1,34 @@ +; Common strings that belong to many files +;[Gender] + +; ../../plugins/Gender/gender.rc +;[Draw an icon when gender info not found] +;[Enable menu items] +;[Note: if you still don't see the icons try changing icon slot. Perhaps its used by some other plugin.] +;[Plugin settings] +;[Use] +;[slot to draw the icon] + +; ../../plugins/Gender/main.cpp +;[Female] +;[Male] +;[No info] +;[Set Female] +;[Set Gender] +;[Set Male] +;[Set Undefined] +;[Undefined] + +; ../../plugins/Gender/options.cpp +;[Advanced 1] +;[Advanced 2] +;[Advanced 3] +;[Advanced 4] +;[Advanced 5] +;[Client] +;[Disabled] +;[Email] +;[Plugins] +;[Protocol] +;[SMS] +;[Web] diff --git a/plugins/Gender/gender-translation.txt b/plugins/Gender/gender-translation.txt deleted file mode 100644 index e7085dfd0b..0000000000 --- a/plugins/Gender/gender-translation.txt +++ /dev/null @@ -1,34 +0,0 @@ -; Common strings that belong to many files -;[Gender] - -; ../../plugins/Gender/gender.rc -;[Draw an icon when gender info not found] -;[Enable menu items] -;[Note: if you still don't see the icons try changing icon slot. Perhaps its used by some other plugin.] -;[Plugin settings] -;[Use] -;[slot to draw the icon] - -; ../../plugins/Gender/main.cpp -;[Female] -;[Male] -;[No info] -;[Set Female] -;[Set Gender] -;[Set Male] -;[Set Undefined] -;[Undefined] - -; ../../plugins/Gender/options.cpp -;[Advanced 1] -;[Advanced 2] -;[Advanced 3] -;[Advanced 4] -;[Advanced 5] -;[Client] -;[Disabled] -;[Email] -;[Plugins] -;[Protocol] -;[SMS] -;[Web] diff --git a/plugins/Gender/gender.rc b/plugins/Gender/gender.rc deleted file mode 100644 index 651f86bd36..0000000000 --- a/plugins/Gender/gender.rc +++ /dev/null @@ -1,129 +0,0 @@ -// Microsoft Visual C++ generated resource script. -// -#include "resource.h" - -#define APSTUDIO_READONLY_SYMBOLS -///////////////////////////////////////////////////////////////////////////// -// -// Generated from the TEXTINCLUDE 2 resource. -// -#include "afxres.h" - -///////////////////////////////////////////////////////////////////////////// -#undef APSTUDIO_READONLY_SYMBOLS - -///////////////////////////////////////////////////////////////////////////// -// Ukrainian resources - -#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_UKR) -#ifdef _WIN32 -LANGUAGE LANG_UKRAINIAN, SUBLANG_DEFAULT -#pragma code_page(1251) -#endif //_WIN32 - -///////////////////////////////////////////////////////////////////////////// -// -// Icon -// - -// Icon with lowest ID value placed first to ensure application icon -// remains consistent on all systems. -IDI_MALE ICON "icons\\male.ico" -IDI_FEMALE ICON "icons\\female.ico" -IDI_UNDEF ICON "icons\\gender.ico" -#endif // Ukrainian resources -///////////////////////////////////////////////////////////////////////////// - - -///////////////////////////////////////////////////////////////////////////// -// English (U.S.) resources - -#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU) -#ifdef _WIN32 -LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US -#pragma code_page(1252) -#endif //_WIN32 - -#ifdef APSTUDIO_INVOKED -///////////////////////////////////////////////////////////////////////////// -// -// TEXTINCLUDE -// - -1 TEXTINCLUDE -BEGIN - "resource.h\0" -END - -2 TEXTINCLUDE -BEGIN - "#include ""afxres.h""\r\n" - "\0" -END - -3 TEXTINCLUDE -BEGIN - "\r\n" - "\0" -END - -#endif // APSTUDIO_INVOKED - - -///////////////////////////////////////////////////////////////////////////// -// -// Dialog -// - -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 -END - - -///////////////////////////////////////////////////////////////////////////// -// -// DESIGNINFO -// - -#ifdef APSTUDIO_INVOKED -GUIDELINES DESIGNINFO -BEGIN - IDD_GENDER_OPT, DIALOG - BEGIN - LEFTMARGIN, 7 - RIGHTMARGIN, 307 - TOPMARGIN, 7 - BOTTOMMARGIN, 233 - END -END -#endif // APSTUDIO_INVOKED - -#endif // English (U.S.) resources -///////////////////////////////////////////////////////////////////////////// - - - -#ifndef APSTUDIO_INVOKED -///////////////////////////////////////////////////////////////////////////// -// -// Generated from the TEXTINCLUDE 3 resource. -// - - -///////////////////////////////////////////////////////////////////////////// -#endif // not APSTUDIO_INVOKED - diff --git a/plugins/Gender/gender_10.vcxproj b/plugins/Gender/gender_10.vcxproj index a458303538..977ba6375d 100644 --- a/plugins/Gender/gender_10.vcxproj +++ b/plugins/Gender/gender_10.vcxproj @@ -160,21 +160,19 @@ - - + + - - + + - - - + diff --git a/plugins/Gender/icons/female.ico b/plugins/Gender/icons/female.ico deleted file mode 100644 index fe1cbd2bce..0000000000 Binary files a/plugins/Gender/icons/female.ico and /dev/null differ diff --git a/plugins/Gender/icons/gender.ico b/plugins/Gender/icons/gender.ico deleted file mode 100644 index 930c34279c..0000000000 Binary files a/plugins/Gender/icons/gender.ico and /dev/null differ diff --git a/plugins/Gender/icons/male.ico b/plugins/Gender/icons/male.ico deleted file mode 100644 index ebd0420554..0000000000 Binary files a/plugins/Gender/icons/male.ico and /dev/null differ diff --git a/plugins/Gender/main.cpp b/plugins/Gender/main.cpp deleted file mode 100644 index 5e5f1f4992..0000000000 --- a/plugins/Gender/main.cpp +++ /dev/null @@ -1,427 +0,0 @@ -/* - Show Contact Gender plugin for Miranda-IM (www.miranda-im.org) - (c) 2006-2011 by Thief - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - - File name : $URL: http://svn.miranda.im/mainrepo/gender/trunk/main.cpp $ - Revision : $Rev: 1688 $ - Last change on : $Date: 2011-01-22 19:44:43 +0200 (Сб, 22 янв 2011) $ - Last change by : $Author: Thief $ - -*/ - -#include "commonheaders.h" - -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 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? -byte bMetaAvail = 0; // metacontacts installed? -int hLangpack; - -extern int onOptInitialise(WPARAM wParam, LPARAM lParam); - -PLUGININFOEX pluginInfo={ -sizeof(PLUGININFOEX), - "Show Contact Gender", - PLUGIN_MAKE_VERSION(0,0,2,1), - "Shows contacts gender as an icon in contact list", - "Thief, idea by nile, icons by a0x", - "thief@miranda.im", - "2006-2011 Alexander Turyak", - "http://thief.miranda.im/", - UNICODE_AWARE, //doesn't replace anything built-in - {0xfb1c17e0, 0x77fc, 0x45a7, {0x9c, 0x8b, 0xe2, 0xbe, 0xf4, 0xf5, 0x6b, 0x28}} /* FB1C17E0-77FC-45A7-9C8B-E2BEF4F56B28 */ -}; - -extern "C" BOOL WINAPI DllMain(HINSTANCE hinstDLL,DWORD fdwReason,LPVOID lpvReserved) -{ - g_hInst = hinstDLL; - return TRUE; -} - -/* 0FF3991A-5505-479D-A2E0-53DD31C6DFA7 */ -#define MIID_GENDER {0x0ff3991a, 0x5505, 0x479d, {0xa2, 0xe0, 0x53, 0xdd, 0x31, 0xc6, 0xdf, 0xa7}} - -extern "C" __declspec(dllexport) const MUUID MirandaInterfaces[] = {MIID_GENDER, MIID_LAST}; - -extern "C" __declspec(dllexport) PLUGININFOEX* MirandaPluginInfoEx(DWORD mirandaVersion) -{ - return &pluginInfo; -} - -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); - } -} - -int onExtraImageApplying(WPARAM wParam, LPARAM lParam) -{ - if (g_hExtraIcon == NULL && !bEnableClistIcon) return 0; - - HANDLE hContact = (HANDLE)wParam; - if (bMetaAvail) - { - HANDLE hMetacontact = (HANDLE)CallService(MS_MC_GETMOSTONLINECONTACT, wParam, 0); - if (hMetacontact != NULL) hContact = hMetacontact; - } - - char *proto = (char *)CallService(MS_PROTO_GETCONTACTBASEPROTO, wParam, 0); - if (!proto) return 0; - - if (DBGetContactSettingByte((HANDLE)wParam, 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)CallService(MS_SKIN2_GETICONBYHANDLE, 0, (LPARAM)g_hIconMale), (LPARAM)0); - g_IECFemale.hImage = (HANDLE)CallService(MS_CLIST_EXTRA_ADD_ICON, (WPARAM)CallService(MS_SKIN2_GETICONBYHANDLE, 0, (LPARAM)g_hIconFemale), (LPARAM)0); - g_IECUndef.hImage = (HANDLE)CallService(MS_CLIST_EXTRA_ADD_ICON, (WPARAM)CallService(MS_SKIN2_GETICONBYHANDLE, 0, (LPARAM)g_hIconMenu), (LPARAM)0); - } - } - - return 0; -} - -// Returns gender icon for specific contact -INT_PTR GetIcon(WPARAM wParam, LPARAM lParam) -{ - char *proto = (char *)CallService(MS_PROTO_GETCONTACTBASEPROTO, wParam, 0); - unsigned short gender = DBGetContactSettingByte((HANDLE)wParam, "UserInfo", "Gender", DBGetContactSettingByte((HANDLE)wParam, proto, "Gender", 0)); - - if (gender > 0) - { - if (gender == 77) return CallService(MS_SKIN2_GETICONBYHANDLE, 0, (LPARAM)g_hIconMale); - else if (gender == 70) return CallService(MS_SKIN2_GETICONBYHANDLE, 0, (LPARAM)g_hIconFemale); - } - - return 0; -} - -int onPrebuildContactMenu(WPARAM wParam, LPARAM lParam) -{ - char *proto = (char *)CallService(MS_PROTO_GETCONTACTBASEPROTO, wParam, 0); - - if (!proto) return 0; - - CLISTMENUITEM mi = {0}; - mi.cbSize = sizeof(CLISTMENUITEM); - - - if (DBGetContactSettingByte((HANDLE)wParam, proto, "ChatRoom", 0) || !(CallProtoService(proto, PS_GETCAPS, PFLAGNUM_1, 0) & PF1_IMSEND)) - mi.flags = CMIM_FLAGS | CMIF_HIDDEN; - else - mi.flags = CMIM_FLAGS; - - CallService(MS_CLIST_MODIFYMENUITEM, (WPARAM)hContactMenu, (LPARAM)&mi); - - unsigned short gender = DBGetContactSettingByte((HANDLE)wParam, proto, "Gender", DBGetContactSettingByte((HANDLE)wParam, "UserInfo", "Gender", 0)); - - CLISTMENUITEM mitem = {0}; - mitem.cbSize = sizeof(CLISTMENUITEM); - mitem.flags = CMIM_FLAGS; - - CallService(MS_CLIST_MODIFYMENUITEM, (WPARAM)hContactMenuMale, (LPARAM)&mitem); - CallService(MS_CLIST_MODIFYMENUITEM, (WPARAM)hContactMenuFemale, (LPARAM)&mitem); - CallService(MS_CLIST_MODIFYMENUITEM, (WPARAM)hContactMenuNotDef, (LPARAM)&mitem); - - mitem.flags = CMIM_FLAGS | CMIF_CHECKED; - - switch (gender) - { - case 77: - CallService(MS_CLIST_MODIFYMENUITEM, (WPARAM)hContactMenuMale, (LPARAM)&mitem); - break; - case 70: - CallService(MS_CLIST_MODIFYMENUITEM, (WPARAM)hContactMenuFemale, (LPARAM)&mitem); - break; - case 0: - CallService(MS_CLIST_MODIFYMENUITEM, (WPARAM)hContactMenuNotDef, (LPARAM)&mitem); - break; - } - - return 0; -} - -void setGender(HANDLE hContact, unsigned int gender) -{ - DBWriteContactSettingByte(hContact, "UserInfo", "Gender", gender); - setIcon(hContact, gender); - - int metasnum = (bMetaAvail ? CallService(MS_MC_GETNUMCONTACTS,(WPARAM)hContact,0) : 0); - for(int i=0; iidFrom == 0) - switch (((LPNMHDR)lParam)->code) - { - case PSN_APPLY: - { - HANDLE hContact; - - 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 = (HANDLE)CallService(MS_DB_CONTACT_FINDFIRST, 0, 0); - while (hContact) - { - CallService(MS_CLIST_EXTRA_SET_ICON, (WPARAM)hContact, (LPARAM)&g_IECClear); - hContact = (HANDLE)CallService(MS_DB_CONTACT_FINDNEXT, (WPARAM)hContact, 0); - } - } - - bEnableClistIcon = (clistIcon != 0); - - if (bEnableClistIcon) - { - g_IECClear.ColumnType = clistIcon; - onExtraImageListRebuild(0,0); - } - } - - if (g_hExtraIcon != NULL || bEnableClistIcon) - { - hContact = (HANDLE)CallService(MS_DB_CONTACT_FINDFIRST, 0, 0); - while (hContact) - { - onExtraImageApplying((WPARAM)hContact,0); - hContact = (HANDLE)CallService(MS_DB_CONTACT_FINDNEXT, (WPARAM)hContact, 0); - } - } - - 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; -} - -int onOptInitialise(WPARAM wParam, LPARAM lParam) -{ - OPTIONSDIALOGPAGE odp = { 0 }; - odp.cbSize = sizeof(odp); - odp.hInstance = g_hInst; - odp.pszGroup = LPGEN("Plugins"); - odp.pszTemplate = MAKEINTRESOURCEA(IDD_GENDER_OPT); - odp.pszTitle = LPGEN("Gender"); - odp.pfnDlgProc = DlgProcOptions; - odp.flags = ODPF_BOLDGROUPS; - Options_AddPage(wParam, &odp); - - return 0; -} diff --git a/plugins/Gender/res/female.ico b/plugins/Gender/res/female.ico new file mode 100644 index 0000000000..fe1cbd2bce Binary files /dev/null and b/plugins/Gender/res/female.ico differ diff --git a/plugins/Gender/res/gender.ico b/plugins/Gender/res/gender.ico new file mode 100644 index 0000000000..930c34279c Binary files /dev/null and b/plugins/Gender/res/gender.ico differ diff --git a/plugins/Gender/res/gender.rc b/plugins/Gender/res/gender.rc new file mode 100644 index 0000000000..7907593e0b --- /dev/null +++ b/plugins/Gender/res/gender.rc @@ -0,0 +1,129 @@ +// Microsoft Visual C++ generated resource script. +// +#include "..\src\resource.h" + +#define APSTUDIO_READONLY_SYMBOLS +///////////////////////////////////////////////////////////////////////////// +// +// Generated from the TEXTINCLUDE 2 resource. +// +#include "afxres.h" + +///////////////////////////////////////////////////////////////////////////// +#undef APSTUDIO_READONLY_SYMBOLS + +///////////////////////////////////////////////////////////////////////////// +// Ukrainian resources + +#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_UKR) +#ifdef _WIN32 +LANGUAGE LANG_UKRAINIAN, SUBLANG_DEFAULT +#pragma code_page(1251) +#endif //_WIN32 + +///////////////////////////////////////////////////////////////////////////// +// +// Icon +// + +// Icon with lowest ID value placed first to ensure application icon +// remains consistent on all systems. +IDI_MALE ICON "male.ico" +IDI_FEMALE ICON "female.ico" +IDI_UNDEF ICON "gender.ico" +#endif // Ukrainian resources +///////////////////////////////////////////////////////////////////////////// + + +///////////////////////////////////////////////////////////////////////////// +// English (U.S.) resources + +#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU) +#ifdef _WIN32 +LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US +#pragma code_page(1252) +#endif //_WIN32 + +#ifdef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// TEXTINCLUDE +// + +1 TEXTINCLUDE +BEGIN + "..\\src\\resource.h\0" +END + +2 TEXTINCLUDE +BEGIN + "#include ""afxres.h""\r\n" + "\0" +END + +3 TEXTINCLUDE +BEGIN + "\r\n" + "\0" +END + +#endif // APSTUDIO_INVOKED + + +///////////////////////////////////////////////////////////////////////////// +// +// Dialog +// + +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 +END + + +///////////////////////////////////////////////////////////////////////////// +// +// DESIGNINFO +// + +#ifdef APSTUDIO_INVOKED +GUIDELINES DESIGNINFO +BEGIN + IDD_GENDER_OPT, DIALOG + BEGIN + LEFTMARGIN, 7 + RIGHTMARGIN, 307 + TOPMARGIN, 7 + BOTTOMMARGIN, 233 + END +END +#endif // APSTUDIO_INVOKED + +#endif // English (U.S.) resources +///////////////////////////////////////////////////////////////////////////// + + + +#ifndef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// Generated from the TEXTINCLUDE 3 resource. +// + + +///////////////////////////////////////////////////////////////////////////// +#endif // not APSTUDIO_INVOKED + diff --git a/plugins/Gender/res/male.ico b/plugins/Gender/res/male.ico new file mode 100644 index 0000000000..ebd0420554 Binary files /dev/null and b/plugins/Gender/res/male.ico differ diff --git a/plugins/Gender/resource.h b/plugins/Gender/resource.h deleted file mode 100644 index 8ea2786991..0000000000 --- a/plugins/Gender/resource.h +++ /dev/null @@ -1,25 +0,0 @@ -//{{NO_DEPENDENCIES}} -// Microsoft Visual C++ generated include file. -// Used by gender.rc -// -#define IDD_GENDER_OPT 9 -#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 -// -#ifdef APSTUDIO_INVOKED -#ifndef APSTUDIO_READONLY_SYMBOLS -#define _APS_NEXT_RESOURCE_VALUE 104 -#define _APS_NEXT_COMMAND_VALUE 40001 -#define _APS_NEXT_CONTROL_VALUE 1007 -#define _APS_NEXT_SYMED_VALUE 101 -#endif -#endif diff --git a/plugins/Gender/src/commonheaders.h b/plugins/Gender/src/commonheaders.h new file mode 100644 index 0000000000..bdea1613da --- /dev/null +++ b/plugins/Gender/src/commonheaders.h @@ -0,0 +1,65 @@ +/* + Show Contact Gender plugin for Miranda-IM (www.miranda-im.org) + (c) 2006-2011 by Thief + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + + File name : $URL: http://svn.miranda.im/mainrepo/gender/trunk/commonheaders.h $ + Revision : $Rev: 1687 $ + Last change on : $Date: 2011-01-22 18:44:21 +0200 (Сб, 22 янв 2011) $ + Last change by : $Author: Thief $ + +*/ + +#ifndef COMMHEADERS_H +#define COMMHEADERS_H + +#define _CRT_SECURE_NO_WARNINGS +#define MIRANDA_VER 0x0A00 + +#include //needed by m_utils.h +#include // needed by m_icolib.h > r9256 + +#include +#include + +//Miranda API headers +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +//Gender SDK +#include "m_gender.h" + +//Resources +#include "resource.h" + +//external SDK headers +#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 new file mode 100644 index 0000000000..5e5f1f4992 --- /dev/null +++ b/plugins/Gender/src/main.cpp @@ -0,0 +1,427 @@ +/* + Show Contact Gender plugin for Miranda-IM (www.miranda-im.org) + (c) 2006-2011 by Thief + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + + File name : $URL: http://svn.miranda.im/mainrepo/gender/trunk/main.cpp $ + Revision : $Rev: 1688 $ + Last change on : $Date: 2011-01-22 19:44:43 +0200 (Сб, 22 янв 2011) $ + Last change by : $Author: Thief $ + +*/ + +#include "commonheaders.h" + +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 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? +byte bMetaAvail = 0; // metacontacts installed? +int hLangpack; + +extern int onOptInitialise(WPARAM wParam, LPARAM lParam); + +PLUGININFOEX pluginInfo={ +sizeof(PLUGININFOEX), + "Show Contact Gender", + PLUGIN_MAKE_VERSION(0,0,2,1), + "Shows contacts gender as an icon in contact list", + "Thief, idea by nile, icons by a0x", + "thief@miranda.im", + "2006-2011 Alexander Turyak", + "http://thief.miranda.im/", + UNICODE_AWARE, //doesn't replace anything built-in + {0xfb1c17e0, 0x77fc, 0x45a7, {0x9c, 0x8b, 0xe2, 0xbe, 0xf4, 0xf5, 0x6b, 0x28}} /* FB1C17E0-77FC-45A7-9C8B-E2BEF4F56B28 */ +}; + +extern "C" BOOL WINAPI DllMain(HINSTANCE hinstDLL,DWORD fdwReason,LPVOID lpvReserved) +{ + g_hInst = hinstDLL; + return TRUE; +} + +/* 0FF3991A-5505-479D-A2E0-53DD31C6DFA7 */ +#define MIID_GENDER {0x0ff3991a, 0x5505, 0x479d, {0xa2, 0xe0, 0x53, 0xdd, 0x31, 0xc6, 0xdf, 0xa7}} + +extern "C" __declspec(dllexport) const MUUID MirandaInterfaces[] = {MIID_GENDER, MIID_LAST}; + +extern "C" __declspec(dllexport) PLUGININFOEX* MirandaPluginInfoEx(DWORD mirandaVersion) +{ + return &pluginInfo; +} + +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); + } +} + +int onExtraImageApplying(WPARAM wParam, LPARAM lParam) +{ + if (g_hExtraIcon == NULL && !bEnableClistIcon) return 0; + + HANDLE hContact = (HANDLE)wParam; + if (bMetaAvail) + { + HANDLE hMetacontact = (HANDLE)CallService(MS_MC_GETMOSTONLINECONTACT, wParam, 0); + if (hMetacontact != NULL) hContact = hMetacontact; + } + + char *proto = (char *)CallService(MS_PROTO_GETCONTACTBASEPROTO, wParam, 0); + if (!proto) return 0; + + if (DBGetContactSettingByte((HANDLE)wParam, 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)CallService(MS_SKIN2_GETICONBYHANDLE, 0, (LPARAM)g_hIconMale), (LPARAM)0); + g_IECFemale.hImage = (HANDLE)CallService(MS_CLIST_EXTRA_ADD_ICON, (WPARAM)CallService(MS_SKIN2_GETICONBYHANDLE, 0, (LPARAM)g_hIconFemale), (LPARAM)0); + g_IECUndef.hImage = (HANDLE)CallService(MS_CLIST_EXTRA_ADD_ICON, (WPARAM)CallService(MS_SKIN2_GETICONBYHANDLE, 0, (LPARAM)g_hIconMenu), (LPARAM)0); + } + } + + return 0; +} + +// Returns gender icon for specific contact +INT_PTR GetIcon(WPARAM wParam, LPARAM lParam) +{ + char *proto = (char *)CallService(MS_PROTO_GETCONTACTBASEPROTO, wParam, 0); + unsigned short gender = DBGetContactSettingByte((HANDLE)wParam, "UserInfo", "Gender", DBGetContactSettingByte((HANDLE)wParam, proto, "Gender", 0)); + + if (gender > 0) + { + if (gender == 77) return CallService(MS_SKIN2_GETICONBYHANDLE, 0, (LPARAM)g_hIconMale); + else if (gender == 70) return CallService(MS_SKIN2_GETICONBYHANDLE, 0, (LPARAM)g_hIconFemale); + } + + return 0; +} + +int onPrebuildContactMenu(WPARAM wParam, LPARAM lParam) +{ + char *proto = (char *)CallService(MS_PROTO_GETCONTACTBASEPROTO, wParam, 0); + + if (!proto) return 0; + + CLISTMENUITEM mi = {0}; + mi.cbSize = sizeof(CLISTMENUITEM); + + + if (DBGetContactSettingByte((HANDLE)wParam, proto, "ChatRoom", 0) || !(CallProtoService(proto, PS_GETCAPS, PFLAGNUM_1, 0) & PF1_IMSEND)) + mi.flags = CMIM_FLAGS | CMIF_HIDDEN; + else + mi.flags = CMIM_FLAGS; + + CallService(MS_CLIST_MODIFYMENUITEM, (WPARAM)hContactMenu, (LPARAM)&mi); + + unsigned short gender = DBGetContactSettingByte((HANDLE)wParam, proto, "Gender", DBGetContactSettingByte((HANDLE)wParam, "UserInfo", "Gender", 0)); + + CLISTMENUITEM mitem = {0}; + mitem.cbSize = sizeof(CLISTMENUITEM); + mitem.flags = CMIM_FLAGS; + + CallService(MS_CLIST_MODIFYMENUITEM, (WPARAM)hContactMenuMale, (LPARAM)&mitem); + CallService(MS_CLIST_MODIFYMENUITEM, (WPARAM)hContactMenuFemale, (LPARAM)&mitem); + CallService(MS_CLIST_MODIFYMENUITEM, (WPARAM)hContactMenuNotDef, (LPARAM)&mitem); + + mitem.flags = CMIM_FLAGS | CMIF_CHECKED; + + switch (gender) + { + case 77: + CallService(MS_CLIST_MODIFYMENUITEM, (WPARAM)hContactMenuMale, (LPARAM)&mitem); + break; + case 70: + CallService(MS_CLIST_MODIFYMENUITEM, (WPARAM)hContactMenuFemale, (LPARAM)&mitem); + break; + case 0: + CallService(MS_CLIST_MODIFYMENUITEM, (WPARAM)hContactMenuNotDef, (LPARAM)&mitem); + break; + } + + return 0; +} + +void setGender(HANDLE hContact, unsigned int gender) +{ + DBWriteContactSettingByte(hContact, "UserInfo", "Gender", gender); + setIcon(hContact, gender); + + int metasnum = (bMetaAvail ? CallService(MS_MC_GETNUMCONTACTS,(WPARAM)hContact,0) : 0); + for(int i=0; iidFrom == 0) + switch (((LPNMHDR)lParam)->code) + { + case PSN_APPLY: + { + HANDLE hContact; + + 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 = (HANDLE)CallService(MS_DB_CONTACT_FINDFIRST, 0, 0); + while (hContact) + { + CallService(MS_CLIST_EXTRA_SET_ICON, (WPARAM)hContact, (LPARAM)&g_IECClear); + hContact = (HANDLE)CallService(MS_DB_CONTACT_FINDNEXT, (WPARAM)hContact, 0); + } + } + + bEnableClistIcon = (clistIcon != 0); + + if (bEnableClistIcon) + { + g_IECClear.ColumnType = clistIcon; + onExtraImageListRebuild(0,0); + } + } + + if (g_hExtraIcon != NULL || bEnableClistIcon) + { + hContact = (HANDLE)CallService(MS_DB_CONTACT_FINDFIRST, 0, 0); + while (hContact) + { + onExtraImageApplying((WPARAM)hContact,0); + hContact = (HANDLE)CallService(MS_DB_CONTACT_FINDNEXT, (WPARAM)hContact, 0); + } + } + + 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; +} + +int onOptInitialise(WPARAM wParam, LPARAM lParam) +{ + OPTIONSDIALOGPAGE odp = { 0 }; + odp.cbSize = sizeof(odp); + odp.hInstance = g_hInst; + odp.pszGroup = LPGEN("Plugins"); + odp.pszTemplate = MAKEINTRESOURCEA(IDD_GENDER_OPT); + odp.pszTitle = LPGEN("Gender"); + odp.pfnDlgProc = DlgProcOptions; + odp.flags = ODPF_BOLDGROUPS; + Options_AddPage(wParam, &odp); + + return 0; +} diff --git a/plugins/Gender/src/resource.h b/plugins/Gender/src/resource.h new file mode 100644 index 0000000000..8ea2786991 --- /dev/null +++ b/plugins/Gender/src/resource.h @@ -0,0 +1,25 @@ +//{{NO_DEPENDENCIES}} +// Microsoft Visual C++ generated include file. +// Used by gender.rc +// +#define IDD_GENDER_OPT 9 +#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 +// +#ifdef APSTUDIO_INVOKED +#ifndef APSTUDIO_READONLY_SYMBOLS +#define _APS_NEXT_RESOURCE_VALUE 104 +#define _APS_NEXT_COMMAND_VALUE 40001 +#define _APS_NEXT_CONTROL_VALUE 1007 +#define _APS_NEXT_SYMED_VALUE 101 +#endif +#endif -- cgit v1.2.3