From 31b191bc8ddb639e488ab8306f71ac1dbabf16f0 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Sat, 3 Nov 2012 17:32:37 +0000 Subject: removing built-in Clist Modern extra icons part I git-svn-id: http://svn.miranda-ng.org/main/trunk@2167 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- plugins/BuddyExpectator/src/BuddyExpectator.cpp | 56 ++-- plugins/IgnoreState/src/commonheaders.h | 45 +-- plugins/IgnoreState/src/main.cpp | 215 ++++-------- plugins/IgnoreState/src/options.cpp | 253 +++----------- plugins/MetaContacts/src/meta_services.cpp | 423 +++++------------------- plugins/MetaContacts/src/metacontacts.h | 1 - plugins/Rate/rate_10.vcxproj | 1 - plugins/Rate/rate_10.vcxproj.filters | 3 - plugins/Rate/res/rate.rc | 44 +-- plugins/Rate/src/commonheaders.h | 17 - plugins/Rate/src/main.cpp | 165 +++------ plugins/Rate/src/options.cpp | 221 ------------- plugins/Rate/src/resource.h | 6 +- plugins/SecureIM/res/resource.rc | 2 - plugins/SecureIM/src/commonheaders.cpp | 6 +- plugins/SecureIM/src/commonheaders.h | 4 +- plugins/SecureIM/src/crypt.h | 2 - plugins/SecureIM/src/crypt_icons.cpp | 90 ++--- plugins/SecureIM/src/main.cpp | 23 +- plugins/SecureIM/src/options.cpp | 18 - plugins/SecureIM/src/resource.h | 1 - plugins/SecureIM/src/svcs_clist.cpp | 30 +- plugins/UserInfoEx/res/resource.rc | 12 +- plugins/UserInfoEx/src/Flags/svc_flags.cpp | 249 ++++---------- plugins/UserInfoEx/src/commonheaders.h | 1 - plugins/UserInfoEx/src/dlg_anniversarylist.cpp | 1 - plugins/UserInfoEx/src/init.cpp | 7 +- plugins/UserInfoEx/src/psp_options.cpp | 208 +----------- plugins/UserInfoEx/src/resource.h | 4 - plugins/UserInfoEx/src/svc_email.cpp | 72 +--- plugins/UserInfoEx/src/svc_gender.cpp | 100 +----- plugins/UserInfoEx/src/svc_homepage.cpp | 60 +--- plugins/UserInfoEx/src/svc_phone.cpp | 112 ++----- plugins/UserInfoEx/src/svc_reminder.cpp | 84 ++--- 34 files changed, 494 insertions(+), 2042 deletions(-) delete mode 100644 plugins/Rate/src/options.cpp (limited to 'plugins') diff --git a/plugins/BuddyExpectator/src/BuddyExpectator.cpp b/plugins/BuddyExpectator/src/BuddyExpectator.cpp index be864b115f..044808c013 100644 --- a/plugins/BuddyExpectator/src/BuddyExpectator.cpp +++ b/plugins/BuddyExpectator/src/BuddyExpectator.cpp @@ -561,20 +561,18 @@ int SettingChanged(WPARAM wParam, LPARAM lParam) return 0; if (DBGetContactSettingByte(hContact, "CList", "NotOnList", 0) == 1) - return 0; + return 0; char *proto = (char *)CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)hContact, 0); if (proto == 0 || (DBGetContactSettingByte(hContact, proto, "ChatRoom", 0) == 1) - || !(CallProtoService(proto, PS_GETCAPS, PFLAGNUM_1, 0) & PF1_IMSEND)) + || !(CallProtoService(proto, PS_GETCAPS, PFLAGNUM_1, 0) & PF1_IMSEND)) return 0; int currentStatus = inf->value.wVal; int prevStatus = DBGetContactSettingWord(hContact, "UserOnline", "OldStatus", ID_STATUS_OFFLINE); if (currentStatus == prevStatus) - { - return 0; - } + return 0; // Last status DBWriteContactSettingDword(hContact, MODULE_NAME, "LastStatus", prevStatus); @@ -610,19 +608,11 @@ int SettingChanged(WPARAM wParam, LPARAM lParam) } } - if (currentStatus == ID_STATUS_OFFLINE) - { - setLastSeen(hContact); - return 0; - } - - /* - if (CallService(MS_IGNORE_ISIGNORED, (WPARAM) hContact, (LPARAM) IGNOREEVENT_USERONLINE)) + if (currentStatus == ID_STATUS_OFFLINE) { setLastSeen(hContact); - return 0; + return 0; } - */ if (DBGetContactSettingDword(hContact, MODULE_NAME, "LastSeen", (DWORD)-1) == (DWORD)-1 && options.notifyFirstOnline) { @@ -632,35 +622,33 @@ int SettingChanged(WPARAM wParam, LPARAM lParam) } unsigned int AbsencePeriod = DBGetContactSettingDword(hContact, MODULE_NAME, "iAbsencePeriod", options.iAbsencePeriod); - if (isContactGoneFor(hContact, AbsencePeriod)) + if (isContactGoneFor(hContact, AbsencePeriod)) { - TCHAR* message = TranslateT("has returned after a long absence."); - time_t tmpTime; + TCHAR* message = TranslateT("has returned after a long absence."); + time_t tmpTime; TCHAR tmpBuf[251] = {0}; - tmpTime = getLastSeen(hContact); - if (tmpTime != -1) + tmpTime = getLastSeen(hContact); + if (tmpTime != -1) { - _tcsftime(tmpBuf, 250, TranslateT("has returned after being absent since %#x"), gmtime(&tmpTime)); - message = tmpBuf; - } + _tcsftime(tmpBuf, 250, TranslateT("has returned after being absent since %#x"), gmtime(&tmpTime)); + message = tmpBuf; + } else { - tmpTime = getLastInputMsg(hContact); - if (tmpTime != -1) + tmpTime = getLastInputMsg(hContact); + if (tmpTime != -1) { - _tcsftime(tmpBuf, 250, TranslateT("has returned after being absent since %#x"), gmtime(&tmpTime)); - message = tmpBuf; - } - } + _tcsftime(tmpBuf, 250, TranslateT("has returned after being absent since %#x"), gmtime(&tmpTime)); + message = tmpBuf; + } + } ReturnNotify(hContact, message); - if ((options.iShowMessageWindow == 0 && options.iShowUDetails == 0) || (options.iShowEvent == 0 && options.iShowPopUp == 0)) - { + if ((options.iShowMessageWindow == 0 && options.iShowUDetails == 0) || (options.iShowEvent == 0 && options.iShowPopUp == 0)) setLastSeen(hContact); - } - } else - setLastSeen(hContact); + } + else setLastSeen(hContact); return 0; } diff --git a/plugins/IgnoreState/src/commonheaders.h b/plugins/IgnoreState/src/commonheaders.h index e21e302b69..b7e495d570 100644 --- a/plugins/IgnoreState/src/commonheaders.h +++ b/plugins/IgnoreState/src/commonheaders.h @@ -58,57 +58,34 @@ #include "Version.h" //external SDK headers -#include #include -static const int DefaultSlot = EXTRA_ICON_PROTO; #define MODULENAME "IgnoreState" /* 3f6acec5-df0e-4d33-a272-e3630addb6c8 */ #define MIID_IGNORESRATE {0x3f6acec5, 0xdf0e, 0x4d33, {0xa2, 0x72, 0xe3, 0x63, 0x0a, 0xdd, 0xb6, 0xc8}} -static struct +struct IGNOREITEMS { - TCHAR* szDescr; - char* szName; - int defIconID; - HANDLE hIconLibItem; -} iconList[] = -{ - { LPGENT( "Full Ignore" ), "ignore_full", IDI_IFULL }, - { LPGENT( "Partial Ignore" ), "ignore_part", IDI_IPART }, - { LPGENT( "Message Ignore" ), "ignore_mess", IDI_IMESS }, -}; - -typedef struct { TCHAR* name; int type; int icon; bool filtered; -} IGNOREITEMS; - -static IGNOREITEMS ii[] = { - { LPGENT("All"), IGNOREEVENT_ALL, SKINICON_OTHER_FILLEDBLOB }, - { LPGENT("Messages"), IGNOREEVENT_MESSAGE, SKINICON_EVENT_MESSAGE }, - { LPGENT("URL"), IGNOREEVENT_URL, SKINICON_EVENT_URL }, - { LPGENT("Files"), IGNOREEVENT_FILE, SKINICON_EVENT_FILE }, - { LPGENT("User Online"), IGNOREEVENT_USERONLINE, SKINICON_OTHER_USERONLINE }, - { LPGENT("Authorization"), IGNOREEVENT_AUTHORIZATION, SKINICON_OTHER_MIRANDA }, - { LPGENT("You Were Added"), IGNOREEVENT_YOUWEREADDED, SKINICON_OTHER_ADDCONTACT }, - { LPGENT("Typing Notify"), IGNOREEVENT_TYPINGNOTIFY, SKINICON_OTHER_TYPING } }; -static int isExtraiconsUsed = 0; +extern IGNOREITEMS ii[]; +extern int nII; + static byte bUseMirandaSettings; extern HINSTANCE g_hInst; -extern int onExtraImageApplying(WPARAM wParam, LPARAM lParam); -extern int onExtraImageListRebuild(WPARAM wParam, LPARAM lParam); -extern int onOptInitialise(WPARAM wParam, LPARAM lParam); -extern BOOL checkState(int type); -extern VOID fill_filter(); + +void applyExtraImage(HANDLE hContact); + +int onOptInitialise(WPARAM wParam, LPARAM lParam); +BOOL checkState(int type); +VOID fill_filter(); + extern HANDLE hExtraIcon; -extern IconExtraColumn g_IECAuth, g_IECGrant, g_IECAuthGrant, g_IECClear; -extern INT clistIcon; #endif //COMMHEADERS_H diff --git a/plugins/IgnoreState/src/main.cpp b/plugins/IgnoreState/src/main.cpp index 9249c85ca8..886219e20f 100644 --- a/plugins/IgnoreState/src/main.cpp +++ b/plugins/IgnoreState/src/main.cpp @@ -22,27 +22,30 @@ HINSTANCE g_hInst; -HANDLE hHookModulesLoaded = NULL, hSystemOKToExit = NULL, hOptInitialise = NULL, hIcoLibIconsChanged = NULL; +HANDLE hIcoLibIconsChanged = NULL; HANDLE hHookExtraIconsRebuild = NULL, hHookExtraIconsApply = NULL, hContactSettingChanged = NULL; HANDLE hPrebuildContactMenu = NULL; HANDLE hExtraIcon = NULL; int hLangpack; INT currentFilter = 0; -//static int bUseMirandaSettings = 0; - -IconExtraColumn g_IECIgnoreFull = {0}; -IconExtraColumn g_IECIgnorePart = {0}; -IconExtraColumn g_IECIgnoreMess = {0}; -IconExtraColumn g_IECClear = {0}; +INT clistIcon = 0; //Icon slot to use +IGNOREITEMS ii[] = { + { LPGENT("All"), IGNOREEVENT_ALL, SKINICON_OTHER_FILLEDBLOB }, + { LPGENT("Messages"), IGNOREEVENT_MESSAGE, SKINICON_EVENT_MESSAGE }, + { LPGENT("URL"), IGNOREEVENT_URL, SKINICON_EVENT_URL }, + { LPGENT("Files"), IGNOREEVENT_FILE, SKINICON_EVENT_FILE }, + { LPGENT("User Online"), IGNOREEVENT_USERONLINE, SKINICON_OTHER_USERONLINE }, + { LPGENT("Authorization"), IGNOREEVENT_AUTHORIZATION, SKINICON_OTHER_MIRANDA }, + { LPGENT("You Were Added"), IGNOREEVENT_YOUWEREADDED, SKINICON_OTHER_ADDCONTACT }, + { LPGENT("Typing Notify"), IGNOREEVENT_TYPINGNOTIFY, SKINICON_OTHER_TYPING } +}; +int nII = SIZEOF(ii); -INT clistIcon = 0; //Icon slot to use -//DWORD dMask = IGNOREEVENT_USERONLINE; // by default hide online notification - -//DWORD dIgnore = 0x0; +///////////////////////////////////////////////////////////////////////////////////////// PLUGININFOEX pluginInfo={ sizeof(PLUGININFOEX), @@ -64,7 +67,6 @@ extern "C" BOOL WINAPI DllMain(HINSTANCE hinstDLL,DWORD fdwReason,LPVOID lpvRese return TRUE; } -// плагининфо extern "C" __declspec(dllexport) PLUGININFOEX* MirandaPluginInfoEx(DWORD mirandaVersion) { return &pluginInfo; @@ -72,126 +74,67 @@ extern "C" __declspec(dllexport) PLUGININFOEX* MirandaPluginInfoEx(DWORD miranda extern "C" __declspec(dllexport) const MUUID MirandaInterfaces[] = {MIID_IGNORESRATE, MIID_LAST}; -int onSystemOKToExit(WPARAM wParam,LPARAM lParam) -{ - UnhookEvent(hHookModulesLoaded); - UnhookEvent(hHookExtraIconsRebuild); - UnhookEvent(hHookExtraIconsApply); - UnhookEvent(hOptInitialise); - UnhookEvent(hSystemOKToExit); - if (hIcoLibIconsChanged) UnhookEvent(hIcoLibIconsChanged); - if (hContactSettingChanged) - UnhookEvent(hContactSettingChanged); - - return 0; -} - +///////////////////////////////////////////////////////////////////////////////////////// inline BOOL checkState(int type) { return ((currentFilter>>(type-1))&1); } - INT_PTR isIgnored(HANDLE hContact, int type) { - int i = 0, all = 0, filtered = 0; + int all = 0, filtered = 0; - if (type == IGNOREEVENT_ALL) - { - int cii = SIZEOF(ii); - for (i = 1; i < cii; i++) - { - if (isIgnored(hContact, ii[i].type)) - { -// checkState(ii[i].type) ? filtered++ : all++; - ii[i].filtered ? filtered++ : all++; - } - } - return (all+filtered == cii-1) ? 1 : (all > 0 ? -1 : 0) ; - } - else + if (type != IGNOREEVENT_ALL) return CallService(MS_IGNORE_ISIGNORED, (WPARAM)hContact, (LPARAM)type); + + for (int i = 1; i < nII; i++) + if (isIgnored(hContact, ii[i].type)) + ii[i].filtered ? filtered++ : all++; + + return (all+filtered == SIZEOF(ii)-1) ? 1 : (all > 0 ? -1 : 0) ; } -int onExtraImageApplying(WPARAM wParam, LPARAM lParam) +void applyExtraImage(HANDLE hContact) { - HANDLE hContact = (HANDLE)wParam; int ignore = isIgnored(hContact, IGNOREEVENT_ALL); - if (hExtraIcon != NULL) - { - if (ignore == 1) - { + if (ignore == 1) ExtraIcon_SetIcon(hExtraIcon, hContact, "ignore_full"); - } - else if (ignore == 0) - { + else if (ignore == 0) ExtraIcon_SetIcon(hExtraIcon, hContact, ""); - } - else if (isIgnored((HANDLE)wParam, IGNOREEVENT_MESSAGE)) - { + else if (isIgnored(hContact, IGNOREEVENT_MESSAGE)) ExtraIcon_SetIcon(hExtraIcon, hContact, "ignore_mess"); - } - else - { + else ExtraIcon_SetIcon(hExtraIcon, hContact, "ignore_part"); - } - } - else - { - if (ignore == 1) - { - CallService(MS_CLIST_EXTRA_SET_ICON, (WPARAM) wParam, (LPARAM) &g_IECIgnoreFull); - } - else if (ignore == 0) - { - CallService(MS_CLIST_EXTRA_SET_ICON, (WPARAM) wParam, (LPARAM) &g_IECClear); - } - else if (isIgnored((HANDLE)wParam, IGNOREEVENT_MESSAGE)) - { - CallService(MS_CLIST_EXTRA_SET_ICON, (WPARAM) wParam, (LPARAM) &g_IECIgnoreMess); - } - else - { - CallService(MS_CLIST_EXTRA_SET_ICON, (WPARAM) wParam, (LPARAM) &g_IECIgnorePart); - } - } - return 0; } +///////////////////////////////////////////////////////////////////////////////////////// -int onExtraImageListRebuild(WPARAM wParam, LPARAM lParam) +static struct { - g_IECIgnoreMess.cbSize = sizeof(IconExtraColumn); - g_IECIgnoreMess.ColumnType = clistIcon; - g_IECIgnorePart.cbSize = sizeof(IconExtraColumn); - g_IECIgnorePart.ColumnType = clistIcon; - g_IECIgnoreFull.cbSize = sizeof(IconExtraColumn); - g_IECIgnoreFull.ColumnType = clistIcon; - - if (ServiceExists(MS_CLIST_EXTRA_ADD_ICON)) - { - g_IECIgnoreMess.hImage = (HANDLE)CallService(MS_CLIST_EXTRA_ADD_ICON, (WPARAM)Skin_GetIcon("ignore_mess"), 0); - g_IECIgnorePart.hImage = (HANDLE)CallService(MS_CLIST_EXTRA_ADD_ICON, (WPARAM)Skin_GetIcon("ignore_part"), 0); - g_IECIgnoreFull.hImage = (HANDLE)CallService(MS_CLIST_EXTRA_ADD_ICON, (WPARAM)Skin_GetIcon("ignore_full"), 0); - } - return 0; + TCHAR* szDescr; + char* szName; + int defIconID; + HANDLE hIconLibItem; } +iconList[] = +{ + { LPGENT( "Full Ignore" ), "ignore_full", IDI_IFULL }, + { LPGENT( "Partial Ignore" ), "ignore_part", IDI_IPART }, + { LPGENT( "Message Ignore" ), "ignore_mess", IDI_IMESS }, +}; static VOID init_icolib (void) { - SKINICONDESC sid = {0}; - ZeroMemory(&sid, sizeof(sid)); TCHAR tszFile[MAX_PATH]; - sid.cbSize = sizeof(sid); - sid.flags = SIDF_ALL_TCHAR; - int i = 0; + GetModuleFileName(g_hInst, tszFile, MAX_PATH); + SKINICONDESC sid = { sizeof(sid) }; + sid.flags = SIDF_ALL_TCHAR; sid.ptszSection = _T(MODULENAME); - GetModuleFileName(g_hInst, tszFile, MAX_PATH); sid.ptszDefaultFile = tszFile; - for ( i = 0; i < SIZEOF(iconList); i++ ) { + for (int i = 0; i < SIZEOF(iconList); i++) { sid.pszName = iconList[i].szName; sid.ptszDescription = iconList[i].szDescr; sid.iDefaultIndex = -iconList[i].defIconID; @@ -205,20 +148,17 @@ VOID fill_filter(void) currentFilter = bUseMirandaSettings ? DBGetContactSettingDword(NULL, "Ignore", "Default1", 0) : DBGetContactSettingDword(NULL, MODULENAME, "Filter", 0x8); - int i = 0, cii = SIZEOF(ii); - - for (; i< cii; i++) - { - if (checkState((ii[i].type))) - ii[i].filtered = true; - else - ii[i].filtered = false; - } + for (int i=0; i < SIZEOF(ii); i++) { + if (checkState((ii[i].type))) + ii[i].filtered = true; + else + ii[i].filtered = false; + } } int onModulesLoaded(WPARAM wParam,LPARAM lParam) { - hOptInitialise = HookEvent(ME_OPT_INITIALISE, onOptInitialise); + HookEvent(ME_OPT_INITIALISE, onOptInitialise); //IcoLib support init_icolib(); @@ -226,59 +166,40 @@ int onModulesLoaded(WPARAM wParam,LPARAM lParam) hExtraIcon = ExtraIcon_Register("ignore", "IgnoreState", "ignore_full"); - if (hExtraIcon != NULL) - { - // Set initial value for all contacts - HANDLE hContact = db_find_first(); - while (hContact != NULL) - { - onExtraImageApplying((WPARAM)hContact, NULL); - hContact = db_find_next(hContact); - } - } - else - { - hIcoLibIconsChanged = HookEvent(ME_SKIN2_ICONSCHANGED, onExtraImageListRebuild); - hHookExtraIconsRebuild = HookEvent(ME_CLIST_EXTRA_LIST_REBUILD, onExtraImageListRebuild); - hHookExtraIconsApply = HookEvent(ME_CLIST_EXTRA_IMAGE_APPLY, onExtraImageApplying); - onExtraImageListRebuild(0,0); + // Set initial value for all contacts + HANDLE hContact = db_find_first(); + while (hContact != NULL) { + applyExtraImage(hContact); + hContact = db_find_next(hContact); } return 0; } - int onContactSettingChanged(WPARAM wParam,LPARAM lParam) { - DBCONTACTWRITESETTING *cws=(DBCONTACTWRITESETTING*)lParam; - if (!lstrcmpA(cws->szModule,"Ignore") & !lstrcmpA(cws->szSetting,"Mask1")) { - onExtraImageApplying(wParam, lParam); - } - if ((HANDLE)wParam ==0) - if (!lstrcmpA(cws->szModule,MODULENAME) & !lstrcmpA(cws->szSetting,"Filter") || - bUseMirandaSettings && (!lstrcmpA(cws->szModule,"Ignore") & !lstrcmpA(cws->szSetting,"Default1")) - ) { + DBCONTACTWRITESETTING *cws = (DBCONTACTWRITESETTING*)lParam; + HANDLE hContact = (HANDLE)wParam; + + if ( !lstrcmpA(cws->szModule,"Ignore") && !lstrcmpA(cws->szSetting,"Mask1")) + applyExtraImage(hContact); + else if (hContact == 0) { + if (( !lstrcmpA(cws->szModule,MODULENAME) && !lstrcmpA(cws->szSetting,"Filter")) || + (bUseMirandaSettings && !lstrcmpA(cws->szModule,"Ignore") && !lstrcmpA(cws->szSetting,"Default1"))) + { fill_filter(); } + } return 0; } extern "C" int __declspec(dllexport) Load(void) { - mir_getLP(&pluginInfo); - hHookModulesLoaded = HookEvent(ME_SYSTEM_MODULESLOADED, onModulesLoaded); - hSystemOKToExit = HookEvent(ME_SYSTEM_OKTOEXIT,onSystemOKToExit); - hContactSettingChanged = HookEvent(ME_DB_CONTACT_SETTINGCHANGED, onContactSettingChanged); - - clistIcon = DBGetContactSettingByte(NULL, MODULENAME, "AdvancedIcon", DefaultSlot); - - g_IECClear.cbSize = sizeof(IconExtraColumn); - g_IECClear.ColumnType = clistIcon; - g_IECClear.hImage = (HANDLE) -1; - + HookEvent(ME_SYSTEM_MODULESLOADED, onModulesLoaded); + HookEvent(ME_DB_CONTACT_SETTINGCHANGED, onContactSettingChanged); return 0; } diff --git a/plugins/IgnoreState/src/options.cpp b/plugins/IgnoreState/src/options.cpp index ba1f01488e..cdd27fb3be 100644 --- a/plugins/IgnoreState/src/options.cpp +++ b/plugins/IgnoreState/src/options.cpp @@ -20,244 +20,93 @@ #include "commonheaders.h" -//extern byte bUseAuthIcon, bUseGrantIcon, bContactMenuItem, bIconsForRecentContacts; - -//#define EXTRA_ICON_RES0 0 // only used by nicer -//#define EXTRA_ICON_EMAIL 1 -//#define EXTRA_ICON_WEB 2 -//#define EXTRA_ICON_SMS 3 -//#define EXTRA_ICON_ADV1 4 -//#define EXTRA_ICON_ADV2 5 -//#define EXTRA_ICON_ADV3 6 -//#define EXTRA_ICON_CLIENT 7 -//#define EXTRA_ICON_ADV4 8 -//#define EXTRA_ICON_RES1 9 // only used by nicer -//#define EXTRA_ICON_PROTO 9 // used by mwclist and modern -//#define EXTRA_ICON_RES2 10 // only used by nicer -//#define EXTRA_ICON_VISMODE 10 // only used by modern - #define MS_SKINENG_DRAWICONEXFIX "SkinEngine/DrawIconEx_Fix" -enum { - clist_none, - clist_modern, - clist_nicer -}; - -TCHAR* szAdvancedIconsModern[] = { - _T("E-mail"), - _T("Web page"), - _T("Phone/SMS"), - _T("Advanced #1"), - _T("Advanced #2"), - _T("Advanced #3"), - _T("Client"), - _T("Advanced #4"), - _T("Protocol"), - _T("Visibility/Chat activity") -}; -//const int cAdvancedIconsModern = sizeof(szAdvancedIconsModern) / sizeof(szAdvancedIconsModern[0]); - -TCHAR* szAdvancedIconsNicer[] = { - _T("Reserved"), - _T("E-mail"), - _T("Homepage"), - _T("Telephone"), - _T("Advanced #1"), - _T("Advanced #2"), - _T("Client"), - _T("Advanced #3"), - _T("Advanced #4"), - _T("Reserved #1"), - _T("Reserved #2") - }; -//const int cAdvancedIconsNicer = sizeof(szAdvancedIconsNicer) / sizeof(szAdvancedIconsNicer[0]); +static bool bInitializing; INT_PTR CALLBACK DlgProcOptions(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) { - HIMAGELIST himlButtonIcons=NULL; - INT bInitializing = 0; - INT usedClist = clist_none; - INT cAdvancedIcons; - isExtraiconsUsed = ServiceExists(MS_EXTRAICON_REGISTER); -// const char **szAdvancedIcons; HWND hTree=GetDlgItem(hwndDlg,IDC_FILTER); - switch (msg) - { - case WM_INITDIALOG: + switch (msg) { + case WM_INITDIALOG: { TranslateDialogDefault(hwndDlg); - bInitializing = 1; + bInitializing = true; fill_filter(); - if (ServiceExists(MS_CLIST_EXTRA_ADD_ICON)) - { - if (hExtraIcon == NULL) - { - if (ServiceExists(MS_SKINENG_DRAWICONEXFIX)) - { // modern? - cAdvancedIcons = SIZEOF(szAdvancedIconsModern); - usedClist = clist_modern; - } - else - { - if (ServiceExists("CLN/About")) - { - usedClist = clist_nicer; - cAdvancedIcons = SIZEOF(szAdvancedIconsNicer); - } - else - { - usedClist = clist_modern; - cAdvancedIcons = SIZEOF(szAdvancedIconsModern) - 1; // mw doesn`t have last modern extraicon - } - } - } - else - { - SendDlgItemMessage(hwndDlg,IDC_NOTICE, WM_SETTEXT,0,(LPARAM)TranslateT("Extraicons plugin is used, use Contact list > Extraicons for customize.")); - ShowWindow(GetDlgItem(hwndDlg, IDC_NOTICE), SW_SHOW); - EnableWindow(GetDlgItem(hwndDlg, IDC_ADVICON), 0); - } - } - else - { - cAdvancedIcons = 0; -// SendDlgItemMessage(hwndDlg,IDC_USED_CLIST, WM_SETTEXT,0,(LPARAM)_T("Your clist: classic")); - SendDlgItemMessage(hwndDlg,IDC_NOTICE, WM_SETTEXT,0,(LPARAM)TranslateT("Warning: classic contact list plugin doesn`t have ability to use extraicons")); - ShowWindow(GetDlgItem(hwndDlg, IDC_NOTICE), SW_SHOW); - EnableWindow(GetDlgItem(hwndDlg, IDC_ADVICON), 0); - } - if (usedClist != clist_none) { - for (int i = 0; i < cAdvancedIcons; i++) - { - SendMessage(GetDlgItem(hwndDlg, IDC_ADVICON), CB_ADDSTRING, 0, (LPARAM) TranslateTS( usedClist==clist_modern ? szAdvancedIconsModern[i] : szAdvancedIconsNicer[i])); - } - if (usedClist == clist_modern ) - SendMessage(GetDlgItem(hwndDlg, IDC_ADVICON), CB_SETCURSEL, clistIcon-1, 0); - else - SendMessage(GetDlgItem(hwndDlg, IDC_ADVICON), CB_SETCURSEL, clistIcon, 0); - } + SendDlgItemMessage(hwndDlg,IDC_NOTICE, WM_SETTEXT,0,(LPARAM)TranslateT("Extraicons plugin is used, use Contact list > Extraicons for customize.")); + ShowWindow(GetDlgItem(hwndDlg, IDC_NOTICE), SW_SHOW); + EnableWindow(GetDlgItem(hwndDlg, IDC_ADVICON), 0); SetWindowLongPtr(hTree,GWL_STYLE,GetWindowLongPtr(hTree,GWL_STYLE)|TVS_NOHSCROLL); - { - himlButtonIcons=ImageList_Create(GetSystemMetrics(SM_CXSMICON),GetSystemMetrics(SM_CYSMICON),ILC_COLOR32|ILC_MASK,2,2); - TreeView_SetImageList(hTree,himlButtonIcons,TVSIL_NORMAL); - } + + HIMAGELIST himlButtonIcons = ImageList_Create(GetSystemMetrics(SM_CXSMICON),GetSystemMetrics(SM_CYSMICON),ILC_COLOR32|ILC_MASK,2,2); + TreeView_SetImageList(hTree,himlButtonIcons,TVSIL_NORMAL); TreeView_DeleteAllItems(hTree); - int i; - int cii = SIZEOF(ii); - for (i=2; iidFrom) - { - case 0: - { - switch (((LPNMHDR)lParam)->code) - { - case PSN_APPLY: - { - if (usedClist==clist_none && hExtraIcon == NULL ) - return TRUE; -/////////// - DWORD flags=0; - TVITEM tvi; - tvi.mask=TVIF_HANDLE|TBIF_LPARAM; - HWND hTree=GetDlgItem(hwndDlg,IDC_FILTER); - tvi.hItem=TreeView_GetRoot(hTree); //check ignore all - while(tvi.hItem) - { - TreeView_GetItem(hTree,&tvi); - if(TreeView_GetCheckState(hTree,tvi.hItem)) flags|=1<<(tvi.lParam-1); - tvi.hItem=TreeView_GetNextSibling(hTree,tvi.hItem); - } - DBWriteContactSettingDword(NULL, MODULENAME, "Filter", flags); - bUseMirandaSettings = IsDlgButtonChecked(hwndDlg,IDC_IGNORE_IGNOREALL) ? 1 : 0; - DBWriteContactSettingByte(NULL, MODULENAME, "UseMirandaSettings", bUseMirandaSettings); + case IDC_IGNORE_IGNOREALL: + EnableWindow(GetDlgItem(hwndDlg, IDC_FILTER), !IsDlgButtonChecked(hwndDlg,IDC_IGNORE_IGNOREALL)); + SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0); + break; + } + break; - fill_filter(); -////////// - if (hExtraIcon == NULL) - { - clistIcon = SendMessage(GetDlgItem(hwndDlg, IDC_ADVICON), CB_GETCURSEL, 0, 0); - if (usedClist == clist_modern ) - clistIcon++; + case WM_NOTIFY: + switch (((LPNMHDR)lParam)->idFrom) { + case 0: + switch (((LPNMHDR)lParam)->code) { + case PSN_APPLY: + { + DWORD flags=0; + TVITEM tvi; + tvi.mask=TVIF_HANDLE|TBIF_LPARAM; + HWND hTree=GetDlgItem(hwndDlg,IDC_FILTER); + tvi.hItem=TreeView_GetRoot(hTree); //check ignore all + while(tvi.hItem) { + TreeView_GetItem(hTree,&tvi); + if(TreeView_GetCheckState(hTree,tvi.hItem)) flags|=1<<(tvi.lParam-1); + tvi.hItem=TreeView_GetNextSibling(hTree,tvi.hItem); + } + DBWriteContactSettingDword(NULL, MODULENAME, "Filter", flags); - //Store options values to DB - DBWriteContactSettingByte(NULL, MODULENAME, "AdvancedIcon", clistIcon); + bUseMirandaSettings = IsDlgButtonChecked(hwndDlg,IDC_IGNORE_IGNOREALL) ? 1 : 0; + DBWriteContactSettingByte(NULL, MODULENAME, "UseMirandaSettings", bUseMirandaSettings); - HANDLE hContact = db_find_first(); - while (hContact) - { - CallService(MS_CLIST_EXTRA_SET_ICON, (WPARAM)hContact, (LPARAM)&g_IECClear); - hContact = db_find_next(hContact); - } - g_IECClear.ColumnType = clistIcon; - if (hExtraIcon == NULL) - onExtraImageListRebuild(0,0); - hContact = db_find_first(); - while (hContact) - { - onExtraImageApplying((WPARAM)hContact,0); - hContact = db_find_next(hContact); - } - } - } - } - } - case IDC_FILTER: - if (((LPNMHDR)lParam)->code == NM_CLICK) - { - SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0); + fill_filter(); } } - } - case WM_DESTROY: + case IDC_FILTER: + if (((LPNMHDR)lParam)->code == NM_CLICK) + SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0); break; + } } return FALSE; } diff --git a/plugins/MetaContacts/src/meta_services.cpp b/plugins/MetaContacts/src/meta_services.cpp index 26609d23be..9379b39f8d 100644 --- a/plugins/MetaContacts/src/meta_services.cpp +++ b/plugins/MetaContacts/src/meta_services.cpp @@ -27,9 +27,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "metacontacts.h" -#define NB_SERVICES 62 //!< Number of services registered in Miranda (see Meta_CloseHandles()). -#define NB_HOOKS 17 //!< Number of hooks set up (see Meta_CloseHandles()). - #define PREF_METANODB 0x2000 //!< Flag to indicate message should not be added to db by filter when sending char *pendingACK = 0; //!< Name of the protocol in which an ACK is about to come. @@ -37,12 +34,6 @@ char *pendingACK = 0; //!< Name of the protocol in which an ACK is about to com int previousMode, //!< Previous status of the MetaContacts Protocol mcStatus; //!< Current status of the MetaContacts Protocol -HANDLE hServices[NB_SERVICES] = {0}, //!< list of all the services registered (see Meta_CloseHandles()). -hHooks[NB_HOOKS] = {0}; //!< list of all hooks set up (see Meta_CloseHandles()). - -HANDLE *hNudgeEvents = 0; -int iNudgeProtos = 0; - HGENMENU hMenuConvert, //!< \c HANDLE to the convert menu item. hMenuAdd, //!< \c HANDLE to the add to menu item. @@ -65,7 +56,6 @@ DWORD nextMetaID; //!< Global variable specifying the ID value the next MetaCont BOOL message_window_api_enabled = FALSE; //!< Global variable specifying whether the message window api ver 0.0.0.1+ is available // stuff for mw_clist extra icon -int proto_count = 0; HANDLE hExtraImage[MAX_PROTOCOLS * 2]; // online and offline icons char proto_names[MAX_PROTOCOLS * 128]; HANDLE hProtoIcons[MAX_PROTOCOLS * 2]; // online and offline icons @@ -1167,7 +1157,6 @@ int NudgeRecieved(WPARAM wParam, LPARAM lParam) { */ int Meta_ModulesLoaded(WPARAM wParam, LPARAM lParam) { - CLISTMENUITEM mi = {0}; char buffer[512], buffer2[512], buffer3[512]; int i; @@ -1185,16 +1174,11 @@ int Meta_ModulesLoaded(WPARAM wParam, LPARAM lParam) if (ServiceExists("DBEditorpp/RegisterSingleModule")) CallService("DBEditorpp/RegisterSingleModule",(WPARAM)META_PROTO,0); - hHooks[11] = (HANDLE)HookEvent(ME_CLIST_PREBUILDCONTACTMENU, Meta_ModifyMenu); - hHooks[12] = (HANDLE)HookEvent(ME_CLIST_DOUBLECLICKED, Meta_ClistDoubleClicked ); - //hHooks[13] = (HANDLE)HookEvent(ME_CLIST_EXTRA_LIST_REBUILD, Meta_CListMW_ExtraIconsRebuild); - //hHooks[14] = (HANDLE)HookEvent(ME_CLIST_EXTRA_IMAGE_APPLY, Meta_CListMW_ExtraIconsApply); + HookEvent(ME_CLIST_PREBUILDCONTACTMENU, Meta_ModifyMenu); + HookEvent(ME_CLIST_DOUBLECLICKED, Meta_ClistDoubleClicked ); - // icons are erased on this event... - // (BUT, the me_clist_extra_list_rebuild is send FIRST...so, we ignore this one...) - hHooks[15] = 0;//(HANDLE)HookEvent(ME_SKIN_ICONSCHANGED, Meta_LoadIcons); - - mi.cbSize = sizeof(mi); + //////////////////////////////////////////////////////////////////////////// + CLISTMENUITEM mi = { sizeof(mi) }; mi.flags = CMIM_ALL; // main menu item @@ -1284,8 +1268,7 @@ int Meta_ModulesLoaded(WPARAM wParam, LPARAM lParam) } // hook srmm window close/open events - message api ver 0.0.0.1+ - hHooks[16] = (HANDLE)HookEvent(ME_MSG_WINDOWEVENT, Meta_MessageWindowEvent); - if (hHooks[16]) // message api available + if (HookEvent(ME_MSG_WINDOWEVENT, Meta_MessageWindowEvent)) message_window_api_enabled = TRUE; // hook protocol nudge events to forward to subcontacts @@ -1301,15 +1284,9 @@ int Meta_ModulesLoaded(WPARAM wParam, LPARAM lParam) { if (strcmp(ppProtocolDescriptors[i]->szModuleName, META_PROTO)) { sprintf(str,"%s/Nudge",ppProtocolDescriptors[i]->szModuleName); - hNudgeEvent = HookEvent(str, NudgeRecieved); - if (hNudgeEvent != NULL) { - ++iNudgeProtos; - hNudgeEvents = (HANDLE *)realloc(hNudgeEvents, sizeof(HANDLE) * iNudgeProtos); - hNudgeEvents[iNudgeProtos - 1] = hNudgeEvent; - } + HookEvent(str, NudgeRecieved); } } - } } return 0; @@ -1378,192 +1355,6 @@ INT_PTR Meta_ContactMenuFunc(WPARAM wParam, LPARAM lParam) { //////////////////// // file transfer support - mostly not required, since subcontacts do the receiving //////////////////// -/* -INT_PTR Meta_FileResume(WPARAM wParam, LPARAM lParam) -{ - DBVARIANT dbv; - CCSDATA *ccs = (CCSDATA *) lParam; - char *proto = 0; - - if (DBGetContactSetting(ccs->hContact,META_PROTO,"Default",&dbv)) - { - // This is a simple contact - // (this should normally not happen, since linked contacts do not appear on the list.) - return 1; - } - else - { - HANDLE most_online = Meta_GetMostOnlineSupporting(ccs->hContact, PFLAGNUM_1, PF1_FILERESUME); - //DBEVENTINFO dbei; - char szServiceName[100]; - - DBFreeVariant(&dbv); - - if (!most_online) - return 0; - - proto = (char *)CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)most_online, 0); - - ccs->hContact = most_online; - Meta_SetNick(proto); - - _snprintf(szServiceName, sizeof(szServiceName), "%s%s", proto, PS_FILERESUME); - if (ServiceExists(szServiceName)) { - strncpy(szServiceName, PS_FILERESUME, sizeof(szServiceName)); - return (int)(CallContactService(ccs->hContact, szServiceName, ccs->wParam, ccs->lParam)); - } - } - return 1; // fail -} - -INT_PTR Meta_FileAllow(WPARAM wParam, LPARAM lParam) -{ - DBVARIANT dbv; - CCSDATA *ccs = (CCSDATA *) lParam; - char *proto = 0; - - if (DBGetContactSetting(ccs->hContact,META_PROTO,"Default",&dbv)) - { - // This is a simple contact - // (this should normally not happen, since linked contacts do not appear on the list.) - return 0; - } - else - { - HANDLE most_online = Meta_GetMostOnlineSupporting(ccs->hContact, PFLAGNUM_1, PF1_FILE); - char szServiceName[100]; - - DBFreeVariant(&dbv); - - if (!most_online) - return 0; - - proto = (char *)CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)most_online, 0); - - ccs->hContact = most_online; - Meta_SetNick(proto); - - _snprintf(szServiceName, sizeof(szServiceName), "%s%s", proto, PSS_FILEALLOW); - if (ServiceExists(szServiceName)) { - strncpy(szServiceName, PSS_FILEALLOW, sizeof(szServiceName)); - return (int)(CallContactService(ccs->hContact, szServiceName, ccs->wParam, ccs->lParam)); - } - } - return 0; // fail -} - -INT_PTR Meta_FileDeny(WPARAM wParam, LPARAM lParam) -{ - DBVARIANT dbv; - CCSDATA *ccs = (CCSDATA *) lParam; - char *proto = 0; - - if (DBGetContactSetting(ccs->hContact,META_PROTO,"Default",&dbv)) - { - // This is a simple contact - // (this should normally not happen, since linked contacts do not appear on the list.) - return 1; - } - else - { - HANDLE most_online = Meta_GetMostOnlineSupporting(ccs->hContact, PFLAGNUM_1, PF1_FILE); - //DBEVENTINFO dbei; - char szServiceName[100]; - - DBFreeVariant(&dbv); - - if (!most_online) - return 1; - - proto = (char *)CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)most_online, 0); - - ccs->hContact = most_online; - Meta_SetNick(proto); - - _snprintf(szServiceName, sizeof(szServiceName), "%s%s", proto, PSS_FILEDENY); - if (ServiceExists(szServiceName)) { - strncpy(szServiceName, PSS_FILEDENY, sizeof(szServiceName)); - return (int)(CallContactService(ccs->hContact, szServiceName, ccs->wParam, ccs->lParam)); - } - } - return 1; // fail -} - -INT_PTR Meta_FileRecv(WPARAM wParam, LPARAM lParam) -{ - DBVARIANT dbv; - CCSDATA *ccs = (CCSDATA *) lParam; - char *proto = 0; - - if (DBGetContactSetting(ccs->hContact,META_PROTO,"Default",&dbv)) - { - // This is a simple contact - // (this should normally not happen, since linked contacts do not appear on the list.) - return 0; - } - else - { - HANDLE most_online = Meta_GetMostOnlineSupporting(ccs->hContact, PFLAGNUM_1, PF1_FILE); - //DBEVENTINFO dbei; - char szServiceName[100]; - - DBFreeVariant(&dbv); - - if (!most_online) - return 0; - - proto = (char *)CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)most_online, 0); - - ccs->hContact = most_online; - Meta_SetNick(proto); - - _snprintf(szServiceName, sizeof(szServiceName), "%s%s", proto, PSR_FILE); - if (ServiceExists(szServiceName)) { - strncpy(szServiceName, PSR_FILE, sizeof(szServiceName)); - return (int)(CallContactService(ccs->hContact, szServiceName, ccs->wParam, ccs->lParam)); - } - } - - return 0; -} - -int Meta_FileCancel(WPARAM wParam, LPARAM lParam) -{ - DBVARIANT dbv; - CCSDATA *ccs = (CCSDATA *) lParam; - char *proto = 0; - - if (DBGetContactSetting(ccs->hContact,META_PROTO,"Default",&dbv)) - { - // This is a simple contact - // (this should normally not happen, since linked contacts do not appear on the list.) - return 0; - } - else - { - HANDLE most_online = Meta_GetMostOnlineSupporting(ccs->hContact, PFLAGNUM_1, PF1_FILE); - //DBEVENTINFO dbei; - char szServiceName[100]; - - DBFreeVariant(&dbv); - - if (!most_online) - return 0; - - proto = (char *)CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)most_online, 0); - - ccs->hContact = most_online; - Meta_SetNick(proto); - - _snprintf(szServiceName, sizeof(szServiceName), "%s%s", proto, PSS_FILECANCEL); - if (ServiceExists(szServiceName)) { - strncpy(szServiceName, PSS_FILECANCEL, sizeof(szServiceName)); - return (int)(CallContactService(ccs->hContact, szServiceName, ccs->wParam, ccs->lParam)); - } - } - return 0; -} -*/ INT_PTR Meta_FileSend(WPARAM wParam, LPARAM lParam) { @@ -1828,103 +1619,89 @@ int Meta_OnIdleChanged(WPARAM wParam, LPARAM lParam) { */ void Meta_InitServices() { - int i; - previousMode = mcStatus = ID_STATUS_OFFLINE; - // set hooks pointers and services pointers to zero - in case we do not initialize them all correctly - for (i=0;i