From bd8a04455d9c991c15df2287e091abe4ba054efb Mon Sep 17 00:00:00 2001 From: George Hazan Date: Sun, 25 Nov 2012 12:54:45 +0000 Subject: typed stub for MS_PROTO_GETCONTACTBASEPROTO git-svn-id: http://svn.miranda-ng.org/main/trunk@2480 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- plugins/AVS/src/acc.cpp | 2 +- plugins/AVS/src/main.cpp | 16 +- plugins/AVS/src/options.cpp | 6 +- plugins/AVS/src/poll.cpp | 2 +- plugins/AuthState/src/main.cpp | 6 +- plugins/AutoShutdown/src/watcher.cpp | 14 +- plugins/AvatarHistory/src/AvatarDlg.cpp | 2 +- plugins/AvatarHistory/src/AvatarHistory.cpp | 8 +- plugins/AvatarHistory/src/icolib.cpp | 2 +- plugins/BasicHistory/src/DatExport.cpp | 2 +- plugins/BasicHistory/src/EventList.cpp | 10 +- plugins/BasicHistory/src/HistoryWindow.cpp | 2 +- plugins/Boltun/src/actionQueue.cpp | 2 +- plugins/BuddyExpectator/src/BuddyExpectator.cpp | 8 +- .../ClientChangeNotify/src/ClientChangeNotify.cpp | 6 +- plugins/Clist_modern/src/modern_awaymsg.cpp | 2 +- plugins/Clist_modern/src/modern_cachefuncs.cpp | 2 +- plugins/Clist_modern/src/modern_clc.cpp | 2 +- plugins/Clist_modern/src/modern_clcitems.cpp | 2 +- plugins/Clist_modern/src/modern_clistevents.cpp | 2 +- plugins/Clist_modern/src/modern_clistmod.cpp | 2 +- plugins/Clist_modern/src/modern_clistsettings.cpp | 2 +- plugins/Clist_modern/src/modern_contact.cpp | 2 +- plugins/Clist_mw/src/clistmod.cpp | 2 +- plugins/Clist_mw/src/clistsettings.cpp | 2 +- plugins/Clist_mw/src/contact.cpp | 5 +- plugins/Clist_nicer/src/clc.cpp | 8 +- plugins/Clist_nicer/src/clcitems.cpp | 12 +- plugins/Clist_nicer/src/clistevents.cpp | 2 +- plugins/Clist_nicer/src/clistmenus.cpp | 2 +- plugins/Clist_nicer/src/clistmod.cpp | 2 +- plugins/Clist_nicer/src/clui.cpp | 6 +- plugins/Clist_nicer/src/contact.cpp | 4 +- plugins/Clist_nicer/src/extBackg.cpp | 2 +- plugins/CmdLine/src/mimcmd_handlers.cpp | 6 +- plugins/CmdLine/src/utils.cpp | 8 +- plugins/CmdLine/src/utils.h | 2 +- plugins/ContactsPlus/src/main.cpp | 4 +- plugins/ContactsPlus/src/receive.cpp | 6 +- plugins/ContactsPlus/src/send.cpp | 8 +- plugins/ContactsPlus/src/utils.cpp | 12 +- plugins/ContactsPlus/src/utils.h | 1 - plugins/CountryFlags/src/extraimg.cpp | 2 +- plugins/DbEditorPP/src/exportimport.cpp | 2 +- plugins/FTPFileYM/src/mir_db.cpp | 2 +- plugins/FavContacts/src/favlist.h | 2 +- plugins/FavContacts/src/http_api.cpp | 2 +- plugins/FavContacts/src/main.cpp | 4 +- plugins/FileAsMessage/src/dialog.cpp | 3 +- plugins/FingerPrintModPlus/src/fingerprint.cpp | 2 +- plugins/FlashAvatars/src/cflash.cpp | 2 +- plugins/FloatingContacts/src/thumbs.cpp | 4 +- plugins/Gender/src/main.cpp | 6 +- plugins/IEView/src/HTMLBuilder.cpp | 12 +- plugins/Import/src/import.cpp | 4 +- plugins/KeyboardNotify/src/ignore.cpp | 2 +- plugins/KeyboardNotify/src/main.cpp | 6 +- plugins/ListeningTo/src/listeningto.cpp | 4 +- plugins/ListeningTo/src/players/mradio.cpp | 2 +- plugins/MenuItemEx/src/main.cpp | 61 ++-- plugins/MetaContacts/src/edit.cpp | 2 +- plugins/MetaContacts/src/meta_main.cpp | 2 +- plugins/MetaContacts/src/meta_menu.cpp | 6 +- plugins/MetaContacts/src/meta_services.cpp | 32 +- plugins/MetaContacts/src/meta_utils.cpp | 22 +- plugins/MirOTR/MirOTR/src/svcs_proto.cpp | 4 +- plugins/MirOTR/MirOTR/src/svcs_srmm.cpp | 6 +- plugins/MirOTR/MirOTR/src/utils.cpp | 4 +- plugins/MobileState/src/main.cpp | 4 +- plugins/NewEventNotify/src/main.cpp | 2 +- plugins/NewXstatusNotify/src/indsnd.cpp | 4 +- plugins/NewXstatusNotify/src/main.cpp | 12 +- plugins/NewXstatusNotify/src/popup.cpp | 4 +- plugins/NewXstatusNotify/src/xstatus.cpp | 2 +- plugins/New_GPG/src/messages.cpp | 10 +- plugins/New_GPG/src/metacontacts.cpp | 2 +- plugins/New_GPG/src/options.cpp | 2 +- plugins/New_GPG/src/utilities.cpp | 6 +- plugins/NoHistory/src/dllmain.cpp | 6 +- plugins/NoHistory/src/options.cpp | 4 +- plugins/Nudge/src/main.cpp | 17 +- plugins/PasteIt/src/PasteIt.cpp | 6 +- plugins/Popup/src/popup_wnd2.cpp | 17 +- plugins/Popup/src/services.cpp | 4 +- plugins/QuickContacts/src/quickcontacts.cpp | 6 +- plugins/QuickMessages/src/Utils.cpp | 6 +- plugins/RecentContacts/src/RecentContacts.cpp | 2 +- plugins/Scriver/src/chat/clist.cpp | 12 +- plugins/Scriver/src/globals.cpp | 2 +- plugins/Scriver/src/msgdialog.cpp | 13 +- plugins/Scriver/src/msglog.cpp | 2 +- plugins/Scriver/src/msgs.cpp | 32 +- plugins/Scriver/src/msgwindow.cpp | 2 +- plugins/Scriver/src/sendqueue.cpp | 2 +- plugins/SecureIM/src/crypt_metacontacts.cpp | 2 +- plugins/SecureIM/src/crypt_misc.cpp | 2 +- plugins/SecureIM/src/dbevent.cpp | 2 +- plugins/SecureIM/src/svcs_clist.cpp | 2 +- plugins/SecureIM/src/svcs_proto.cpp | 2 +- plugins/SeenPlugin/src/menu.cpp | 2 +- plugins/SeenPlugin/src/userinfo.cpp | 2 +- plugins/SeenPlugin/src/utils.cpp | 20 +- plugins/SendScreenshotPlus/src/CSend.cpp | 2 +- plugins/SendScreenshotPlus/src/Main.cpp | 4 +- plugins/SimpleAR/src/Main.cpp | 2 +- plugins/SimpleStatusMsg/src/awaymsg.cpp | 4 +- plugins/SimpleStatusMsg/src/main.cpp | 2 +- plugins/SmileyAdd/src/dlgboxsubclass.cpp | 7 +- plugins/SmileyAdd/src/services.cpp | 4 +- plugins/SmileyAdd/src/smileys.cpp | 6 +- plugins/SpellChecker/src/spellchecker.cpp | 2 +- plugins/StopSpamMod/src/utilities.cpp | 8 +- plugins/StopSpamPlus/src/services.cpp | 2 +- plugins/TabSRMM/src/chat/clist.cpp | 14 +- plugins/TabSRMM/src/chat/services.cpp | 2 +- plugins/TabSRMM/src/chat/window.cpp | 2 +- plugins/TabSRMM/src/contactcache.cpp | 4 +- plugins/TabSRMM/src/container.cpp | 8 +- plugins/TabSRMM/src/generic_msghandlers.cpp | 2 +- plugins/TabSRMM/src/mim.cpp | 7 +- plugins/TabSRMM/src/modplus.cpp | 2 +- plugins/TabSRMM/src/msgdialog.cpp | 2 +- plugins/TabSRMM/src/msgdlgutils.cpp | 2 +- plugins/TabSRMM/src/msgs.cpp | 6 +- plugins/TabSRMM/src/sendlater.cpp | 2 +- plugins/TabSRMM/src/sendqueue.cpp | 8 +- plugins/TabSRMM/src/templates.cpp | 4 +- plugins/TabSRMM/src/trayicon.cpp | 2 +- plugins/TabSRMM/src/typingnotify.cpp | 2 +- plugins/TabSRMM/src/userprefs.cpp | 23 +- plugins/TipperYM/src/message_pump.cpp | 2 +- plugins/TipperYM/src/popwin.cpp | 8 +- plugins/TipperYM/src/subst.cpp | 20 +- plugins/TooltipNotify/src/TooltipNotify.cpp | 2 +- plugins/UserInfoEx/src/Flags/svc_flags.cpp | 3 +- plugins/Variables/src/contact.cpp | 23 +- plugins/Variables/src/parse_metacontacts.cpp | 6 +- plugins/Variables/src/parse_miranda.cpp | 2 +- plugins/WhenWasIt/src/WhenWasIt.cpp | 32 +- plugins/WhenWasIt/src/birthdays.cpp | 2 +- plugins/WhenWasIt/src/date_utils.cpp | 254 +++++++--------- plugins/WhenWasIt/src/dlg_handlers.cpp | 115 +++----- plugins/WhenWasIt/src/hooked_events.cpp | 8 +- plugins/WhenWasIt/src/icons.cpp | 2 +- plugins/WhenWasIt/src/notifiers.cpp | 8 +- plugins/WhenWasIt/src/services.cpp | 326 +++++++++------------ plugins/WhenWasIt/src/utils.cpp | 209 +++++-------- plugins/WhenWasIt/src/utils.h | 1 - 148 files changed, 747 insertions(+), 1024 deletions(-) (limited to 'plugins') diff --git a/plugins/AVS/src/acc.cpp b/plugins/AVS/src/acc.cpp index 507245fca8..00e0c644c8 100644 --- a/plugins/AVS/src/acc.cpp +++ b/plugins/AVS/src/acc.cpp @@ -567,7 +567,7 @@ static LRESULT CALLBACK ACCWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM l DestroyAnimation(hwnd, data); data->hContact = (HANDLE) lParam; - lstrcpynA(data->proto, (char*) CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)data->hContact, 0), sizeof(data->proto)); + lstrcpynA(data->proto, GetContactProto(data->hContact), sizeof(data->proto)); StartAnimation(hwnd, data); diff --git a/plugins/AVS/src/main.cpp b/plugins/AVS/src/main.cpp index 91ba752a27..251c612c41 100644 --- a/plugins/AVS/src/main.cpp +++ b/plugins/AVS/src/main.cpp @@ -165,7 +165,7 @@ int _DebugTrace(HANDLE hContact, const char *fmt, ...) if (hContact != NULL) { name = (char*) CallService(MS_CLIST_GETCONTACTDISPLAYNAME, (WPARAM)hContact, 0); - proto = (char*) CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)hContact, 0); + proto = GetContactProto(hContact); } mir_snprintf(text, SIZEOF(text) - 10, " ***** AVS [%08d] [ID:%04x]: [%08d - %s - %s] ", @@ -252,7 +252,7 @@ static void NotifyMetaAware(HANDLE hContact, struct CacheNode *node = NULL, AVAT cacn.filename[MAX_PATH - 1] = 0; // Get hash - char *szProto = (char *)CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)hContact, 0); + char *szProto = GetContactProto(hContact); if (szProto != NULL) { DBVARIANT dbv = {0}; if (!DBGetContactSetting(hContact, szProto, "AvatarHash", &dbv)) { @@ -434,7 +434,7 @@ int CreateAvatarInCache(HANDLE hContact, avatarCacheEntry *ace, char *szProto) ace->szFilename[0] = 0; if (szProto == NULL) { - char *proto = (char *) CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)hContact, 0); + char *proto = GetContactProto(hContact); if (proto == NULL || !DBGetContactSettingByte(NULL, AVS_MODULE, proto, 1)) { return -1; } @@ -639,7 +639,7 @@ struct CacheNode *FindAvatarInCache(HANDLE hContact, BOOL add, BOOL findAny = FA { struct CacheNode *cacheNode = g_Cache, *foundNode = NULL; - char *szProto = (char *) CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)hContact, 0); + char *szProto = GetContactProto(hContact); if (szProto == NULL || !DBGetContactSettingByte(NULL, AVS_MODULE, szProto, 1)) return NULL; @@ -749,7 +749,7 @@ static int ProtocolAck(WPARAM wParam, LPARAM lParam) } else if (ack->result == ACKRESULT_STATUS) { - char *szProto = (char *) CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)ack->hContact, 0); + char *szProto = GetContactProto(ack->hContact); if (szProto == NULL || Proto_NeedDelaysForAvatars(szProto)) { // Queue @@ -1702,7 +1702,7 @@ INT_PTR GetMyAvatar(WPARAM wParam, LPARAM lParam) static protoPicCacheEntry *GetProtoDefaultAvatar(HANDLE hContact) { - char *szProto = (char *)CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)hContact, 0); + char *szProto = GetContactProto(hContact); if (szProto) { for(int i = 0; i < g_ProtoPictures.getCount(); i++) { protoPicCacheEntry& p = g_ProtoPictures[i]; @@ -1818,7 +1818,7 @@ static void PicLoader(LPVOID param) if (result == -2) { - char *szProto = (char *) CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)node->ace.hContact, 0); + char *szProto = GetContactProto(node->ace.hContact); if (szProto == NULL || Proto_NeedDelaysForAvatars(szProto)) { QueueAdd(node->ace.hContact); @@ -2373,7 +2373,7 @@ static int OnDetailsInit(WPARAM wParam, LPARAM lParam) } else { - char *szProto = (char *) CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)hContact, 0); + char *szProto = GetContactProto(hContact); if (szProto == NULL || DBGetContactSettingByte(NULL, AVS_MODULE, szProto, 1)) { // Contact dialog diff --git a/plugins/AVS/src/options.cpp b/plugins/AVS/src/options.cpp index 54858c99c3..218a092e85 100644 --- a/plugins/AVS/src/options.cpp +++ b/plugins/AVS/src/options.cpp @@ -437,7 +437,7 @@ INT_PTR CALLBACK DlgProcOptionsProtos(HWND hwndDlg, UINT msg, WPARAM wParam, LPA HANDLE hContact = db_find_first(); while (hContact != NULL) { - char* szContactProto = (char*) CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM) hContact, 0); + char* szContactProto = GetContactProto(hContact); if (szContactProto != NULL && !strcmp(szContactProto, szProto)) DeleteAvatarFromCache(hContact, TRUE); @@ -613,7 +613,7 @@ INT_PTR CALLBACK DlgProcAvatarOptions(HWND hwndDlg, UINT msg, WPARAM wParam, LPA case IDC_RESET: { - char *szProto = ( char* )CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)hContact, 0); + char *szProto = GetContactProto(hContact); DBVARIANT dbv = {0}; ProtectAvatar((WPARAM)hContact, 0); @@ -844,7 +844,7 @@ INT_PTR CALLBACK DlgProcAvatarUserInfo(HWND hwndDlg, UINT msg, WPARAM wParam, LP } case IDC_RESET: { - char *szProto = ( char* )CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)hContact, 0); + char *szProto = GetContactProto(hContact); DBVARIANT dbv = {0}; ProtectAvatar((WPARAM)hContact, 0); diff --git a/plugins/AVS/src/poll.cpp b/plugins/AVS/src/poll.cpp index d93ef5309c..3fb4263497 100644 --- a/plugins/AVS/src/poll.cpp +++ b/plugins/AVS/src/poll.cpp @@ -230,7 +230,7 @@ int FetchAvatarFor(HANDLE hContact, char *szProto = NULL) int result = GAIR_NOAVATAR; if (szProto == NULL) - szProto = (char *)CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)hContact, 0); + szProto = GetContactProto(hContact); if (szProto != NULL && PollProtocolCanHaveAvatar(szProto) && PollContactCanHaveAvatar(hContact, szProto)) { diff --git a/plugins/AuthState/src/main.cpp b/plugins/AuthState/src/main.cpp index 0917db41fb..b65de865f4 100644 --- a/plugins/AuthState/src/main.cpp +++ b/plugins/AuthState/src/main.cpp @@ -69,7 +69,7 @@ extern "C" __declspec(dllexport) PLUGININFOEX* MirandaPluginInfoEx(DWORD miranda INT_PTR getIconToUse(HANDLE hContact, LPARAM lParam) { - char *proto = (char *)CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)hContact, 0); + char *proto = GetContactProto(hContact); // if (lParam == 1) return icon_none; if (!DBGetContactSettingByte(hContact,"AuthState","ShowIcons",!bIconsForRecentContacts)) return icon_none; @@ -112,7 +112,7 @@ int onExtraImageApplying(WPARAM wParam, LPARAM lParam) int onContactSettingChanged(WPARAM wParam,LPARAM lParam) { DBCONTACTWRITESETTING *cws=(DBCONTACTWRITESETTING*)lParam; - char *proto = (char *)CallService(MS_PROTO_GETCONTACTBASEPROTO, wParam, 0); + char *proto = GetContactProto((HANDLE)wParam); if (!proto) return 0; if (!lstrcmpA(cws->szModule,proto)) @@ -142,7 +142,7 @@ INT_PTR onAuthMenuSelected(WPARAM wParam, LPARAM lParam) int onPrebuildContactMenu(WPARAM wParam, LPARAM lParam) { - char *proto = (char *)CallService(MS_PROTO_GETCONTACTBASEPROTO, wParam, 0); + char *proto = GetContactProto((HANDLE)wParam); if (!proto) return 0; CLISTMENUITEM mi = {0}; diff --git a/plugins/AutoShutdown/src/watcher.cpp b/plugins/AutoShutdown/src/watcher.cpp index 99c3d524c5..0162ca5867 100644 --- a/plugins/AutoShutdown/src/watcher.cpp +++ b/plugins/AutoShutdown/src/watcher.cpp @@ -177,13 +177,11 @@ static int IdleChanged(WPARAM wParam,LPARAM lParam) static BOOL CheckAllContactsOffline(void) { BOOL fSmartCheck,fAllOffline=TRUE; /* tentatively */ - HANDLE hContact; - char *pszProto; fSmartCheck=DBGetContactSettingByte(NULL,"AutoShutdown","SmartOfflineCheck",SETTING_SMARTOFFLINECHECK_DEFAULT); - hContact=db_find_first(); - while(hContact!=NULL) { - pszProto=(char*)CallService(MS_PROTO_GETCONTACTBASEPROTO,(WPARAM)hContact,0); - if(pszProto!=NULL && CallProtoService(pszProto,PS_GETSTATUS,0,0)!=ID_STATUS_OFFLINE) + HANDLE hContact = db_find_first(); + while(hContact != NULL) { + char *pszProto = GetContactProto(hContact); + if(pszProto != NULL && CallProtoService(pszProto,PS_GETSTATUS,0,0)!=ID_STATUS_OFFLINE) if(DBGetContactSettingByte(hContact,pszProto,"ChatRoom",0)) continue; if(DBGetContactSettingWord(hContact,pszProto,"Status",0)!=ID_STATUS_OFFLINE) { if(fSmartCheck) { @@ -203,7 +201,7 @@ static int StatusSettingChanged(WPARAM wParam,LPARAM lParam) if(currentWatcherType&SDWTF_STATUS) { DBCONTACTWRITESETTING *dbcws=(DBCONTACTWRITESETTING*)lParam; if((HANDLE)wParam!=NULL && dbcws->value.wVal==ID_STATUS_OFFLINE && !lstrcmpA(dbcws->szSetting,"Status")) { - char *pszProto=(char*)CallService(MS_PROTO_GETCONTACTBASEPROTO,wParam,0); + char *pszProto = GetContactProto((HANDLE)wParam); if(pszProto!=NULL && !lstrcmpA(dbcws->szModule,pszProto)) if(CheckAllContactsOffline()) ShutdownAndStopWatcher(); @@ -239,7 +237,7 @@ static BOOL CALLBACK CpuUsageWatcherProc(BYTE nCpuUsage,LPARAM lParam) static int WeatherUpdated(WPARAM wParam,LPARAM lParam) { - char *pszProto=(char*)CallService(MS_PROTO_GETCONTACTBASEPROTO,wParam,0); + char *pszProto = GetContactProto((HANDLE)wParam); if((BOOL)lParam && pszProto!=NULL && CallProtoService(pszProto,PS_GETSTATUS,0,0)==THUNDER) if(DBGetContactSettingByte(NULL,"AutoShutdown","WeatherShutdown",SETTING_WEATHERSHUTDOWN_DEFAULT)) ServiceShutdown(SDSDT_SHUTDOWN,TRUE); diff --git a/plugins/AvatarHistory/src/AvatarDlg.cpp b/plugins/AvatarHistory/src/AvatarDlg.cpp index efdb07610a..f499fcb8ee 100644 --- a/plugins/AvatarHistory/src/AvatarDlg.cpp +++ b/plugins/AvatarHistory/src/AvatarDlg.cpp @@ -530,7 +530,7 @@ int PreBuildContactMenu(WPARAM wParam,LPARAM lParam) clmi.cbSize = sizeof(clmi); clmi.flags = CMIM_FLAGS; - char *proto = (char*) CallService(MS_PROTO_GETCONTACTBASEPROTO, wParam, 0); + char *proto = GetContactProto((HANDLE)wParam); if (!ProtocolEnabled(proto)) clmi.flags |= CMIF_HIDDEN; diff --git a/plugins/AvatarHistory/src/AvatarHistory.cpp b/plugins/AvatarHistory/src/AvatarHistory.cpp index 0cd94a15f2..68fed732d0 100644 --- a/plugins/AvatarHistory/src/AvatarHistory.cpp +++ b/plugins/AvatarHistory/src/AvatarHistory.cpp @@ -253,7 +253,7 @@ BOOL ContactEnabled(HANDLE hContact, char *setting, int def) if (hContact == NULL) return FALSE; - char *proto = (char *) CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM) hContact, 0); + char *proto = GetContactProto(hContact); if (!ProtocolEnabled(proto)) return FALSE; @@ -403,7 +403,7 @@ static int AvatarChanged(WPARAM wParam, LPARAM lParam) return 0; } - char *proto = (char *) CallService(MS_PROTO_GETCONTACTBASEPROTO, wParam, 0); + char *proto = GetContactProto((HANDLE)wParam); if (proto == NULL) { ShowDebugPopup(hContact, _T("AVH Debug"), _T("Invalid protocol... skipping")); @@ -545,7 +545,7 @@ static int AvatarChanged(WPARAM wParam, LPARAM lParam) { DBEVENTINFO AvatarEvent = { 0 }; AvatarEvent.cbSize = sizeof(AvatarEvent); - AvatarEvent.szModule = (char*)CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)hContact, 0); + AvatarEvent.szModule = GetContactProto(hContact); AvatarEvent.flags = flags; AvatarEvent.timestamp = (DWORD) time(NULL); AvatarEvent.eventType = EVENTTYPE_AVATAR_CHANGE; @@ -698,7 +698,7 @@ TCHAR * GetContactFolder(TCHAR *fn, HANDLE hContact) { TCHAR uin[MAX_PATH]; - char *proto = (char *) CallService(MS_PROTO_GETCONTACTBASEPROTO,(WPARAM) hContact, 0); + char *proto = GetContactProto(hContact); GetProtocolFolder(fn, proto); GetUIDFromHContact(hContact, uin, MAX_REGS(uin)); diff --git a/plugins/AvatarHistory/src/icolib.cpp b/plugins/AvatarHistory/src/icolib.cpp index 76bc96d80c..acc5d642c3 100644 --- a/plugins/AvatarHistory/src/icolib.cpp +++ b/plugins/AvatarHistory/src/icolib.cpp @@ -123,7 +123,7 @@ HICON createProtoOverlayedIcon(HANDLE hContact) { HICON icon1 = LoadIconEx(I_OVERLAY); - char *szProto = (char *)CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)hContact, 0); + char *szProto = GetContactProto(hContact); HICON icon0 = LoadSkinnedProtoIcon(szProto, ID_STATUS_ONLINE); HICON resIcon = getOverlayedIcon(icon0, icon1, FALSE); diff --git a/plugins/BasicHistory/src/DatExport.cpp b/plugins/BasicHistory/src/DatExport.cpp index 0a40abd39d..06ec796904 100644 --- a/plugins/BasicHistory/src/DatExport.cpp +++ b/plugins/BasicHistory/src/DatExport.cpp @@ -156,7 +156,7 @@ bool DatExport::GetEventList(std::vector& eventList) DBEVENTINFO86 messageHeader; DBEVENTINFO info = {0}; info.cbSize = sizeof(DBEVENTINFO); - info.szModule = (char *)CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)hContact, 0); + info.szModule = GetContactProto(hContact); TCHAR _str[MAXSELECTSTR + 8]; // for safety reason std::multimap sortedEvents; while(dataSize > 0) diff --git a/plugins/BasicHistory/src/EventList.cpp b/plugins/BasicHistory/src/EventList.cpp index e6bf5ef0d3..930f8827bc 100644 --- a/plugins/BasicHistory/src/EventList.cpp +++ b/plugins/BasicHistory/src/EventList.cpp @@ -507,7 +507,7 @@ std::wstring EventList::GetMyName() CONTACTINFO ci; ZeroMemory(&ci, sizeof(ci)); ci.cbSize = sizeof(ci); - ci.szProto = (char *)CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)hContact, 0); + ci.szProto = GetContactProto(hContact); ci.hContact = 0; ci.dwFlag = CNF_DISPLAY | CNF_TCHAR; GetInfo(ci, myName); @@ -544,7 +544,7 @@ std::wstring EventList::GetProtocolName() std::string EventList::GetBaseProtocol() { - char* proto = (char *)CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)hContact, 0); + char* proto = GetContactProto(hContact); return proto == NULL ? "" : proto; } @@ -554,7 +554,7 @@ std::wstring EventList::GetMyId() CONTACTINFO ci; ZeroMemory(&ci, sizeof(ci)); ci.cbSize = sizeof(ci); - ci.szProto = (char *)CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)hContact, 0); + ci.szProto = GetContactProto(hContact); ci.hContact = 0; ci.dwFlag = CNF_DISPLAYUID | CNF_TCHAR; GetInfo(ci, myId); @@ -567,7 +567,7 @@ inline std::wstring GetContactId(HANDLE hContact) CONTACTINFO ci; ZeroMemory(&ci, sizeof(ci)); ci.cbSize = sizeof(ci); - ci.szProto = (char *)CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)hContact, 0); + ci.szProto = GetContactProto(hContact); ci.hContact = hContact; ci.dwFlag = CNF_DISPLAYUID | CNF_TCHAR; GetInfo(ci, id); @@ -723,7 +723,7 @@ void EventList::MargeMessages(const std::vector& messa GetTempList(tempList, true, false, hContact); DBEVENTINFO dbei = {0}; dbei.cbSize = sizeof(DBEVENTINFO); - dbei.szModule = (char *)CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)hContact, 0); + dbei.szModule = GetContactProto(hContact); CallService(MS_DB_SETSAFETYMODE, (WPARAM)FALSE, 0); for(std::list::iterator it = tempList.begin(); it != tempList.end(); ++it) { diff --git a/plugins/BasicHistory/src/HistoryWindow.cpp b/plugins/BasicHistory/src/HistoryWindow.cpp index 844dedc14c..dfde02eb0b 100644 --- a/plugins/BasicHistory/src/HistoryWindow.cpp +++ b/plugins/BasicHistory/src/HistoryWindow.cpp @@ -1516,7 +1516,7 @@ void HistoryWindow::ReplaceIcons(HWND hwndDlg, int selStart, BOOL isSent) smadd.cbSize = sizeof(smadd); smadd.hwndRichEditControl = hwndDlg; - smadd.Protocolname = (char *)CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)hContact, 0); + smadd.Protocolname = GetContactProto(hContact); smadd.hContact = hContact; smadd.flags = isSent ? SAFLRE_OUTGOING : 0; if (selStart > 0) diff --git a/plugins/Boltun/src/actionQueue.cpp b/plugins/Boltun/src/actionQueue.cpp index c464c92f39..d0ba9adae8 100644 --- a/plugins/Boltun/src/actionQueue.cpp +++ b/plugins/Boltun/src/actionQueue.cpp @@ -97,7 +97,7 @@ static char *MsgServiceName(HANDLE hContact) { char szServiceName[100]; - char *szProto = (char *) CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM) hContact, 0); + char *szProto = GetContactProto(hContact); if (szProto == NULL) return PSS_MESSAGE; diff --git a/plugins/BuddyExpectator/src/BuddyExpectator.cpp b/plugins/BuddyExpectator/src/BuddyExpectator.cpp index b0798c59a4..e89114cb97 100644 --- a/plugins/BuddyExpectator/src/BuddyExpectator.cpp +++ b/plugins/BuddyExpectator/src/BuddyExpectator.cpp @@ -251,7 +251,7 @@ bool isContactGoneFor(HANDLE hContact, int days) ppd.lchContact = hContact; ppd.lchIcon = Skin_GetIcon("enabled_icon"); - mir_sntprintf(szInfo, 200, TranslateT("Hiding %s (%S)"), (TCHAR*)CallService(MS_CLIST_GETCONTACTDISPLAYNAME,(WPARAM)hContact,GCDNF_TCHAR), (char *)CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)hContact, 0)); + mir_sntprintf(szInfo, 200, TranslateT("Hiding %s (%S)"), (TCHAR*)CallService(MS_CLIST_GETCONTACTDISPLAYNAME,(WPARAM)hContact,GCDNF_TCHAR), GetContactProto(hContact)); _tcsncpy(ppd.lptzContactName, szInfo, MAX_CONTACTNAME); mir_sntprintf(szInfo, 200, TranslateT("%d days since last message"), daysSinceMessage); _tcsncpy(ppd.lptzText, szInfo, MAX_SECONDLINE); @@ -465,7 +465,7 @@ INT_PTR MenuMissYouClick(WPARAM wParam, LPARAM lParam) */ int onPrebuildContactMenu(WPARAM wParam, LPARAM lParam) { - char *proto = (char *)CallService(MS_PROTO_GETCONTACTBASEPROTO, wParam, 0); + char *proto = GetContactProto((HANDLE)wParam); if (!proto) return 0; CLISTMENUITEM mi = {0}; @@ -516,7 +516,7 @@ int SettingChanged(WPARAM wParam, LPARAM lParam) if (db_get_b(hContact, "CList", "NotOnList", 0) == 1) return 0; - char *proto = (char *)CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)hContact, 0); + char *proto = GetContactProto(hContact); if (proto == 0 || (db_get_b(hContact, proto, "ChatRoom", 0) == 1) || !(CallProtoService(proto, PS_GETCAPS, PFLAGNUM_1, 0) & PF1_IMSEND)) return 0; @@ -612,7 +612,7 @@ void CALLBACK TimerProc(HWND, UINT, UINT_PTR, DWORD) char *proto; while (hContact != 0) { - proto = (char *)CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)hContact, 0); + proto = GetContactProto(hContact); if (proto && (db_get_b(hContact, proto, "ChatRoom", 0) == 0) && (CallProtoService(proto, PS_GETCAPS, PFLAGNUM_1, 0) & PF1_IMSEND) && isContactGoneFor(hContact, options.iAbsencePeriod2) && (db_get_b(hContact, MODULE_NAME, "StillAbsentNotified", 0) == 0)) { db_set_b(hContact, MODULE_NAME, "StillAbsentNotified", 1); diff --git a/plugins/ClientChangeNotify/src/ClientChangeNotify.cpp b/plugins/ClientChangeNotify/src/ClientChangeNotify.cpp index e5110ed332..b3b5b05dae 100644 --- a/plugins/ClientChangeNotify/src/ClientChangeNotify.cpp +++ b/plugins/ClientChangeNotify/src/ClientChangeNotify.cpp @@ -178,7 +178,7 @@ void ShowPopup(SHOWPOPUP_DATA *sd) PLUGIN_DATA *pdata = (PLUGIN_DATA*)calloc(1, sizeof(PLUGIN_DATA)); POPUPDATAT ppd = {0}; ppd.lchContact = sd->hContact; - char *szProto = (char*)CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)sd->hContact, 0); + char *szProto = GetContactProto(sd->hContact); pdata->hIcon = ppd.lchIcon = (HICON)CallService(MS_FP_GETCLIENTICON, (WPARAM)(const char*)TCHAR2ANSI(sd->MirVer), false); _ASSERT(ppd.lchIcon); if (!ppd.lchIcon || (DWORD)ppd.lchIcon == CALLSERVICE_NOTFOUND) { @@ -211,7 +211,7 @@ int ContactSettingChanged(WPARAM wParam, LPARAM lParam) if (!hContact) // exit if hContact == NULL and it's not a popup preview return 0; - szProto = (char*)CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)hContact, 0); + szProto = GetContactProto(hContact); _ASSERT(szProto); if (ServiceExists(MS_MC_GETPROTOCOLNAME) && !strcmp(szProto, (char*)CallService(MS_MC_GETPROTOCOLNAME, 0, 0))) // workaround for metacontacts return 0; @@ -301,7 +301,7 @@ int ContactSettingChanged(WPARAM wParam, LPARAM lParam) static int ContactSettingsInit(WPARAM wParam, LPARAM lParam) { CONTACTSETTINGSINIT *csi = (CONTACTSETTINGSINIT*)wParam; - char *szProto = (csi->Type == CSIT_CONTACT) ? (char*)CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)csi->hContact, 0) : NULL; + char *szProto = (csi->Type == CSIT_CONTACT) ? GetContactProto(csi->hContact) : NULL; if ((csi->Type == CSIT_GROUP) || (szProto && csi->Type == CSIT_CONTACT)) { int Flag1 = (csi->Type == CSIT_CONTACT) ? CallProtoService(szProto, PS_GETCAPS, PFLAGNUM_1, 0) : PF1_IM; // if it's a group settings dialog, we assume that there are possibly some contacts in the group with PF1_IM capability if (Flag1 & (PF1_IMRECV | PF1_URLRECV | PF1_FILERECV)) { // I hope, these flags are sufficient to describe which protocols can theoretically have a client diff --git a/plugins/Clist_modern/src/modern_awaymsg.cpp b/plugins/Clist_modern/src/modern_awaymsg.cpp index 77e06dff5e..ddf27062dd 100644 --- a/plugins/Clist_modern/src/modern_awaymsg.cpp +++ b/plugins/Clist_modern/src/modern_awaymsg.cpp @@ -208,7 +208,7 @@ void amRequestAwayMsg(HANDLE hContact) if ( !g_CluiData.bInternalAwayMsgDiscovery || !hContact) return; //Do not re-ask for chat rooms - szProto = (char *) CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM) hContact, 0); + szProto = GetContactProto(hContact); if (szProto == NULL || db_get_b(hContact, szProto, "ChatRoom", 0) != 0) return; amAddHandleToChain(hContact); diff --git a/plugins/Clist_modern/src/modern_cachefuncs.cpp b/plugins/Clist_modern/src/modern_cachefuncs.cpp index d6c7cf2338..6ff4f8fdec 100644 --- a/plugins/Clist_modern/src/modern_cachefuncs.cpp +++ b/plugins/Clist_modern/src/modern_cachefuncs.cpp @@ -209,7 +209,7 @@ void CSmileyString::ReplaceSmileys(struct SHORTDATA *dat, ClcCacheEntry *pdnce, if (db_get_b(NULL,"CLC","Meta",SETTING_USEMETAICON_DEFAULT) != 1 && pdnce->m_cache_cszProto != NULL && g_szMetaModuleName && strcmp(pdnce->m_cache_cszProto, g_szMetaModuleName) == 0) { HANDLE hContact = (HANDLE)CallService(MS_MC_GETMOSTONLINECONTACT, (LPARAM)pdnce->hContact, 0); if (hContact != 0) - sp.Protocolname = (char*)CallService(MS_PROTO_GETCONTACTBASEPROTO, (LPARAM)hContact, 0); + sp.Protocolname = GetContactProto(hContact); } } else sp.Protocolname = "clist"; diff --git a/plugins/Clist_modern/src/modern_clc.cpp b/plugins/Clist_modern/src/modern_clc.cpp index e2b3aea184..054d69648d 100644 --- a/plugins/Clist_modern/src/modern_clc.cpp +++ b/plugins/Clist_modern/src/modern_clc.cpp @@ -1550,7 +1550,7 @@ static LRESULT clcOnIntmIconChanged(ClcData *dat, HWND hwnd, UINT msg, WPARAM wP HANDLE hSelItem = NULL; ClcContact *selcontact = NULL; - char *szProto = (char *) CallService(MS_PROTO_GETCONTACTBASEPROTO, wParam, 0); + char *szProto = GetContactProto((HANDLE)wParam); if (szProto == NULL) status = ID_STATUS_OFFLINE; else diff --git a/plugins/Clist_modern/src/modern_clcitems.cpp b/plugins/Clist_modern/src/modern_clcitems.cpp index 9a27760bea..dd155e74bb 100644 --- a/plugins/Clist_modern/src/modern_clcitems.cpp +++ b/plugins/Clist_modern/src/modern_clcitems.cpp @@ -718,7 +718,7 @@ int __fastcall CLVM_GetContactHiddenStatus(HANDLE hContact, char *szProto, ClcDa } if (pdnce && g_CluiData.bFilterEffective && !fEmbedded) { if (szProto == NULL) - szProto = (char *)CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)hContact, 0); + szProto = GetContactProto(hContact); // check stickies first (priority), only if we really have stickies defined (CLVM_STICKY_CONTACTS is set). if (g_CluiData.bFilterEffective & CLVM_STICKY_CONTACTS) { if ((dwLocalMask = db_get_dw(hContact, CLVM_MODULE, g_CluiData.current_viewmode, 0)) != 0) { diff --git a/plugins/Clist_modern/src/modern_clistevents.cpp b/plugins/Clist_modern/src/modern_clistevents.cpp index 7745330956..f15f7f0045 100644 --- a/plugins/Clist_modern/src/modern_clistevents.cpp +++ b/plugins/Clist_modern/src/modern_clistevents.cpp @@ -126,7 +126,7 @@ struct CListEvent* cli_AddEvent(CLISTEVENT *cle) return p; } } } - szProto = (char*) CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM) p->cle.hContact, 0); + szProto = GetContactProto(p->cle.hContact); szName = pcli->pfnGetContactDisplayName(p->cle.hContact, 0); if (szProto && szName) { nmi = (struct NotifyMenuItemExData *) malloc(sizeof(struct NotifyMenuItemExData)); diff --git a/plugins/Clist_modern/src/modern_clistmod.cpp b/plugins/Clist_modern/src/modern_clistmod.cpp index eef6c834ca..2adc55d19e 100644 --- a/plugins/Clist_modern/src/modern_clistmod.cpp +++ b/plugins/Clist_modern/src/modern_clistmod.cpp @@ -166,7 +166,7 @@ int GetContactIconC(ClcCacheEntry *cacheEntry) INT_PTR GetContactIcon(WPARAM wParam,LPARAM lParam) { int status; - char *szProto = (char *) CallService(MS_PROTO_GETCONTACTBASEPROTO, wParam, 0); + char *szProto = GetContactProto((HANDLE)wParam); if (szProto == NULL) status = ID_STATUS_OFFLINE; else diff --git a/plugins/Clist_modern/src/modern_clistsettings.cpp b/plugins/Clist_modern/src/modern_clistsettings.cpp index 484ba96b29..badfa95153 100644 --- a/plugins/Clist_modern/src/modern_clistsettings.cpp +++ b/plugins/Clist_modern/src/modern_clistsettings.cpp @@ -499,7 +499,7 @@ int ContactSettingChanged(WPARAM wParam,LPARAM lParam) else if ( !strcmp(cws->szSetting,"Hidden")) { InvalidateDNCEbyPointer(hContact,pdnce,cws->value.type); if (cws->value.type == DBVT_DELETED || cws->value.bVal == 0) { - char *szProto = (char*)CallService(MS_PROTO_GETCONTACTBASEPROTO,wParam,0); + char *szProto = GetContactProto((HANDLE)wParam); cli_ChangeContactIcon(hContact,ExtIconFromStatusMode(hContact,szProto,szProto == NULL?ID_STATUS_OFFLINE:db_get_w(hContact,szProto,"Status",ID_STATUS_OFFLINE)),1); //by FYR } pcli->pfnClcBroadcast(CLM_AUTOREBUILD,0, 0); diff --git a/plugins/Clist_modern/src/modern_contact.cpp b/plugins/Clist_modern/src/modern_contact.cpp index 4f1de747b5..74ee963705 100644 --- a/plugins/Clist_modern/src/modern_contact.cpp +++ b/plugins/Clist_modern/src/modern_contact.cpp @@ -179,7 +179,7 @@ INT_PTR ContactChangeGroup(WPARAM wParam,LPARAM lParam) db_unset((HANDLE)wParam,"CList","Group"); else db_set_ws((HANDLE)wParam,"CList","Group",pcli->pfnGetGroupName(lParam, NULL)); - CallService(MS_CLUI_CONTACTADDED,wParam,ExtIconFromStatusMode((HANDLE)wParam,(char*)CallService(MS_PROTO_GETCONTACTBASEPROTO,wParam,0),GetContactStatus((HANDLE)wParam))); + CallService(MS_CLUI_CONTACTADDED,wParam,ExtIconFromStatusMode((HANDLE)wParam,GetContactProto((HANDLE)wParam),GetContactStatus((HANDLE)wParam))); return 0; } diff --git a/plugins/Clist_mw/src/clistmod.cpp b/plugins/Clist_mw/src/clistmod.cpp index edf5ca68cd..dda20b767f 100644 --- a/plugins/Clist_mw/src/clistmod.cpp +++ b/plugins/Clist_mw/src/clistmod.cpp @@ -85,7 +85,7 @@ int ExtIconFromStatusMode(HANDLE hContact, const char *szProto,int status) if (strcmp(szProto,"MetaContacts") == 0 ) { hContact = (HANDLE)CallService(MS_MC_GETMOSTONLINECONTACT,(UINT)hContact,0); if ( hContact != 0 ) { - szProto = (char*)CallService(MS_PROTO_GETCONTACTBASEPROTO,(UINT)hContact,0); + szProto = GetContactProto((UINT)hContact,0); status = db_get_w(hContact,szProto,"Status",ID_STATUS_OFFLINE); } } diff --git a/plugins/Clist_mw/src/clistsettings.cpp b/plugins/Clist_mw/src/clistsettings.cpp index fb0c14e989..c0dd11b077 100644 --- a/plugins/Clist_mw/src/clistsettings.cpp +++ b/plugins/Clist_mw/src/clistsettings.cpp @@ -330,7 +330,7 @@ int ContactSettingChanged(WPARAM wParam,LPARAM lParam) if ( !strcmp(cws->szSetting,"Hidden")) { InvalidateDisplayNameCacheEntryByPDNE(hContact,pdnce,cws->value.type); if (cws->value.type == DBVT_DELETED || cws->value.bVal == 0) { - char *szProto = (char*)CallService(MS_PROTO_GETCONTACTBASEPROTO,wParam,0); + char *szProto = GetContactProto((HANDLE)wParam); ChangeContactIcon(hContact,ExtIconFromStatusMode(hContact, szProto, szProto == NULL ? ID_STATUS_OFFLINE : db_get_w(hContact, szProto, "Status", ID_STATUS_OFFLINE)), 1); //by FYR } } diff --git a/plugins/Clist_mw/src/contact.cpp b/plugins/Clist_mw/src/contact.cpp index 088e125d51..e6c4f31805 100644 --- a/plugins/Clist_mw/src/contact.cpp +++ b/plugins/Clist_mw/src/contact.cpp @@ -51,7 +51,7 @@ static int GetContactStatus(HANDLE hContact) char *szProto; - szProto = (char*)CallService(MS_PROTO_GETCONTACTBASEPROTO,(WPARAM)hContact,0); + szProto = GetContactProto(hContact,0); if (szProto == NULL) return ID_STATUS_OFFLINE; return db_get_w(hContact,szProto,"Status",ID_STATUS_OFFLINE); */ @@ -181,6 +181,7 @@ INT_PTR ContactChangeGroup(WPARAM wParam,LPARAM lParam) DBDeleteContactSetting((HANDLE)wParam,"CList","Group"); else db_set_s((HANDLE)wParam,"CList","Group",(char*)CallService(MS_CLIST_GROUPGETNAME2,lParam,(LPARAM)(int*)NULL)); - CallService(MS_CLUI_CONTACTADDED,wParam,ExtIconFromStatusMode((HANDLE)wParam,(char*)CallService(MS_PROTO_GETCONTACTBASEPROTO,wParam,0),GetContactStatus((HANDLE)wParam))); + + CallService(MS_CLUI_CONTACTADDED,wParam,ExtIconFromStatusMode((HANDLE)wParam, GetContactProto((HANDLE)wParam), GetContactStatus((HANDLE)wParam))); return 0; } diff --git a/plugins/Clist_nicer/src/clc.cpp b/plugins/Clist_nicer/src/clc.cpp index 07838053c1..6d80e49cfd 100644 --- a/plugins/Clist_nicer/src/clc.cpp +++ b/plugins/Clist_nicer/src/clc.cpp @@ -125,7 +125,7 @@ static int ClcSettingChanged(WPARAM wParam, LPARAM lParam) else if ( !__strcmp(cws->szSetting, "Timezone") || !__strcmp(cws->szSetting, "TzName")) ReloadExtraInfo((HANDLE)wParam); } - else if (wParam != 0 && (szProto = (char *)CallService(MS_PROTO_GETCONTACTBASEPROTO, wParam, 0)) != NULL) { + else if (wParam != 0 && (szProto = GetContactProto((HANDLE)wParam)) != NULL) { char *id = NULL; if ( !__strcmp(cws->szModule, "Protocol") && !__strcmp(cws->szSetting, "p")) { char *szProto_s; @@ -352,7 +352,7 @@ LBL_Def: HANDLE hSelItem = NULL; ClcContact *selcontact = NULL; - char *szProto = (char*) CallService(MS_PROTO_GETCONTACTBASEPROTO, wParam, 0); + char *szProto = GetContactProto((HANDLE)wParam); if (szProto == NULL) status = ID_STATUS_OFFLINE; else @@ -412,7 +412,7 @@ LBL_Def: if (contact->bIsMeta && cfg::dat.bMetaAvail && !(cfg::dat.dwFlags & CLUI_USEMETAICONS)) { contact->hSubContact = (HANDLE) CallService(MS_MC_GETMOSTONLINECONTACT, (WPARAM) contact->hContact, 0); - contact->metaProto = (char*) CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM) contact->hSubContact, 0); + contact->metaProto = GetContactProto(contact->hSubContact); contact->iImage = CallService(MS_CLIST_GETCONTACTICON, (WPARAM) contact->hSubContact, 0); if (contact->extraCacheEntry >= 0 && contact->extraCacheEntry < cfg::nextCacheEntry) { int subIndex = cfg::getCache(contact->hSubContact, contact->metaProto); @@ -523,7 +523,7 @@ LBL_Def: if ( !FindItem(hwnd, dat, (HANDLE)wParam, &contact, NULL, NULL)) break; - contact->proto = (char*) CallService(MS_PROTO_GETCONTACTBASEPROTO, wParam, 0); + contact->proto = GetContactProto((HANDLE)wParam); CallService(MS_CLIST_INVALIDATEDISPLAYNAME, wParam, 0); lstrcpyn(contact->szText, pcli->pfnGetContactDisplayName((HANDLE)wParam, 0), safe_sizeof(contact->szText)); diff --git a/plugins/Clist_nicer/src/clcitems.cpp b/plugins/Clist_nicer/src/clcitems.cpp index 160bc97112..37135af5ce 100644 --- a/plugins/Clist_nicer/src/clcitems.cpp +++ b/plugins/Clist_nicer/src/clcitems.cpp @@ -127,7 +127,7 @@ int AddContactToGroup(struct ClcData *dat, ClcGroup *group, HANDLE hContact) p->bIsMeta = FALSE; if (p->bIsMeta && cfg::dat.bMetaAvail && !(cfg::dat.dwFlags & CLUI_USEMETAICONS)) { p->hSubContact = (HANDLE) CallService(MS_MC_GETMOSTONLINECONTACT, (WPARAM) hContact, 0); - p->metaProto = (char*) CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM) p->hSubContact, 0); + p->metaProto = GetContactProto(p->hSubContact); p->iImage = CallService(MS_CLIST_GETCONTACTICON, (WPARAM) p->hSubContact, 0); } else { @@ -206,7 +206,7 @@ void RebuildEntireList(HWND hwnd, struct ClcData *dat) if (group != NULL) { group->totalMembers++; if ( !(style & CLS_NOHIDEOFFLINE) && (style & CLS_HIDEOFFLINE || group->hideOffline)) { - char *szProto = (char*) CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM) hContact, 0); + char *szProto = GetContactProto(hContact); if (szProto == NULL) { if ( !pcli->pfnIsHiddenMode(dat, ID_STATUS_OFFLINE)) AddContactToGroup(dat, group, hContact); @@ -271,7 +271,7 @@ BYTE GetCachedStatusMsg(int iExtraCacheEntry, char *szProto) cEntry->bStatusMsgValid = STATUSMSG_CLIST; else { if ( !szProto) - szProto = (char *)CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)hContact, 0); + szProto = GetContactProto(hContact); if (szProto) { if ( !result ) DBFreeVariant( &dbv ); @@ -374,7 +374,7 @@ void ReloadExtraInfo(HANDLE hContact) if (hContact && pcli->hwndContactTree) { int index = cfg::getCache(hContact, NULL); if (index >= 0 && index < cfg::nextCacheEntry) { - char *szProto = (char *)CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)hContact, 0); + char *szProto = GetContactProto(hContact); TZ_LoadTimeZone(hContact, &cfg::eCache[index], szProto); InvalidateRect(pcli->hwndContactTree, NULL, FALSE); @@ -501,7 +501,7 @@ void LoadSkinItemToCache(struct TExtraCache *cEntry, const char *szProto) void ReloadSkinItemsToCache() { for (int i = 0; i < cfg::nextCacheEntry; i++) { - char *szProto = (char *)CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)cfg::eCache[i].hContact, 0); + char *szProto = GetContactProto(cfg::eCache[i].hContact); if (szProto) LoadSkinItemToCache(&cfg::eCache[i], szProto); } @@ -531,7 +531,7 @@ int __fastcall CLVM_GetContactHiddenStatus(HANDLE hContact, char *szProto, struc return dbHidden; if (szProto == NULL) - szProto = (char *)CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)hContact, 0); + szProto = GetContactProto(hContact); // check stickies first (priority), only if we really have stickies defined (CLVM_STICKY_CONTACTS is set). if (cfg::dat.bFilterEffective & CLVM_STICKY_CONTACTS) { if ((dwLocalMask = cfg::getDword(hContact, "CLVM", cfg::dat.current_viewmode, 0)) != 0) { diff --git a/plugins/Clist_nicer/src/clistevents.cpp b/plugins/Clist_nicer/src/clistevents.cpp index 277eb29db1..12449d3adb 100644 --- a/plugins/Clist_nicer/src/clistevents.cpp +++ b/plugins/Clist_nicer/src/clistevents.cpp @@ -276,7 +276,7 @@ struct CListEvent* AddEvent(CLISTEVENT *cle) return p; } } } - szProto = (char*) CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM) p->cle.hContact, 0); + szProto = GetContactProto(p->cle.hContact); szName = pcli->pfnGetContactDisplayName(p->cle.hContact, 0); if (szProto && szName) { nmi = (struct NotifyMenuItemExData *) malloc(sizeof(struct NotifyMenuItemExData)); diff --git a/plugins/Clist_nicer/src/clistmenus.cpp b/plugins/Clist_nicer/src/clistmenus.cpp index 801fc644ba..fdd5c3e9f2 100644 --- a/plugins/Clist_nicer/src/clistmenus.cpp +++ b/plugins/Clist_nicer/src/clistmenus.cpp @@ -124,7 +124,7 @@ static INT_PTR CALLBACK IgnoreDialogProc(HWND hWnd, UINT msg, WPARAM wParam, LPA SetWindowText(hWnd, szTitle); SendMessage(hWnd, WM_SETICON, ICON_BIG, (LPARAM)LoadSkinnedIcon(SKINICON_OTHER_MIRANDA)); - pCaps = CallProtoService(contact ? contact->proto : (char *)CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)hContact, 0), PS_GETCAPS, PFLAGNUM_1, 0); + pCaps = CallProtoService(contact ? contact->proto : GetContactProto(hContact), PS_GETCAPS, PFLAGNUM_1, 0); Utils::enableDlgControl(hWnd, IDC_IGN_ALWAYSONLINE, pCaps & PF1_INVISLIST ? TRUE : FALSE); Utils::enableDlgControl(hWnd, IDC_IGN_ALWAYSOFFLINE, pCaps & PF1_VISLIST ? TRUE : FALSE); CheckDlgButton(hWnd, IDC_IGN_PRIORITY, cfg::getByte(hContact, "CList", "Priority", 0) ? 1 : 0); diff --git a/plugins/Clist_nicer/src/clistmod.cpp b/plugins/Clist_nicer/src/clistmod.cpp index 9065d52d9e..c6f619f010 100644 --- a/plugins/Clist_nicer/src/clistmod.cpp +++ b/plugins/Clist_nicer/src/clistmod.cpp @@ -64,7 +64,7 @@ int IconFromStatusMode(const char *szProto, int status, HANDLE hContact, HICON * if (szProto != NULL && !strcmp(szProto, cfg::dat.szMetaName) && cfg::dat.bMetaAvail && hContact != 0 && !(cfg::dat.dwFlags & CLUI_USEMETAICONS)) { HANDLE hSubContact = (HANDLE) CallService(MS_MC_GETMOSTONLINECONTACT, (WPARAM) hContact, 0); - szFinalProto = (char*) CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM) hSubContact, 0); + szFinalProto = GetContactProto(hSubContact); finalStatus = (status == 0) ? (WORD) cfg::getWord(hSubContact, szFinalProto, "Status", ID_STATUS_OFFLINE) : status; } else { szFinalProto = (char*) szProto; diff --git a/plugins/Clist_nicer/src/clui.cpp b/plugins/Clist_nicer/src/clui.cpp index c283da5058..5f2059e0ea 100644 --- a/plugins/Clist_nicer/src/clui.cpp +++ b/plugins/Clist_nicer/src/clui.cpp @@ -476,7 +476,7 @@ void SetDBButtonStates(HANDLE hPassedContact) continue; } if (buttonItem->dwFlags & BUTTON_ISCONTACTDBACTION) - szModule = (char *)CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)hContact, 0); + szModule = GetContactProto(hContact); hFinalContact = hContact; } else hFinalContact = 0; @@ -1444,7 +1444,7 @@ skipbg: if (contactOK) { char szFinalService[512]; - mir_snprintf(szFinalService, 512, "%s/%s", (char *)CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)hContact, 0), item->szService); + mir_snprintf(szFinalService, 512, "%s/%s", GetContactProto(hContact), item->szService); if (ServiceExists(szFinalService)) CallService(szFinalService, wwParam, llParam); else @@ -1460,7 +1460,7 @@ skipbg: if (item->dwFlags & BUTTON_ISCONTACTDBACTION || item->dwFlags & BUTTON_DBACTIONONCONTACT) { contactOK = ServiceParamsOK(item, &wwParam, &llParam, hContact); if (contactOK && item->dwFlags & BUTTON_ISCONTACTDBACTION) - szModule = (char *)CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)hContact, 0); + szModule = GetContactProto(hContact); finalhContact = hContact; } else contactOK = 1; diff --git a/plugins/Clist_nicer/src/contact.cpp b/plugins/Clist_nicer/src/contact.cpp index 2d54120e8b..0bce13f2ae 100644 --- a/plugins/Clist_nicer/src/contact.cpp +++ b/plugins/Clist_nicer/src/contact.cpp @@ -51,7 +51,7 @@ static int GetContactStatus(HANDLE hContact) { char *szProto; - szProto = (char*) CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM) hContact, 0); + szProto = GetContactProto(hContact); if (szProto == NULL) return ID_STATUS_OFFLINE; return cfg::getWord(hContact, szProto, "Status", ID_STATUS_OFFLINE); @@ -161,7 +161,7 @@ void LoadContactTree(void) while (hContact != NULL) { status = GetContactStatus(hContact); if ((!hideOffline || status != ID_STATUS_OFFLINE) && !CLVM_GetContactHiddenStatus(hContact, NULL, NULL)) - pcli->pfnChangeContactIcon(hContact, IconFromStatusMode((char*) CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM) hContact, 0), status, hContact, NULL), 1); + pcli->pfnChangeContactIcon(hContact, IconFromStatusMode(GetContactProto(hContact), status, hContact, NULL), 1); if (mc_disablehgh && !mc_hgh_removed) { if ( !DBGetContactSetting(hContact, "CList", "Group", &dbv)) { diff --git a/plugins/Clist_nicer/src/extBackg.cpp b/plugins/Clist_nicer/src/extBackg.cpp index 29854db114..651995a52c 100644 --- a/plugins/Clist_nicer/src/extBackg.cpp +++ b/plugins/Clist_nicer/src/extBackg.cpp @@ -1327,7 +1327,7 @@ void LoadPerContactSkins(TCHAR *tszFileName) char UIN[40]; int j; - szProto = (char *)CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)hContact, 0); + szProto = GetContactProto(hContact); if (szProto) { uid = (char *)CallProtoService(szProto, PS_GETCAPS, PFLAG_UNIQUEIDSETTING, 0); if ((INT_PTR) uid != CALLSERVICE_NOTFOUND && uid != NULL) { diff --git a/plugins/CmdLine/src/mimcmd_handlers.cpp b/plugins/CmdLine/src/mimcmd_handlers.cpp index 061edf07b2..3e12950c61 100644 --- a/plugins/CmdLine/src/mimcmd_handlers.cpp +++ b/plugins/CmdLine/src/mimcmd_handlers.cpp @@ -1848,7 +1848,7 @@ void HandleContactsCommand(PCommand command, TArgument *argv, int argc, PReply r while (hContact) { - GetContactProtocol(hContact, protocol, sizeof(protocol)); + GetContactProto(hContact, protocol, sizeof(protocol)); char *contact = GetContactName(hContact, protocol); char *id = GetContactID(hContact, protocol); @@ -1894,7 +1894,7 @@ void HandleContactsCommand(PCommand command, TArgument *argv, int argc, PReply r *reply->message = 0; while (hContact) { - GetContactProtocol(hContact, protocol, sizeof(protocol)); + GetContactProto(hContact, protocol, sizeof(protocol)); char *contact = GetContactName(hContact, protocol); char *id = GetContactID(hContact, protocol); @@ -2030,7 +2030,7 @@ void HandleHistoryCommand(PCommand command, TArgument *argv, int argc, PReply re hEvent = (HANDLE) CallService(MS_DB_EVENT_FINDNEXT, (WPARAM) hEvent, 0); } - GetContactProtocol(hContact, protocol, sizeof(protocol)); + GetContactProto(hContact, protocol, sizeof(protocol)); contact = GetContactName(hContact, protocol); mir_snprintf(buffer, sizeof(buffer), Translate("%s:%s - %d unread events."), contact, protocol, count); diff --git a/plugins/CmdLine/src/utils.cpp b/plugins/CmdLine/src/utils.cpp index 70e86085cc..f85fb74e43 100644 --- a/plugins/CmdLine/src/utils.cpp +++ b/plugins/CmdLine/src/utils.cpp @@ -224,7 +224,7 @@ TCHAR *GetContactName(HANDLE hContact, char *szProto) ctInfo.szProto = szProto; } else{ - GetContactProtocol(hContact, proto, sizeof(proto)); + GetContactProto(hContact, proto, sizeof(proto)); ctInfo.szProto = proto; } ctInfo.dwFlag = CNF_DISPLAY; @@ -253,7 +253,7 @@ TCHAR *GetContactName(HANDLE hContact, char *szProto) #pragma warning (default: 4312) #pragma warning (disable: 4312) -void GetContactProtocol(HANDLE hContact, char *szProto, size_t size) +void GetContactProto(HANDLE hContact, char *szProto, size_t size) { GetStringFromDatabase(hContact, "Protocol", "p", NULL, szProto, size); } @@ -263,7 +263,7 @@ void GetContactProtocol(HANDLE hContact, char *szProto, size_t size) TCHAR *GetContactID(HANDLE hContact) { char protocol[256]; - GetContactProtocol(hContact, protocol, sizeof(protocol)); + GetContactProto(hContact, protocol, sizeof(protocol)); return GetContactID(hContact, protocol); } @@ -346,7 +346,7 @@ HANDLE GetContactFromID(TCHAR *szID, char *szProto) int found = 0; while (hContact) { - GetContactProtocol(hContact, cProtocol, sizeof(cProtocol)); + GetContactProto(hContact, cProtocol, sizeof(cProtocol)); szHandle = GetContactID(hContact, cProtocol); tmp = (char *) CallService(MS_CLIST_GETCONTACTDISPLAYNAME, (WPARAM) hContact, 0); diff --git a/plugins/CmdLine/src/utils.h b/plugins/CmdLine/src/utils.h index 22b4721cfa..5729528f04 100644 --- a/plugins/CmdLine/src/utils.h +++ b/plugins/CmdLine/src/utils.h @@ -53,7 +53,7 @@ TCHAR *GetContactID(HANDLE hContact); TCHAR *GetContactID(HANDLE hContact, char *szProto); HANDLE GetContactFromID(TCHAR *szID, char *szProto); HANDLE GetContactFromID(TCHAR *szID, wchar_t *szProto); -void GetContactProtocol(HANDLE hContact, char *szProto, size_t size); +void GetContactProto(HANDLE hContact, char *szProto, size_t size); int MyPUShowMessage(char *lpzText, BYTE kind); diff --git a/plugins/ContactsPlus/src/main.cpp b/plugins/ContactsPlus/src/main.cpp index 0f413368fe..585575f77b 100644 --- a/plugins/ContactsPlus/src/main.cpp +++ b/plugins/ContactsPlus/src/main.cpp @@ -155,7 +155,7 @@ static bool CheckContactsServiceSupport(const char* szProto) static int HookPreBuildContactMenu(WPARAM wParam, LPARAM lParam) { HANDLE hContact = (HANDLE)wParam; - char* szProto = GetContactProto(hContact); + char* szProto =GetContactProto(hContact); int bVisible = FALSE; if (szProto && CheckContactsServiceSupport(szProto)) @@ -214,7 +214,7 @@ static int HookModulesLoaded(WPARAM wParam, LPARAM lParam) static int HookContactSettingChanged(WPARAM wParam, LPARAM lParam) { DBCONTACTWRITESETTING *cws = (DBCONTACTWRITESETTING*)lParam; - char *szProto = GetContactProto((HANDLE)wParam); + char *szProto =GetContactProto((HANDLE)wParam); if (strcmpnull(cws->szModule,"CList") && strcmpnull(cws->szModule, szProto)) return 0; diff --git a/plugins/ContactsPlus/src/receive.cpp b/plugins/ContactsPlus/src/receive.cpp index 3d3fb2f773..d590a3b37b 100644 --- a/plugins/ContactsPlus/src/receive.cpp +++ b/plugins/ContactsPlus/src/receive.cpp @@ -137,7 +137,7 @@ static void RebuildGroupCombo(HWND hwndDlg) static HANDLE CreateTemporaryContactForItem(HWND hwndDlg, TRecvContactsData* wndData, int iItem) { char* caUIN = ListView_GetItemTextEx(GetDlgItem(hwndDlg, IDC_CONTACTS), iItem, 0); - char* szProto = GetContactProto(wndData->mhContact); + char* szProto =GetContactProto(wndData->mhContact); wndData->rhSearch = (HANDLE)CallProtoService(szProto, PS_BASICSEARCH, 0, (LPARAM)caUIN); // find it SAFE_FREE((void**)&wndData->haUin); wndData->haUin = caUIN; @@ -193,7 +193,7 @@ INT_PTR CALLBACK RecvDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lPara TranslateMenu(wndData->mhPopup); wndData->hHook = HookEventMessage(ME_PROTO_ACK, hwndDlg, HM_EVENTSENT); - char *szProto = GetContactProto(wndData->mhContact); + char *szProto =GetContactProto(wndData->mhContact); HWND hLV = GetDlgItem(hwndDlg, IDC_CONTACTS); ListView_SetExtendedListViewStyle(hLV, LVS_EX_CHECKBOXES|LVS_EX_FULLROWSELECT); @@ -332,7 +332,7 @@ INT_PTR CALLBACK RecvDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lPara for (int j = 0; j < wndData->cbReceived; j++) // determine item index in packet if (!strcmpnull(wndData->maReceived[j]->mcaUIN, caUIN)) { - char* szProto = GetContactProto(wndData->mhContact); + char* szProto =GetContactProto(wndData->mhContact); HANDLE hContact = (HANDLE)CallProtoService(szProto, PS_ADDTOLISTBYEVENT, MAKEWPARAM(0, j), (LPARAM)wndData->mhDbEvent); if (hContact && caGroup) { // use newest group API if available diff --git a/plugins/ContactsPlus/src/send.cpp b/plugins/ContactsPlus/src/send.cpp index ac042fa63e..c09284a2eb 100644 --- a/plugins/ContactsPlus/src/send.cpp +++ b/plugins/ContactsPlus/src/send.cpp @@ -139,7 +139,7 @@ int TSendContactsData::SendContactsPacket(HWND hwndDlg, HANDLE *phContacts, int int TSendContactsData::SendContacts(HWND hwndDlg) { - char* szProto = GetContactProto(hContact); + char* szProto =GetContactProto(hContact); int nMaxContacts = CallProtoService(szProto, PS_GETCAPS, PFLAG_MAXCONTACTSPERPACKET, (LPARAM)hContact); if (!nMaxContacts) { @@ -224,7 +224,7 @@ static void SetAllContactChecks(HWND hwndList, HANDLE hReceiver) // doubtful nam if (binListEvent) return; binListEvent = TRUE; - char* szProto = GetContactProto(hReceiver); + char* szProto =GetContactProto(hReceiver); if (szProto == NULL) return; if (CallService(MS_CLUI_GETCAPS, 0, 0) & CLUIF_HIDEEMPTYGROUPS && DBGetContactSettingByte(NULL, "CList", "HideEmptyGroups", SETTING_USEGROUPS_DEFAULT)) @@ -235,7 +235,7 @@ static void SetAllContactChecks(HWND hwndList, HANDLE hReceiver) // doubtful nam hContact = FindFirstClistContact(hwndList, &hItem); while (hContact) { - char* szProto2 = GetContactProto(hContact); + char* szProto2 =GetContactProto(hContact); if (strcmpnull(szProto, szProto2)) { // different protocols or protocol undefined, remove contact, useless anyway @@ -470,7 +470,7 @@ INT_PTR CALLBACK SendDlgProc( HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lPar } dbei.cbSize = sizeof(dbei); - dbei.szModule = GetContactProto(ackData->hContact); + dbei.szModule =GetContactProto(ackData->hContact); dbei.eventType = EVENTTYPE_CONTACTS; dbei.flags = DBEF_SENT; if (g_UnicodeCore && g_Utf8EventsSupported) diff --git a/plugins/ContactsPlus/src/utils.cpp b/plugins/ContactsPlus/src/utils.cpp index f0971a37ae..18b80b9d3f 100644 --- a/plugins/ContactsPlus/src/utils.cpp +++ b/plugins/ContactsPlus/src/utils.cpp @@ -61,19 +61,11 @@ void __fastcall SAFE_FREE(void** p) } } - -char *GetContactProto(HANDLE hContact) -{ - return (char*)CallService(MS_PROTO_GETCONTACTBASEPROTO,(WPARAM)hContact,0); -} - - TCHAR *GetContactDisplayNameT(HANDLE hContact) { return (TCHAR*)CallService(MS_CLIST_GETCONTACTDISPLAYNAME, (WPARAM)hContact, g_UnicodeCore ? GCDNF_UNICODE : 0); } - char *GetContactUID(HANDLE hContact, int bTchar) { DBVARIANT vrUid; @@ -218,7 +210,7 @@ void UpdateDialogTitle(HWND hwndDlg, HANDLE hContact, char* pszTitleStart) if (hContact) { - szProto = GetContactProto(hContact); + szProto =GetContactProto(hContact); if (szProto) { TCHAR *uid = GetContactUID(hContact, TRUE); @@ -273,7 +265,7 @@ HICON InitMButton(HWND hDlg, int idButton, LPCSTR szIcon, char* szTip) HICON LoadContactProtoIcon(HANDLE hContact) { - char* szProto = GetContactProto(hContact); + char* szProto =GetContactProto(hContact); if (szProto) return (HICON)CallProtoService(szProto, PS_LOADICON, PLI_PROTOCOL|PLIF_SMALL, 0); return NULL; diff --git a/plugins/ContactsPlus/src/utils.h b/plugins/ContactsPlus/src/utils.h index 3bc2d8e00d..c9d89e9f24 100644 --- a/plugins/ContactsPlus/src/utils.h +++ b/plugins/ContactsPlus/src/utils.h @@ -33,7 +33,6 @@ size_t __fastcall strlennull(const char *string); int __fastcall strcmpnull(const char *str1, const char *str2); char* __fastcall null_strdup(const char *string); -char *GetContactProto(HANDLE hContact); char *GetContactUID(HANDLE hContact, int bTchar); TCHAR *GetContactDisplayNameT(HANDLE hContact); TCHAR* MirandaStatusToStringT(int mirandaStatus); diff --git a/plugins/CountryFlags/src/extraimg.cpp b/plugins/CountryFlags/src/extraimg.cpp index 433cbfb664..0b1648bd6b 100644 --- a/plugins/CountryFlags/src/extraimg.cpp +++ b/plugins/CountryFlags/src/extraimg.cpp @@ -32,7 +32,7 @@ extern struct CountryListEntry *countries; static INT_PTR ServiceDetectContactOriginCountry(WPARAM wParam,LPARAM lParam) { int countryNumber = 0xFFFF; - char *pszProto = (char*)CallService(MS_PROTO_GETCONTACTBASEPROTO,wParam,0); + char *pszProto = GetContactProto((HANDLE)wParam); /* ip detect */ if ( db_get_b(NULL,"Flags","UseIpToCountry",SETTING_USEIPTOCOUNTRY_DEFAULT)) countryNumber=ServiceIpToCountry(DBGetContactSettingDword((HANDLE)wParam,pszProto,"RealIP",0),0); diff --git a/plugins/DbEditorPP/src/exportimport.cpp b/plugins/DbEditorPP/src/exportimport.cpp index 2e58ea34ea..b4c1142e2c 100644 --- a/plugins/DbEditorPP/src/exportimport.cpp +++ b/plugins/DbEditorPP/src/exportimport.cpp @@ -337,7 +337,7 @@ HANDLE CheckNewContact(char *myProto, char *uid, char *myName) while (hContact) { - //szProto = (char*)CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)hContact, 0); + //szProto = GetContactProto(hContact); if (DBGetContactSettingStringStatic(hContact, "Protocol", "p", szProto, 256)) { if (!mir_strcmp(szProto, myProto)) diff --git a/plugins/FTPFileYM/src/mir_db.cpp b/plugins/FTPFileYM/src/mir_db.cpp index f5745d9f24..6c634da656 100644 --- a/plugins/FTPFileYM/src/mir_db.cpp +++ b/plugins/FTPFileYM/src/mir_db.cpp @@ -192,6 +192,6 @@ int DB::deleteSettingF(HANDLE hContact, char *szModule, char *szSetting, int id) char *DB::getProto(HANDLE hContact) { - char *szProto = (char *)CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)hContact, 0); + char *szProto = GetContactProto(hContact); return ((INT_PTR)szProto != CALLSERVICE_NOTFOUND) ? szProto : NULL; } \ No newline at end of file diff --git a/plugins/FavContacts/src/favlist.h b/plugins/FavContacts/src/favlist.h index 0b793b2185..dc2dd610e9 100644 --- a/plugins/FavContacts/src/favlist.h +++ b/plugins/FavContacts/src/favlist.h @@ -32,7 +32,7 @@ public: { group = mir_tstrdup(TranslateT("Favourite Contacts")); } - status = DBGetContactSettingWord(hContact, (char *)CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)hContact, 0), "Status", ID_STATUS_OFFLINE); + status = DBGetContactSettingWord(hContact, GetContactProto(hContact), "Status", ID_STATUS_OFFLINE); } ~TContactInfo() diff --git a/plugins/FavContacts/src/http_api.cpp b/plugins/FavContacts/src/http_api.cpp index 9b2ac3f3c3..fccd06968b 100644 --- a/plugins/FavContacts/src/http_api.cpp +++ b/plugins/FavContacts/src/http_api.cpp @@ -75,7 +75,7 @@ public: HANDLE hContact = favList[i]->getHandle(); TCHAR *name = (TCHAR *)CallService(MS_CLIST_GETCONTACTDISPLAYNAME, (WPARAM)hContact, GCDNF_TCHAR); AVATARCACHEENTRY *avatar = (AVATARCACHEENTRY *)CallService(MS_AV_GETAVATARBITMAP, (WPARAM)hContact, 0); - int status = DBGetContactSettingWord(hContact, (char *)CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)hContact, 0), "Status", ID_STATUS_OFFLINE); + int status = DBGetContactSettingWord(hContact, GetContactProto(hContact), "Status", ID_STATUS_OFFLINE); Send("SetContact("); Send(i); diff --git a/plugins/FavContacts/src/main.cpp b/plugins/FavContacts/src/main.cpp index 4cdb44abdb..733a890bd0 100644 --- a/plugins/FavContacts/src/main.cpp +++ b/plugins/FavContacts/src/main.cpp @@ -507,7 +507,7 @@ static BOOL sttMeasureItem_Contact(LPMEASUREITEMSTRUCT lpmis, Options *options) bool bFree = false; if (DBGetContactSettingTString(hContact, "CList", "StatusMsg", &dbv) || !*dbv.ptszVal) { - char *proto = (char *)CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)hContact, 0); + char *proto = GetContactProto(hContact); int status = DBGetContactSettingWord(hContact, proto, "Status", ID_STATUS_OFFLINE); title = (TCHAR *)CallService(MS_CLIST_GETSTATUSMODEDESCRIPTION, status, GSMDF_TCHAR); } else @@ -706,7 +706,7 @@ static BOOL sttDrawItem_Contact(LPDRAWITEMSTRUCT lpdis, Options *options = NULL) lpdis->rcItem.top += 2; lpdis->rcItem.bottom -= 2; - char *proto = (char *)CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)hContact, 0); + char *proto = GetContactProto(hContact); if (true) { diff --git a/plugins/FileAsMessage/src/dialog.cpp b/plugins/FileAsMessage/src/dialog.cpp index 125952db8b..ecd5ce7ac1 100644 --- a/plugins/FileAsMessage/src/dialog.cpp +++ b/plugins/FileAsMessage/src/dialog.cpp @@ -1183,8 +1183,7 @@ INT_PTR CALLBACK DialogProc( HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam break; case WM_FE_STATUSCHANGE: { - char *szProto; - szProto=(char*)CallService(MS_PROTO_GETCONTACTBASEPROTO,(WPARAM)dat->hContact,0); + char *szProto = GetContactProto(dat->hContact); if (szProto) { int dwStatus; diff --git a/plugins/FingerPrintModPlus/src/fingerprint.cpp b/plugins/FingerPrintModPlus/src/fingerprint.cpp index 8b4b542064..95bb034f69 100644 --- a/plugins/FingerPrintModPlus/src/fingerprint.cpp +++ b/plugins/FingerPrintModPlus/src/fingerprint.cpp @@ -205,7 +205,7 @@ int OnExtraImageApply(WPARAM wParam, LPARAM lParam) if (hContact == NULL) return 0; - char *szProto = (char*)CallService(MS_PROTO_GETCONTACTBASEPROTO,wParam,0); + char *szProto = GetContactProto((HANDLE)wParam); if (szProto != NULL) { DBVARIANT dbvMirVer = { 0 }; diff --git a/plugins/FlashAvatars/src/cflash.cpp b/plugins/FlashAvatars/src/cflash.cpp index 284a453659..e99984afbc 100644 --- a/plugins/FlashAvatars/src/cflash.cpp +++ b/plugins/FlashAvatars/src/cflash.cpp @@ -66,7 +66,7 @@ struct flash_avatar_item : public MZeroedObject FLASHAVATAR hFA; IShockwaveFlash* pFlash; - char* getProto() { return (hFA.cProto) ? hFA.cProto : (char*)CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)hFA.hContact, 0); } + char* getProto() { return (hFA.cProto) ? hFA.cProto : GetContactProto(hFA.hContact); } flash_avatar_item(HANDLE contact, FLASHAVATAR& fa, IShockwaveFlash *flash) { hContact = contact; hFA = fa; pFlash = flash; } }; diff --git a/plugins/FloatingContacts/src/thumbs.cpp b/plugins/FloatingContacts/src/thumbs.cpp index 77daa3107a..af4a18acf9 100644 --- a/plugins/FloatingContacts/src/thumbs.cpp +++ b/plugins/FloatingContacts/src/thumbs.cpp @@ -306,7 +306,7 @@ void ThumbInfo::ResizeThumb() int nApparentMode; char* szProto; - szProto = (char*)CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)hContact, 0); + szProto = GetContactProto(hContact); if ( NULL != szProto ) { @@ -725,7 +725,7 @@ void ThumbInfo::UpdateContent() char* szProto; - szProto = (char*)CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)hContact, 0); + szProto = GetContactProto(hContact); if ( NULL != szProto ) { diff --git a/plugins/Gender/src/main.cpp b/plugins/Gender/src/main.cpp index 33c841b42e..000c9d6389 100644 --- a/plugins/Gender/src/main.cpp +++ b/plugins/Gender/src/main.cpp @@ -91,7 +91,7 @@ int applyExtraImage(HANDLE hContact) hContact = hMetacontact; } - char *proto = (char *)CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)hContact, 0); + char *proto = GetContactProto(hContact); if (!proto) return 0; @@ -107,7 +107,7 @@ int applyExtraImage(HANDLE hContact) // Returns gender icon for specific contact INT_PTR GetIcon(WPARAM wParam, LPARAM lParam) { - char *proto = (char *)CallService(MS_PROTO_GETCONTACTBASEPROTO, wParam, 0); + char *proto = GetContactProto((HANDLE)wParam); unsigned short gender = DBGetContactSettingByte((HANDLE)wParam, "UserInfo", "Gender", DBGetContactSettingByte((HANDLE)wParam, proto, "Gender", 0)); if (gender > 0) { @@ -122,7 +122,7 @@ INT_PTR GetIcon(WPARAM wParam, LPARAM lParam) int onPrebuildContactMenu(WPARAM wParam, LPARAM lParam) { - char *proto = (char *)CallService(MS_PROTO_GETCONTACTBASEPROTO, wParam, 0); + char *proto = GetContactProto((HANDLE)wParam); if (!proto) return 0; diff --git a/plugins/IEView/src/HTMLBuilder.cpp b/plugins/IEView/src/HTMLBuilder.cpp index e4211cac74..ee1a7baa10 100644 --- a/plugins/IEView/src/HTMLBuilder.cpp +++ b/plugins/IEView/src/HTMLBuilder.cpp @@ -136,24 +136,24 @@ char * HTMLBuilder::encodeUTF8(HANDLE hContact, const char *proto, const char *t } char *HTMLBuilder::getProto(HANDLE hContact) { - return Utils::dupString((char *)CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM) hContact, 0)); + return Utils::dupString(GetContactProto(hContact)); } char *HTMLBuilder::getProto(const char *proto, HANDLE hContact) { if (proto != NULL) { return Utils::dupString(proto); } - return Utils::dupString((char *)CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM) hContact, 0)); + return Utils::dupString(GetContactProto(hContact)); } char *HTMLBuilder::getRealProto(HANDLE hContact) { if (hContact != NULL) { - char *szProto = Utils::dupString((char *)CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM) hContact, 0)); + char *szProto = Utils::dupString(GetContactProto(hContact)); if (szProto!=NULL && !strcmp(szProto,"MetaContacts")) { hContact = (HANDLE) CallService(MS_MC_GETMOSTONLINECONTACT, (WPARAM) hContact, 0); if (hContact!=NULL) { delete szProto; - szProto = Utils::dupString((char *)CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM) hContact, 0)); + szProto = Utils::dupString(GetContactProto(hContact)); } } return szProto; @@ -165,14 +165,14 @@ char *HTMLBuilder::getRealProto(HANDLE hContact, const char *szProto) { if (szProto!=NULL && !strcmp(szProto,"MetaContacts")) { hContact = (HANDLE) CallService(MS_MC_GETMOSTONLINECONTACT, (WPARAM) hContact, 0); if (hContact!=NULL) { - return Utils::dupString((char *)CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM) hContact, 0)); + return Utils::dupString(GetContactProto(hContact)); } } return Utils::dupString(szProto); } HANDLE HTMLBuilder::getRealContact(HANDLE hContact) { - char *szProto = (char *)CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM) hContact, 0); + char *szProto = GetContactProto(hContact); if (szProto != NULL && !strcmp(szProto,"MetaContacts")) { hContact = (HANDLE) CallService(MS_MC_GETMOSTONLINECONTACT, (WPARAM) hContact, 0); } diff --git a/plugins/Import/src/import.cpp b/plugins/Import/src/import.cpp index f9ac5d815b..c0de7cc8e3 100644 --- a/plugins/Import/src/import.cpp +++ b/plugins/Import/src/import.cpp @@ -70,7 +70,7 @@ static HANDLE HContactFromNumericID(char* szProto, char* pszSetting, DWORD dwID) HANDLE hContact = dstDb->FindFirstContact(); while (hContact != NULL) { if ( db_get_dw(hContact, szProto, pszSetting, 0) == dwID) { - char* szProto = (char*)CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)hContact, 0); + char* szProto = GetContactProto(hContact); if (szProto != NULL && !lstrcmpA(szProto, szProto)) return hContact; } @@ -83,7 +83,7 @@ static HANDLE HContactFromID(char* szProto, char* pszSetting, TCHAR* pwszID) { HANDLE hContact = dstDb->FindFirstContact(); while (hContact != NULL) { - char* szProto = (char*)CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)hContact, 0); + char* szProto = GetContactProto(hContact); if ( !lstrcmpA(szProto, szProto)) { mir_ptr id( db_get_tsa(hContact, szProto, pszSetting)); if ( !lstrcmp(pwszID, id)) diff --git a/plugins/KeyboardNotify/src/ignore.cpp b/plugins/KeyboardNotify/src/ignore.cpp index 4d756e8b05..769cf5bce2 100644 --- a/plugins/KeyboardNotify/src/ignore.cpp +++ b/plugins/KeyboardNotify/src/ignore.cpp @@ -196,7 +196,7 @@ static void SetAllContactIcons(HWND hwndList) do { hItem = (HANDLE)SendMessage(hwndList, CLM_FINDCONTACT, (WPARAM)hContact, 0); if(hItem && SendMessage(hwndList, CLM_GETEXTRAIMAGE, (WPARAM)hItem, MAKELPARAM(IGNOREEVENT_MAX, 0)) == EMPTY_EXTRA_ICON) { - szProto = (char*)CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)hContact, 0); + szProto = GetContactProto(hContact); if(szProto == NULL) protoCaps = 0; else diff --git a/plugins/KeyboardNotify/src/main.cpp b/plugins/KeyboardNotify/src/main.cpp index 02254e11ef..144dfaf27a 100644 --- a/plugins/KeyboardNotify/src/main.cpp +++ b/plugins/KeyboardNotify/src/main.cpp @@ -306,7 +306,7 @@ BOOL CheckMsgWnd(HANDLE, BOOL *); BOOL isMetaContactsSubContact(HANDLE hMetaContact, HANDLE hContact) { - char *szProto = (char *)CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)hMetaContact, 0); + char *szProto = GetContactProto(hMetaContact); if (szProto && !strcmp(szMetaProto, szProto)) { // Safety check int i = DBGetContactSettingDword(hContact, szMetaProto, "ContactNumber", -1); if (i >= 0 && hContact == (HANDLE)CallService(MS_MC_GETSUBCONTACT, (WPARAM)hMetaContact, i)) @@ -478,7 +478,7 @@ DBEVENTINFO createMsgEventInfo(HANDLE hContact) einfo.cbSize = sizeof(einfo); einfo.eventType = EVENTTYPE_MESSAGE; - einfo.szModule = (char *)CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)hContact, 0); + einfo.szModule = GetContactProto(hContact); return einfo; } @@ -525,7 +525,7 @@ BOOL metaCheckProtocol(char *szProto, HANDLE hContact, WORD eventType) if (szMetaProto && bMetaProtoEnabled && szProto && !strcmp(szMetaProto, szProto)) if (hSubContact = (HANDLE)CallService(MS_MC_GETMOSTONLINECONTACT, (WPARAM)hContact, 0)) - szProto = (char *)CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)hSubContact, 0); + szProto = GetContactProto(hSubContact); return checkProtocol(szProto) && checkIgnore(hSubContact?hSubContact:hContact, eventType); } diff --git a/plugins/ListeningTo/src/listeningto.cpp b/plugins/ListeningTo/src/listeningto.cpp index 931270ff1b..cea9ef9566 100644 --- a/plugins/ListeningTo/src/listeningto.cpp +++ b/plugins/ListeningTo/src/listeningto.cpp @@ -314,7 +314,7 @@ int ModulesLoaded(WPARAM wParam, LPARAM lParam) HANDLE hContact = db_find_first(); while (hContact != NULL) { - char *proto = (char *) CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM) hContact, 0); + char *proto = GetContactProto(hContact); if (proto != NULL) { DBVARIANT dbv; if (!DBGetContactSettingTString(hContact, proto, "ListeningTo", &dbv)) { @@ -985,7 +985,7 @@ int SettingChanged(WPARAM wParam,LPARAM lParam) if (strcmp(cws->szSetting, "ListeningTo") != 0) return 0; - char *proto = (char *) CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM) hContact, 0); + char *proto = GetContactProto(hContact); if (proto == NULL) return 0; diff --git a/plugins/ListeningTo/src/players/mradio.cpp b/plugins/ListeningTo/src/players/mradio.cpp index 84fdd61b95..1916d491ab 100644 --- a/plugins/ListeningTo/src/players/mradio.cpp +++ b/plugins/ListeningTo/src/players/mradio.cpp @@ -41,7 +41,7 @@ int MRadio::GetData() hContact = db_find_first(); while (hContact != NULL) { - char *proto = (char *)CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)hContact, 0); + char *proto = GetContactProto(hContact); if (proto) { if (strcmp("mRadio", proto) == 0) diff --git a/plugins/MenuItemEx/src/main.cpp b/plugins/MenuItemEx/src/main.cpp index ce2d7349c4..6450110251 100644 --- a/plugins/MenuItemEx/src/main.cpp +++ b/plugins/MenuItemEx/src/main.cpp @@ -319,7 +319,7 @@ BOOL isMetaContact(HANDLE hContact) { char *proto; if(bMetaContacts) { - proto = (char *)CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)hContact, 0); + proto = GetContactProto(hContact); if ( lstrcmpA(proto,"MetaContacts") == 0 ) { return TRUE; } @@ -373,7 +373,7 @@ int StatusMsgExists(HANDLE hContact) BOOL ret = 0; int i; - module = (LPSTR) CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)hContact, 0); + module = GetContactProto(hContact); if (!module) return 0; for(i = 0; i < SIZEOF(statusMsg); i++) { @@ -397,7 +397,7 @@ BOOL IPExists(HANDLE hContact) LPSTR szProto; DWORD mIP,rIP; - szProto = (LPSTR) CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)hContact, 0); + szProto = GetContactProto(hContact); if (!szProto) return 0; mIP = DBGetContactSettingDword(hContact, szProto, "IP", 0); @@ -411,7 +411,7 @@ BOOL MirVerExists(HANDLE hContact) LPSTR szProto, msg; BOOL ret = 0; - szProto = (LPSTR) CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)hContact, 0); + szProto = GetContactProto(hContact); if (!szProto) return 0; msg = DBGetString(hContact,szProto,"MirVer"); @@ -439,7 +439,7 @@ LPSTR getMirVer(HANDLE hContact) { LPSTR szProto, msg; - szProto = (LPSTR) CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)hContact, 0); + szProto = GetContactProto(hContact); if (!szProto) return NULL; msg = DBGetString(hContact,szProto,"MirVer"); @@ -505,14 +505,14 @@ INT_PTR CALLBACK AuthReqWndProc(HWND hdlg,UINT msg,WPARAM wparam,LPARAM lparam) BOOL isVisSupport(HANDLE hContact) { - char *szProto = (char*)CallService(MS_PROTO_GETCONTACTBASEPROTO,(WPARAM)hContact,0); + char *szProto = GetContactProto(hContact); if(szProto == NULL) return 0; return CallProtoService(szProto,PS_GETCAPS,PFLAGNUM_1,0)&PF1_INVISLIST; } BOOL isInvSupport(HANDLE hContact) { - char *szProto = (char*)CallService(MS_PROTO_GETCONTACTBASEPROTO,(WPARAM)hContact,0); + char *szProto = GetContactProto(hContact); if(szProto == NULL) return 0; return CallProtoService(szProto,PS_GETCAPS,PFLAGNUM_1,0)&PF1_VISLIST; } @@ -532,9 +532,7 @@ BOOL isProtoOnline(char *szProto) INT_PTR onSendAuthRequest(WPARAM wparam,LPARAM lparam) { DWORD flags; - char *szProto; - - szProto = (char *)CallService(MS_PROTO_GETCONTACTBASEPROTO,wparam,0); + char *szProto = GetContactProto((HANDLE)wparam); flags = CallProtoService(szProto,PS_GETCAPS,PFLAGNUM_4,0); if (flags&PF4_NOCUSTOMAUTH) @@ -554,14 +552,14 @@ INT_PTR onSendAdded(WPARAM wparam,LPARAM lparam) // set the invisible-flag in db INT_PTR onSetInvis(WPARAM wparam,LPARAM lparam) { - CallContactService((HANDLE)wparam,PSS_SETAPPARENTMODE,(DBGetContactSettingWord((HANDLE)wparam,(const char*)CallService(MS_PROTO_GETCONTACTBASEPROTO,wparam,0),"ApparentMode",0) == ID_STATUS_OFFLINE)?0:ID_STATUS_OFFLINE,0); + CallContactService((HANDLE)wparam,PSS_SETAPPARENTMODE,(DBGetContactSettingWord((HANDLE)wparam, GetContactProto((HANDLE)wparam),"ApparentMode",0) == ID_STATUS_OFFLINE)?0:ID_STATUS_OFFLINE,0); return 0; } // set visible-flag in db INT_PTR onSetVis(WPARAM wparam,LPARAM lparam) { - CallContactService((HANDLE)wparam,PSS_SETAPPARENTMODE,(DBGetContactSettingWord((HANDLE)wparam,(const char*)CallService(MS_PROTO_GETCONTACTBASEPROTO,wparam,0),"ApparentMode",0) == ID_STATUS_ONLINE)?0:ID_STATUS_ONLINE,0); + CallContactService((HANDLE)wparam,PSS_SETAPPARENTMODE,(DBGetContactSettingWord((HANDLE)wparam, GetContactProto((HANDLE)wparam),"ApparentMode",0) == ID_STATUS_ONLINE)?0:ID_STATUS_ONLINE,0); return 0; } @@ -623,7 +621,7 @@ void ModifyCopyID(CLISTMENUITEM *cli, HANDLE hContact, BOOL bShowID, BOOL bTrimI hContact = hC; } - szProto = (LPSTR) CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)hContact, 0); + szProto = GetContactProto(hContact); if (!szProto) { HideItem(cli,hmenuCopyID); return; @@ -668,7 +666,7 @@ void ModifyStatusMsg(CLISTMENUITEM *cli,HANDLE hContact) cli->flags|=CMIM_ICON; - szProto = (LPSTR) CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)hContact, 0); + szProto = GetContactProto(hContact); if (!szProto) { HideItem(cli,hmenuStatusMsg); return; @@ -690,7 +688,7 @@ void ModifyCopyIP(CLISTMENUITEM *cli,HANDLE hContact) cli->flags |= CMIM_ICON; - szProto = (LPSTR) CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)hContact, 0); + szProto = GetContactProto(hContact); if (!szProto) { HideItem(cli,hmenuCopyIP); return; @@ -734,7 +732,7 @@ INT_PTR onCopyID(WPARAM wparam,LPARAM lparam) if ( !hContact ) hC = getDefaultContact(hContact); hContact = hC; } - if ((szProto = (LPSTR) CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)hContact, 0)) == NULL) + if ((szProto = GetContactProto(hContact)) == NULL) return 0; GetID(hContact,szProto,(LPSTR)&szID); @@ -766,8 +764,9 @@ INT_PTR onCopyStatusMsg(WPARAM wparam,LPARAM lparam) int i; DWORD flags = DBGetContactSettingDword(NULL,VISPLG,"flags",vf_default); - module = (LPSTR) CallService(MS_PROTO_GETCONTACTBASEPROTO, wparam, 0); - if (!module) return 0; + module = GetContactProto((HANDLE)wparam); + if (!module) + return 0; buffer[0] = 0; for(i = 0; i < SIZEOF(statusMsg); i++) { @@ -802,10 +801,9 @@ INT_PTR onCopyStatusMsg(WPARAM wparam,LPARAM lparam) INT_PTR onCopyIP(WPARAM wparam,LPARAM lparam) { - LPSTR szProto; - char szIP[128]; + char *szProto = GetContactProto((HANDLE)wparam); - szProto = (LPSTR) CallService(MS_PROTO_GETCONTACTBASEPROTO, wparam, 0); + char szIP[128]; getIP((HANDLE)wparam,szProto,(LPSTR)&szIP); CopyToClipboard((HWND)lparam, szIP, 0); @@ -838,17 +836,15 @@ INT_PTR onRecvFiles(WPARAM wparam,LPARAM lparam) INT_PTR onChangeProto(WPARAM wparam,LPARAM lparam) { - HANDLE hContact, hContactNew; - - hContact = (HANDLE)wparam; - if (!strcmp((char*)CallService(MS_PROTO_GETCONTACTBASEPROTO, wparam, 0), (char*)lparam)) + HANDLE hContact = (HANDLE)wparam, hContactNew; + char* szProto = GetContactProto(hContact); + if ( !strcmp(szProto, (char*)lparam)) return 0; - if (CTRL_IS_PRESSED) - { + if (CTRL_IS_PRESSED) { hContactNew = hContact; - RenameDbProto(hContact, hContactNew, (char*)CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)hContact, 0), (char*)lparam, 1); - CallService(MS_PROTO_REMOVEFROMCONTACT, (WPARAM)hContact, CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)hContact, 0)); + RenameDbProto(hContact, hContactNew, GetContactProto(hContact), (char*)lparam, 1); + CallService(MS_PROTO_REMOVEFROMCONTACT, (WPARAM)hContact, (LPARAM)GetContactProto(hContact)); CallService(MS_PROTO_ADDTOCONTACT, (WPARAM)hContactNew, lparam); } else @@ -857,7 +853,7 @@ INT_PTR onChangeProto(WPARAM wparam,LPARAM lparam) if (hContactNew) { CallService(MS_PROTO_ADDTOCONTACT, (WPARAM)hContactNew, lparam); - RenameDbProto(hContact, hContactNew, (char*)CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)hContact, 0), (char*)lparam, 0); + RenameDbProto(hContact, hContactNew, GetContactProto(hContact), (char*)lparam, 0); RenameDbProto(hContact, hContactNew, "CList", "CList", 0); } else @@ -932,8 +928,7 @@ int BuildMenu(WPARAM wparam,LPARAM lparam) DWORD flags = DBGetContactSettingDword(NULL,VISPLG,"flags",vf_default); int i = 0, j = 0, check = 0, all = 0, hide = 0; BOOL bIsOnline = FALSE, bShowAll = CTRL_IS_PRESSED; - char* pszProto; - pszProto = (LPSTR)CallService(MS_PROTO_GETCONTACTBASEPROTO, wparam, 0); + char* pszProto = GetContactProto((HANDLE)wparam); PROTOACCOUNT *pa = ProtoGetAccount(pszProto); bIsOnline = isProtoOnline(pszProto); @@ -1044,7 +1039,7 @@ int BuildMenu(WPARAM wparam,LPARAM lparam) if(bShowAll || (flags&VF_VS)) { - int apparent = DBGetContactSettingWord((HANDLE)wparam,(const char*)CallService(MS_PROTO_GETCONTACTBASEPROTO,wparam,0),"ApparentMode",0); + int apparent = DBGetContactSettingWord((HANDLE)wparam, GetContactProto((HANDLE)wparam),"ApparentMode",0); if(isVisSupport((HANDLE)wparam)) ModifyVisibleSet(&miAV,apparent == ID_STATUS_ONLINE,flags&VF_SAI); else HideItem(&miAV,hmenuVis); if(isInvSupport((HANDLE)wparam)) ModifyInvisSet(&miNV,apparent == ID_STATUS_OFFLINE,flags&VF_SAI); diff --git a/plugins/MetaContacts/src/edit.cpp b/plugins/MetaContacts/src/edit.cpp index 5980f905a4..15e9455bda 100644 --- a/plugins/MetaContacts/src/edit.cpp +++ b/plugins/MetaContacts/src/edit.cpp @@ -103,7 +103,7 @@ void FillContactList(HWND hWndDlg, CHANGES *chg) { LvItem.iSubItem = 1; // id - proto = (char *)CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)chg->hContact[i], 0); + proto = GetContactProto(chg->hContact[i]); if (proto) { field = (char *)CallProtoService(proto,PS_GETCAPS,PFLAG_UNIQUEIDSETTING,0); diff --git a/plugins/MetaContacts/src/meta_main.cpp b/plugins/MetaContacts/src/meta_main.cpp index 8a05fe1f7b..f307d800b6 100644 --- a/plugins/MetaContacts/src/meta_main.cpp +++ b/plugins/MetaContacts/src/meta_main.cpp @@ -171,7 +171,7 @@ extern "C" __declspec(dllexport) int Load(void) HANDLE hContact = db_find_first(); char *proto; while(hContact != NULL) { - //proto = (char *)CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)hContact, 0); + //proto = GetContactProto(hContact); if (!DBGetContactSetting(hContact, "Protocol", "p", &dbv)) { proto = dbv.pszVal; if (proto && !lstrcmp( META_PROTO, proto)) { diff --git a/plugins/MetaContacts/src/meta_menu.cpp b/plugins/MetaContacts/src/meta_menu.cpp index fe718ba95b..524a46931c 100644 --- a/plugins/MetaContacts/src/meta_menu.cpp +++ b/plugins/MetaContacts/src/meta_menu.cpp @@ -42,7 +42,7 @@ INT_PTR Meta_Convert(WPARAM wParam,LPARAM lParam) char *group = 0;//, *proto; // Get some information about the selected contact. -// proto = (char *)CallService(MS_PROTO_GETCONTACTBASEPROTO,wParam,0); +// proto = GetContactProto(wParam,0); if (!DBGetContactSettingStringUtf((HANDLE)wParam,"CList","Group",&dbv)) { group = _strdup(dbv.pszVal); DBFreeVariant(&dbv); @@ -437,7 +437,7 @@ int Meta_ModifyMenu(WPARAM wParam, LPARAM lParam) for (i = 0; i < MAX_CONTACTS; i++) { if (i < num_contacts) { hContact = Meta_GetContactHandle((HANDLE)wParam, i); - proto = _strdup((char *)CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)hContact, 0)); + proto = _strdup(GetContactProto(hContact)); if (!proto) status = ID_STATUS_OFFLINE; @@ -506,7 +506,7 @@ int Meta_ModifyMenu(WPARAM wParam, LPARAM lParam) { char serviceFunc[256]; hContact = Meta_GetMostOnline((HANDLE)wParam); - mir_snprintf(serviceFunc, 256, "%s/SendNudge", (char *)CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)hContact, 0)); + mir_snprintf(serviceFunc, 256, "%s/SendNudge", GetContactProto(hContact)); CallService(MS_NUDGE_SHOWMENU, (WPARAM)META_PROTO, (LPARAM)ServiceExists(serviceFunc)); } } diff --git a/plugins/MetaContacts/src/meta_services.cpp b/plugins/MetaContacts/src/meta_services.cpp index 251f42a718..d2b5ca563c 100644 --- a/plugins/MetaContacts/src/meta_services.cpp +++ b/plugins/MetaContacts/src/meta_services.cpp @@ -299,7 +299,7 @@ INT_PTR Meta_SendNudge(WPARAM wParam,LPARAM lParam) hSubContact = Meta_GetMostOnline(hMeta); char servicefunction[ 100 ]; - char *protoName = (char *)CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)hSubContact, 0); + char *protoName = GetContactProto(hSubContact); sprintf(servicefunction, "%s/SendNudge", protoName); return CallService(servicefunction, (WPARAM)hSubContact, lParam); @@ -358,7 +358,7 @@ INT_PTR Meta_SendMessage(WPARAM wParam,LPARAM lParam) Meta_CopyContactNick(ccs->hContact, most_online); ccs->hContact = most_online; - proto = (char *)CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)most_online, 0); + proto = GetContactProto(most_online); Meta_SetNick(proto); // (no matter what was there before) // don't bypass filters etc @@ -374,7 +374,7 @@ INT_PTR Meta_SendMessage(WPARAM wParam,LPARAM lParam) if (options.subhistory && !(ccs->wParam & PREF_METANODB)) { // add sent event to subcontact DBEVENTINFO dbei = { sizeof(dbei) }; - dbei.szModule = (char *)CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)ccs->hContact, 0); + dbei.szModule = GetContactProto(ccs->hContact); if (dbei.szModule) { dbei.flags = DBEF_SENT; dbei.timestamp = time(NULL); @@ -464,7 +464,7 @@ INT_PTR MetaFilter_RecvMessage(WPARAM wParam,LPARAM lParam) if (options.use_proto_recv) { // use the subcontact's protocol 'recv' service to add the meta's history (AIMOSCAR removes HTML here!) if possible - char *proto = (char *)CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)ccs->hContact, 0); + char *proto = GetContactProto(ccs->hContact); if (proto) { char service[256]; HANDLE hSub = ccs->hContact; @@ -509,7 +509,7 @@ INT_PTR MetaFilter_RecvMessage(WPARAM wParam,LPARAM lParam) if (options.subhistory) { ZeroMemory(&dbei, sizeof(dbei)); dbei.cbSize = sizeof(dbei); - dbei.szModule = (char *)CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)ccs->hContact, 0); + dbei.szModule = GetContactProto(ccs->hContact, 0); dbei.timestamp = pre->timestamp; dbei.flags = (DBGetContactSettingByte(ccs->hContact, META_PROTO, "WindowOpen", 0) ? 0 : DBEF_READ); if (pre->flags & PREF_RTL) dbei.flags |= DBEF_RTL; @@ -551,9 +551,7 @@ INT_PTR Meta_RecvMessage(WPARAM wParam, LPARAM lParam) CCSDATA *ccs = (CCSDATA *) lParam; PROTORECVEVENT *pre = (PROTORECVEVENT *) ccs->lParam; - char *proto; - - proto = (char *)CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)ccs->hContact, 0); + char *proto = GetContactProto(ccs->hContact); // contact is not a meta proto contact - just leave it if (!proto || strcmp(proto, META_PROTO)) { @@ -564,7 +562,7 @@ INT_PTR Meta_RecvMessage(WPARAM wParam, LPARAM lParam) { // use the subcontact's protocol to add the db if possible (AIMOSCAR removes HTML here!) HANDLE most_online = Meta_GetMostOnline(ccs->hContact); - char *proto = (char *)CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)most_online, 0); + char *proto = GetContactProto(most_online); if (proto) { char service[256]; mir_snprintf(service, 256, "%s%s", proto, PSR_MESSAGE); @@ -817,7 +815,7 @@ int Meta_SettingChanged(WPARAM wParam, LPARAM lParam) if (dcws->value.type == DBVT_DELETED) { DBVARIANT dbv; - char *proto = (char *)CallService(MS_PROTO_GETCONTACTBASEPROTO, wParam, 0); + char *proto = GetContactProto((HANDLE)wParam); strcpy(buffer, "CListName"); strcat(buffer, _itoa(contact_number, buffer2, 10)); if (proto && !MyDBGetContactSetting((HANDLE)wParam, proto, "Nick", &dbv)) { @@ -969,7 +967,7 @@ INT_PTR Meta_UserIsTyping(WPARAM wParam, LPARAM lParam) if (!most_online) return 0; - proto = (char *)CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)most_online, 0); + proto = GetContactProto(most_online); if (proto) { strncpy(buff, proto, 512); strncpy(buff + strlen(proto), PSS_USERISTYPING, 512 - strlen(proto)); @@ -1100,7 +1098,7 @@ int Meta_ClistDoubleClicked(WPARAM wParam, LPARAM lParam) } return 1; } else { - proto = (char *)CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)most_online, 0); + proto = GetContactProto(most_online); if (proto) { strcpy(buffer, proto); @@ -1315,7 +1313,7 @@ INT_PTR Meta_ContactMenuFunc(WPARAM wParam, LPARAM lParam) { char *proto; char buffer[512]; - proto = (char *)CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)hContact, 0); + proto = GetContactProto(hContact); if (proto) { strcpy(buffer, proto); @@ -1376,7 +1374,7 @@ INT_PTR Meta_FileSend(WPARAM wParam, LPARAM lParam) return 0; } - proto = (char *)CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)most_online, 0); + proto = GetContactProto(most_online); //Meta_CopyContactNick(ccs->hContact, most_online, proto); if (proto) { @@ -1416,7 +1414,7 @@ INT_PTR Meta_GetAwayMsg(WPARAM wParam, LPARAM lParam) { if (!most_online) return 0; - proto = (char *)CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)most_online, 0); + proto = GetContactProto(most_online); if (!proto) return 0; //Meta_CopyContactNick(ccs->hContact, most_online, proto); @@ -1452,7 +1450,7 @@ INT_PTR Meta_GetAvatarInfo(WPARAM wParam, LPARAM lParam) { if (!hSub) return GAIR_NOAVATAR; - proto = (char *)CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)hSub, 0); + proto = GetContactProto(hSub); if (!proto) return GAIR_NOAVATAR; AI->hContact = hSub; @@ -1487,7 +1485,7 @@ INT_PTR Meta_GetInfo(WPARAM wParam, LPARAM lParam) { if (!most_online) return 0; - proto = (char *)CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)most_online, 0); + proto = GetContactProto(most_online); if (!proto) return 0; AI.cbSize = sizeof(AI); diff --git a/plugins/MetaContacts/src/meta_utils.cpp b/plugins/MetaContacts/src/meta_utils.cpp index 3931044812..8df0479440 100644 --- a/plugins/MetaContacts/src/meta_utils.cpp +++ b/plugins/MetaContacts/src/meta_utils.cpp @@ -257,7 +257,7 @@ BOOL Meta_Assign(HANDLE src, HANDLE dest, BOOL set_as_default) MessageBox(0, Translate("Could not retreive MetaContact contact count"), Translate("Assignment Error"), MB_OK | MB_ICONWARNING); return FALSE; } - if (!(proto = (char *)CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)src,0))) { + if (!(proto = GetContactProto(src))) { MessageBox(0, Translate("Could not retreive contact protocol"), Translate("Assignment Error"), MB_OK | MB_ICONWARNING); return FALSE; } @@ -476,7 +476,7 @@ HANDLE Meta_GetMostOnlineSupporting(HANDLE hMeta, int pflagnum, unsigned long ca return NULL; most_online_contact = Meta_GetContactHandle(hMeta, default_contact_number); - proto = (char *)CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)most_online_contact, 0); + proto = GetContactProto(most_online_contact); caps = proto ? CallProtoService(proto, PS_GETCAPS, (WPARAM)pflagnum, 0) : 0; if (proto && strcmp(proto, "IRC") == 0) caps |= PF1_IM; // we are forced to do use default for sending - '-1' capability indicates no specific capability, but respect 'Force Default' @@ -492,7 +492,7 @@ HANDLE Meta_GetMostOnlineSupporting(HANDLE hMeta, int pflagnum, unsigned long ca } most_online_contact = Meta_GetContactHandle(hMeta, default_contact_number); - proto = (char *)CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)most_online_contact, 0); + proto = GetContactProto(most_online_contact); if (proto && CallProtoService(proto, PS_GETSTATUS, 0, 0) >= ID_STATUS_ONLINE) { caps = proto ? CallProtoService(proto, PS_GETCAPS, (WPARAM)pflagnum, 0) : 0; if (proto && strcmp(proto, "IRC") == 0) caps |= PF1_IM; @@ -516,7 +516,7 @@ HANDLE Meta_GetMostOnlineSupporting(HANDLE hMeta, int pflagnum, unsigned long ca continue; hContact = Meta_GetContactHandle(hMeta, i); - proto = (char *)CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)hContact, 0); + proto = GetContactProto(hContact); if (!proto || CallProtoService(proto, PS_GETSTATUS, 0, 0) < ID_STATUS_ONLINE) // proto offline or connecting continue; @@ -607,7 +607,7 @@ BOOL dbv_same(DBVARIANT *dbv1, DBVARIANT *dbv2) { if (hContact) { if (!module) { - used_mod = (char *)CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)hContact, 0); + used_mod = GetContactProto(hContact); if (!used_mod) continue; // next contact } else used_mod = module; @@ -698,7 +698,7 @@ void CopyStatusData(HANDLE hMeta) { else hContact = Meta_GetContactHandle(hMeta, i); - proto = (char *)CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)hContact, 0); + proto = GetContactProto(hContact); if (proto && DBGetContactSettingWord(hContact, proto, "Status", ID_STATUS_OFFLINE) == status) { if (!bDoneStatus && !MyDBGetContactSetting(hContact, "CList", "StatusMsg", &dbv)) { @@ -974,7 +974,7 @@ int Meta_HideLinkedContacts(void) { contact_number = DBGetContactSettingDword(hContact, META_PROTO, "ContactNumber", (DWORD)-1); // prepare to update metacontact record of subcontat status - proto = (char *)CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)hContact, 0); + proto = GetContactProto(hContact); // save old group and move to invisible group (i.e. non-existent group) Meta_SetGroup(hContact); @@ -1184,7 +1184,7 @@ void Meta_SetGroup(HANDLE hContact) { // the existence of this service means that clist_meta_mw is active and will do the hiding for us if (ServiceExists(MS_CLUI_METASUPPORT)) return; - proto = (char *)CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)hContact, 0); + proto = GetContactProto(hContact); if (proto) uid = (char *)CallProtoService(proto, PS_GETCAPS, PFLAG_UNIQUEIDSETTING, 0); @@ -1280,7 +1280,7 @@ int Meta_CopyContactNick(HANDLE hMeta, HANDLE hContact) { if (!hContact) return 1; - //proto = (char *)CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)hContact, 0); + //proto = GetContactProto(hContact); // read proto direct from db, since we do this on load and other proto plugins may not be loaded yet if (!DBGetContactSetting(hContact, "Protocol", "p", &dbv_proto)) { @@ -1636,7 +1636,7 @@ void Meta_RemoveHistory(HANDLE hContactRemoveFrom, HANDLE hContactSource) { } char *Meta_GetUniqueIdentifier(HANDLE hContact, DWORD *pused) { - char *proto = (char *)CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)hContact, 0); + char *proto = GetContactProto(hContact); char *field; char *id; char buff[256]; @@ -1687,7 +1687,7 @@ char *Meta_GetUniqueIdentifier(HANDLE hContact, DWORD *pused) { void Meta_FixStatus(HANDLE hMeta) { HANDLE most_online = Meta_GetMostOnlineSupporting(hMeta, PFLAGNUM_1, 0); if (most_online) { - char *proto = (char *)CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)most_online, 0); + char *proto = GetContactProto(most_online); if (proto) { WORD status = (WORD)DBGetContactSettingWord(most_online, proto, "Status", (WORD)ID_STATUS_OFFLINE); DBWriteContactSettingWord(hMeta, META_PROTO, "Status", status); diff --git a/plugins/MirOTR/MirOTR/src/svcs_proto.cpp b/plugins/MirOTR/MirOTR/src/svcs_proto.cpp index 618034cc10..a681763be6 100644 --- a/plugins/MirOTR/MirOTR/src/svcs_proto.cpp +++ b/plugins/MirOTR/MirOTR/src/svcs_proto.cpp @@ -18,7 +18,7 @@ INT_PTR SVC_OTRSendMessage(WPARAM wParam,LPARAM lParam){ if (ccs->wParam & PREF_BYPASS_OTR) // bypass for OTR-messages return CallService(MS_PROTO_CHAINSEND, wParam, lParam); - char *proto = (char *)CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)ccs->hContact, 0); + char *proto = GetContactProto(ccs->hContact); if(proto && g_metaproto && strcmp(proto, g_metaproto) == 0) // bypass for metacontacts return CallService(MS_PROTO_CHAINSEND, wParam, lParam); if (!proto || !ccs->hContact) return 1; // error @@ -166,7 +166,7 @@ INT_PTR SVC_OTRRecvMessage(WPARAM wParam,LPARAM lParam){ return CallService(MS_PROTO_CHAINRECV, wParam, lParam); } - char *proto = (char *)CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)ccs->hContact, 0); + char *proto = GetContactProto(ccs->hContact); if (!proto) return 1; //error else if(proto && g_metaproto && strcmp(proto, g_metaproto) == 0) // bypass for metacontacts diff --git a/plugins/MirOTR/MirOTR/src/svcs_srmm.cpp b/plugins/MirOTR/MirOTR/src/svcs_srmm.cpp index 707eb0a020..8ad883bfd6 100644 --- a/plugins/MirOTR/MirOTR/src/svcs_srmm.cpp +++ b/plugins/MirOTR/MirOTR/src/svcs_srmm.cpp @@ -39,7 +39,7 @@ int SVC_IconPressed(WPARAM wParam, LPARAM lParam) { return 0; if(strcmp(sicd->szModule, MODULENAME) == 0) { - char *proto = (char *)CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)hContact, 0); + char *proto = GetContactProto(hContact); if(proto && DBGetContactSettingByte(hContact, proto, "ChatRoom", 0)) return 0; ShowOTRMenu(hContact, sicd->clickLocation); @@ -145,7 +145,7 @@ void SetEncryptionStatus(HANDLE hContact, TrustLevel level) { //strcat(dbg_msg, "Set encyption status: "); //strcat(dbg_msg, (encrypted ? "true" : "false")); - char *proto = (char *)CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)hContact, 0); + char *proto = GetContactProto(hContact); bool chat_room = (proto && DBGetContactSettingByte(hContact, proto, "ChatRoom", 0)); // if (!chat_room) DBWriteContactSettingByte(hContact, MODULENAME, "Encrypted", (encrypted ? 1 : 0)); @@ -225,7 +225,7 @@ int SVC_ButtonsBarPressed(WPARAM w, LPARAM l) { if (cbcd->cbSize == (int)sizeof(CustomButtonClickData) && cbcd->dwButtonId == 0 && strcmp(cbcd->pszModule, MODULENAME)==0) { HANDLE hContact = (HANDLE)w; - char *proto = (char *)CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)hContact, 0); + char *proto = GetContactProto(hContact); if(proto && DBGetContactSettingByte(hContact, proto, "ChatRoom", 0)) return 0; ShowOTRMenu(hContact, cbcd->pt); diff --git a/plugins/MirOTR/MirOTR/src/utils.cpp b/plugins/MirOTR/MirOTR/src/utils.cpp index ce2bbc5b9a..ea9b55b619 100644 --- a/plugins/MirOTR/MirOTR/src/utils.cpp +++ b/plugins/MirOTR/MirOTR/src/utils.cpp @@ -144,7 +144,7 @@ __inline const TCHAR* contact_get_nameT(HANDLE hContact) { } __inline const char* contact_get_proto(HANDLE hContact) { - char *uproto = (char *)CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)hContact, 0); + char *uproto = GetContactProto(hContact); return uproto; } @@ -367,7 +367,7 @@ void ShowMessage(const HANDLE hContact, const TCHAR *msg) { /* bool GetEncryptionStatus(HANDLE hContact) { - char *proto = (char *)CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)hContact, 0); + char *proto = GetContactProto(hContact); bool chat_room = (proto && DBGetContactSettingByte(hContact, proto, "ChatRoom", 0)); if (!chat_room) { diff --git a/plugins/MobileState/src/main.cpp b/plugins/MobileState/src/main.cpp index f0c3bc77e9..743dfbe0e8 100644 --- a/plugins/MobileState/src/main.cpp +++ b/plugins/MobileState/src/main.cpp @@ -53,7 +53,7 @@ extern "C" __declspec(dllexport) PLUGININFOEX* MirandaPluginInfoEx(DWORD miranda bool hasMobileClient(HANDLE hContact, LPARAM lParam) { - char *proto = (char *)CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)hContact, 0); + char *proto = GetContactProto(hContact); DBVARIANT dbv; if (!DBGetContactSettingTString(hContact, proto, "MirVer", &dbv)) { @@ -83,7 +83,7 @@ int ExtraIconsApply(WPARAM wParam, LPARAM lParam) int onContactSettingChanged(WPARAM wParam,LPARAM lParam) { DBCONTACTWRITESETTING *cws=(DBCONTACTWRITESETTING*)lParam; - char *proto = (char *)CallService(MS_PROTO_GETCONTACTBASEPROTO, wParam, 0); + char *proto = GetContactProto((HANDLE)wParam); if (!proto) return 0; diff --git a/plugins/NewEventNotify/src/main.cpp b/plugins/NewEventNotify/src/main.cpp index 9bc102a96c..4719ef820d 100644 --- a/plugins/NewEventNotify/src/main.cpp +++ b/plugins/NewEventNotify/src/main.cpp @@ -240,7 +240,7 @@ int CheckMsgWnd(HANDLE hContact) char *szProto; TCHAR *contactName, *szStatus; - szProto = (char*)CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)hContact, 0); + szProto = GetContactProto(hContact); contactName = (TCHAR*)CallService(MS_CLIST_GETCONTACTDISPLAYNAME, (WPARAM)hContact, GCDNF_TCHAR); szStatus = (TCHAR*)CallService(MS_CLIST_GETSTATUSMODEDESCRIPTION, szProto?DBGetContactSettingWord(hContact,szProto,"Status",ID_STATUS_OFFLINE):ID_STATUS_OFFLINE, GSMDF_TCHAR); diff --git a/plugins/NewXstatusNotify/src/indsnd.cpp b/plugins/NewXstatusNotify/src/indsnd.cpp index 573b631648..f516f44e02 100644 --- a/plugins/NewXstatusNotify/src/indsnd.cpp +++ b/plugins/NewXstatusNotify/src/indsnd.cpp @@ -119,7 +119,7 @@ INT_PTR CALLBACK DlgProcSoundUIPage(HWND hwndDlg, UINT msg, WPARAM wParam, LPARA TranslateDialogDefault(hwndDlg); hContact = (HANDLE)lParam; - char *szProto = (char *)CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)hContact, 0); + char *szProto = GetContactProto(hContact); HWND hList = GetDlgItem(hwndDlg, IDC_INDSNDLIST); ListView_SetImageList(hList, GetStatusIconsImgList(szProto), LVSIL_SMALL); @@ -377,7 +377,7 @@ void SetAllContactsIcons(HWND hwndList) HANDLE hItem = (HANDLE)SendMessage(hwndList, CLM_FINDCONTACT, (WPARAM)hContact, 0); if (hItem) { - char *szProto = (char *)CallService(MS_PROTO_GETCONTACTBASEPROTO,(WPARAM)hContact,0); + char *szProto = GetContactProto(hContact); if (szProto) { EnableSounds = db_get_b(hContact, MODULE, "EnableSounds", 1); diff --git a/plugins/NewXstatusNotify/src/main.cpp b/plugins/NewXstatusNotify/src/main.cpp index ff58ca697f..dc590828b1 100644 --- a/plugins/NewXstatusNotify/src/main.cpp +++ b/plugins/NewXstatusNotify/src/main.cpp @@ -70,7 +70,7 @@ extern "C" __declspec(dllexport) const MUUID MirandaInterfaces[] = {MIID_USERONL BYTE GetGender(HANDLE hContact) { - char *szProto =(char *)CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)hContact, 0); + char *szProto =GetContactProto(hContact); if (szProto) { switch (db_get_b(hContact, szProto, "Gender", 0)) { case 'M': case 'm': @@ -108,7 +108,7 @@ bool IsNewExtraStatus(HANDLE hContact, char *szSetting, TCHAR *newStatusTitle) int ProcessExtraStatus(DBCONTACTWRITESETTING *cws, HANDLE hContact) { XSTATUSCHANGE *xsc; - char *szProto = (char *)CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)hContact, 0); + char *szProto = GetContactProto(hContact); if ( ProtoServiceExists(szProto, JS_PARSE_XMPP_URI)) { if (cws->value.type == DBVT_DELETED) @@ -472,7 +472,7 @@ int ProcessStatus(DBCONTACTWRITESETTING *cws, HANDLE hContact) if (!db_get_b(NULL, MODULE, dbSetting, 1)) return 0; } - smi.proto = (char*)CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)hContact, 0); + smi.proto = GetContactProto(hContact); //don't show popup when mradio connecting and disconnecting if (_stricmp(smi.proto, "mRadio") == 0 && !cws->value.type == DBVT_DELETED) { @@ -565,7 +565,7 @@ int ContactSettingChanged(WPARAM wParam, LPARAM lParam) if (hContact == NULL) return 0; - char *szProto = (char *)CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)hContact, 0); + char *szProto = GetContactProto(hContact); if (szProto == NULL) return 0; @@ -776,7 +776,7 @@ int ContactStatusChanged(WPARAM wParam, LPARAM lParam) char buff[8], szProto[64], szSubProto[64]; bool bEnablePopup = true, bEnableSound = true; - char *hlpProto = (char *)CallService(MS_PROTO_GETCONTACTBASEPROTO, wParam, 0); + char *hlpProto = GetContactProto((HANDLE)wParam); if (hlpProto == NULL || opt.TempDisabled) return 0; @@ -785,7 +785,7 @@ int ContactStatusChanged(WPARAM wParam, LPARAM lParam) if (strcmp(szProto, szMetaModuleName) == 0) { //this contact is Meta HANDLE hSubContact = (HANDLE)CallService(MS_MC_GETMOSTONLINECONTACT, (WPARAM)hContact, 0); - strcpy(szSubProto, (char *)CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)hSubContact,0)); + strcpy(szSubProto, GetContactProto(hSubContact)); if (newStatus == ID_STATUS_OFFLINE) { // read last online proto for metaconatct if exists, diff --git a/plugins/NewXstatusNotify/src/popup.cpp b/plugins/NewXstatusNotify/src/popup.cpp index be7c39fd1c..7d6f1d9672 100644 --- a/plugins/NewXstatusNotify/src/popup.cpp +++ b/plugins/NewXstatusNotify/src/popup.cpp @@ -29,7 +29,7 @@ extern OPTIONS opt; void QueryAwayMessage(HWND hWnd, PLUGINDATA *pdp) { HANDLE hContact = PUGetContact(hWnd); - char *szProto = (char *)CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)hContact, 0); + char *szProto = GetContactProto(hContact); if (szProto) { if ((CallProtoService(szProto, PS_GETCAPS,PFLAGNUM_1, 0) & PF1_MODEMSGRECV) && @@ -154,7 +154,7 @@ INT_PTR CALLBACK PopupDlgProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lPa case UM_INITPOPUP: pdp = (PLUGINDATA *)PUGetPluginData(hwnd); if (pdp != NULL) { - char *szProto = (char *)CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)PUGetContact(hwnd), 0); + char *szProto = GetContactProto( PUGetContact(hwnd)); if (szProto && opt.ReadAwayMsg && StatusHasAwayMessage(szProto, pdp->newStatus)) { WORD myStatus = (WORD)CallProtoService(szProto, PS_GETSTATUS, 0, 0); if (myStatus != ID_STATUS_INVISIBLE) diff --git a/plugins/NewXstatusNotify/src/xstatus.cpp b/plugins/NewXstatusNotify/src/xstatus.cpp index bc2bb541e6..48897840dc 100644 --- a/plugins/NewXstatusNotify/src/xstatus.cpp +++ b/plugins/NewXstatusNotify/src/xstatus.cpp @@ -438,7 +438,7 @@ void AddEventThread(void *arg) HANDLE hContact = (HANDLE)arg; TCHAR stzTitle[MAX_TITLE_LEN], stzText[MAX_TEXT_LEN]; - char *szProto = (char *)CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)hContact, 0); + char *szProto = GetContactProto(hContact); if (szProto == NULL) return; diff --git a/plugins/New_GPG/src/messages.cpp b/plugins/New_GPG/src/messages.cpp index abc1a624ec..db17333da6 100755 --- a/plugins/New_GPG/src/messages.cpp +++ b/plugins/New_GPG/src/messages.cpp @@ -568,11 +568,9 @@ int RecvMsgSvc(WPARAM w, LPARAM l) } else if(!isContactHaveKey(ccs->hContact) && bAutoExchange && gpg_valid && gpg_keyexist) { - LPSTR proto = (LPSTR)CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)ccs->hContact, 0); + char *proto = GetContactProto(ccs->hContact); DWORD uin = DBGetContactSettingDword(ccs->hContact, proto, "UIN", 0); - if(uin) - { - char *proto = (char*)CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)ccs->hContact, 0); + if(uin) { char svc[64]; strcpy(svc, proto); strcat(svc, PS_ICQ_CHECKCAPABILITY); @@ -841,11 +839,11 @@ int SendMsgSvc(WPARAM w, LPARAM l) if(bAutoExchange && !strstr(msg, "-----PGP KEY REQUEST-----") && !strstr(msg, "-----BEGIN PGP PUBLIC KEY BLOCK-----") && gpg_valid) { void send_encrypted_msgs_thread(HANDLE hContact); - LPSTR proto = (LPSTR)CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)ccs->hContact, 0); + LPSTR proto = GetContactProto(ccs->hContact); DWORD uin = DBGetContactSettingDword(ccs->hContact, proto, "UIN", 0); if(uin) { - char *proto = (char*)CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)ccs->hContact, 0); + char *proto = GetContactProto(ccs->hContact); char svc[64]; strcpy(svc, proto); strcat(svc, PS_ICQ_CHECKCAPABILITY); diff --git a/plugins/New_GPG/src/metacontacts.cpp b/plugins/New_GPG/src/metacontacts.cpp index 1abc2aaeac..ab3c60bce5 100755 --- a/plugins/New_GPG/src/metacontacts.cpp +++ b/plugins/New_GPG/src/metacontacts.cpp @@ -21,7 +21,7 @@ extern bool bMetaContacts; bool metaIsProtoMetaContacts(HANDLE hContact) { if(bMetaContacts) { - LPSTR proto = (LPSTR)CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)hContact, 0); + LPSTR proto = GetContactProto(hContact); if( proto && strcmp(proto,"MetaContacts")==0 ) { return true; } diff --git a/plugins/New_GPG/src/options.cpp b/plugins/New_GPG/src/options.cpp index add9e9566c..8b9f32d58c 100755 --- a/plugins/New_GPG/src/options.cpp +++ b/plugins/New_GPG/src/options.cpp @@ -156,7 +156,7 @@ static INT_PTR CALLBACK DlgProcGpgOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LP item.pszText = name; iRow = ListView_InsertItem(hwndList, &item); ListView_SetItemText(hwndList, iRow, 0, name); - TCHAR *tmp = mir_a2t((char*)CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)hContact, 0)); + TCHAR *tmp = mir_a2t(GetContactProto(hContact)); ListView_SetItemText(hwndList, iRow, 4, tmp); mir_free(tmp); tmp2 = UniGetContactSettingUtf(hContact, szGPGModuleName, "KeyID", ""); diff --git a/plugins/New_GPG/src/utilities.cpp b/plugins/New_GPG/src/utilities.cpp index f0a8e7a387..f872bd5e7f 100755 --- a/plugins/New_GPG/src/utilities.cpp +++ b/plugins/New_GPG/src/utilities.cpp @@ -146,7 +146,7 @@ INT_PTR SendKey(WPARAM w, LPARAM l) hContact = metaGetMostOnline(hContact); char *szMessage; { - LPSTR proto = (LPSTR)CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)hContact, 0); + LPSTR proto = GetContactProto(hContact); PROTOACCOUNT *acc = (PROTOACCOUNT*)CallService(MS_PROTO_GETACCOUNT, 0, (LPARAM)proto); std::string acc_str; if(acc) @@ -1165,7 +1165,7 @@ int SendBroadcast( HANDLE hContact, int type, int result, HANDLE hProcess, LPARA ACKDATA ack; memset(&ack,0,sizeof(ack)); ack.cbSize = sizeof( ACKDATA ); - ack.szModule = szGPGModuleName;// (char*)CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)hContact, 0); + ack.szModule = szGPGModuleName;// GetContactProto(hContact); ack.hContact = hContact; ack.type = type; ack.result = result; @@ -1334,7 +1334,7 @@ INT_PTR ExportGpGKeys(WPARAM w, LPARAM l) std::string key = k; mir_free(k); - const char* proto = (const char*)CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)hContact, 0); + const char* proto = (const char*)GetContactProto(hContact); std::string id = "Comment: login "; const char * uid = (const char*)CallProtoService(proto, PS_GETCAPS, (WPARAM)PFLAG_UNIQUEIDSETTING, 0); DBVARIANT dbv = {0}; diff --git a/plugins/NoHistory/src/dllmain.cpp b/plugins/NoHistory/src/dllmain.cpp index 2a76dc620a..a1bb09e6ed 100644 --- a/plugins/NoHistory/src/dllmain.cpp +++ b/plugins/NoHistory/src/dllmain.cpp @@ -161,7 +161,7 @@ int PrebuildContactMenu(WPARAM wParam, LPARAM lParam) { HANDLE hContact = (HANDLE)wParam; bool remove = (DBGetContactSettingByte(hContact, MODULE, DBSETTING_REMOVE, 0) != 0); - char *proto = (char *)CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)hContact, 0); + char *proto = GetContactProto(hContact); bool chat_room = (proto && DBGetContactSettingByte(hContact, proto, "ChatRoom", 0) != 0); CLISTMENUITEM mi = {0}; @@ -227,7 +227,7 @@ int WindowEvent(WPARAM wParam, LPARAM lParam) { if(!ServiceExists(MS_MSG_MODIFYICON)) return 0; - char *proto = (char *)CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)hContact, 0); + char *proto = GetContactProto(hContact); bool chat_room = (proto && DBGetContactSettingByte(hContact, proto, "ChatRoom", 0) != 0); @@ -263,7 +263,7 @@ int IconPressed(WPARAM wParam, LPARAM lParam) { if(sicd->flags & MBCF_RIGHTBUTTON) return 0; // ignore right-clicks if(strcmp(sicd->szModule, MODULE) != 0) return 0; // not our event - char *proto = (char *)CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)hContact, 0); + char *proto = GetContactProto(hContact); bool chat_room = (proto && DBGetContactSettingByte(hContact, proto, "ChatRoom", 0) != 0); if(!chat_room) ServiceToggle((WPARAM)hContact, 0); diff --git a/plugins/NoHistory/src/options.cpp b/plugins/NoHistory/src/options.cpp index 45b2c876eb..567e135409 100644 --- a/plugins/NoHistory/src/options.cpp +++ b/plugins/NoHistory/src/options.cpp @@ -74,7 +74,7 @@ static void SetAllContactIcons(HWND hwndList) { HANDLE hContact = db_find_first(); do { - char *proto = (char *)CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)hContact, 0); + char *proto = GetContactProto(hContact); bool chat_room = (proto && DBGetContactSettingByte(hContact, proto, "ChatRoom", 0) != 0); if(!chat_room) { @@ -198,7 +198,7 @@ static INT_PTR CALLBACK DlgProcOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARA { HANDLE hContact = db_find_first(); do { - char *proto = (char *)CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)hContact, 0); + char *proto = GetContactProto(hContact); bool chat_room = (proto && DBGetContactSettingByte(hContact, proto, "ChatRoom", 0) != 0); if(!chat_room) { diff --git a/plugins/Nudge/src/main.cpp b/plugins/Nudge/src/main.cpp index 56a7c3e6c0..ab9442c524 100644 --- a/plugins/Nudge/src/main.cpp +++ b/plugins/Nudge/src/main.cpp @@ -36,21 +36,16 @@ PLUGININFOEX pluginInfo={ INT_PTR NudgeShowMenu(WPARAM wParam,LPARAM lParam) { - for(NudgeElementList *n = NudgeList;n != NULL; n = n->next) - { if (!strcmp((char *) wParam,n->item.ProtocolName)) - { return n->item.ShowContactMenu(lParam != 0); - } - } + return 0; } INT_PTR NudgeSend(WPARAM wParam,LPARAM lParam) { - - char *protoName = (char*) CallService(MS_PROTO_GETCONTACTBASEPROTO,wParam,0); + char *protoName = GetContactProto((HANDLE)wParam); int diff = time(NULL) - DBGetContactSettingDword((HANDLE) wParam, "Nudge", "LastSent", time(NULL)-30); if(diff < GlobalNudge.sendTimeSec) @@ -113,7 +108,7 @@ void OpenContactList() int NudgeRecieved(WPARAM wParam,LPARAM lParam) { - char *protoName = (char*) CallService(MS_PROTO_GETCONTACTBASEPROTO,wParam,0); + char *protoName = GetContactProto((HANDLE)wParam); DWORD currentTimestamp = time(NULL); DWORD nudgeSentTimestamp = lParam ? (DWORD)lParam : currentTimestamp; @@ -418,7 +413,7 @@ static int TabsrmmButtonInit(WPARAM wParam, LPARAM lParam) void HideNudgeButton(HANDLE hContact) { char str[MAXMODULELABELLENGTH + 12] = {0}; - char *szProto = (char*) CallService(MS_PROTO_GETCONTACTBASEPROTO,(WPARAM)hContact,0); + char *szProto = GetContactProto(hContact); mir_snprintf(str,MAXMODULELABELLENGTH + 12,"%s/SendNudge", szProto); if (!ServiceExists(str)) @@ -654,7 +649,7 @@ void Nudge_SentStatus(CNudgeElement n, HANDLE hContact) DBEVENTINFO NudgeEvent = { 0 }; NudgeEvent.cbSize = sizeof(NudgeEvent); - NudgeEvent.szModule = (char*)CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)hContact, 0); + NudgeEvent.szModule = GetContactProto(hContact); char *buff = mir_utf8encodeT(n.senText); NudgeEvent.flags = DBEF_SENT | DBEF_UTF; @@ -681,7 +676,7 @@ void Nudge_ShowStatus(CNudgeElement n, HANDLE hContact, DWORD timestamp) DBEVENTINFO NudgeEvent = { 0 }; NudgeEvent.cbSize = sizeof(NudgeEvent); - NudgeEvent.szModule = (char*)CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)hContact, 0); + NudgeEvent.szModule = GetContactProto(hContact); char *buff = mir_utf8encodeT(n.recText); NudgeEvent.flags = DBEF_UTF; diff --git a/plugins/PasteIt/src/PasteIt.cpp b/plugins/PasteIt/src/PasteIt.cpp index ce38743f68..e2164c2492 100644 --- a/plugins/PasteIt/src/PasteIt.cpp +++ b/plugins/PasteIt/src/PasteIt.cpp @@ -131,7 +131,7 @@ void PasteIt(HANDLE hContact, int mode) } else if(hContact != NULL && pasteToWeb->szFileLink[0] != 0) { - char *szProto = (char *)CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)hContact, 0); + char *szProto = GetContactProto(hContact); if (szProto && (INT_PTR)szProto != CALLSERVICE_NOTFOUND) { BOOL isChat = DBGetContactSettingByte(hContact, szProto, "ChatRoom", 0); @@ -336,7 +336,7 @@ int PrebuildContactMenu(WPARAM wParam, LPARAM lParam) { bool bIsContact = false; - char *szProto = (char *)CallService(MS_PROTO_GETCONTACTBASEPROTO, wParam, 0); + char *szProto = GetContactProto((HANDLE)wParam); if (szProto && (INT_PTR)szProto != CALLSERVICE_NOTFOUND) bIsContact = (CallProtoService(szProto, PS_GETCAPS, PFLAGNUM_1, 0) & PF1_IM) ? true : false; CLISTMENUITEM mi = {0}; @@ -472,7 +472,7 @@ int WindowEvent(WPARAM wParam, MessageWindowEventData* lParam) { if(lParam->uType == MSG_WINDOW_EVT_OPEN) { - char *szProto = (char *)CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)lParam->hContact, 0); + char *szProto = GetContactProto(lParam->hContact); if (szProto && (INT_PTR)szProto != CALLSERVICE_NOTFOUND) { if(DBGetContactSettingByte(lParam->hContact, szProto, "ChatRoom", 0)) diff --git a/plugins/Popup/src/popup_wnd2.cpp b/plugins/Popup/src/popup_wnd2.cpp index 74ff137c79..6ff98aba12 100644 --- a/plugins/Popup/src/popup_wnd2.cpp +++ b/plugins/Popup/src/popup_wnd2.cpp @@ -616,10 +616,8 @@ void PopupWnd2::fixDefaults() m_hContactPassed = m_hContact; if (m_hContact) - { - if (!CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)m_hContact, 0)) + if (!GetContactProto(m_hContact)) m_hContact = NULL; - } switch (m_textType) { @@ -653,10 +651,7 @@ void PopupWnd2::fixAvatar() int PopupWnd2::fixActions(POPUPACTION *theActions, int count) { - bool isIm = (m_hContact && - (CallProtoService( - (char *)CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)m_hContact, 0), - PS_GETCAPS, PFLAGNUM_1, 0) & PF1_IM)) ? true : false; + bool isIm = (m_hContact && (CallProtoService(GetContactProto(m_hContact), PS_GETCAPS, PFLAGNUM_1, 0) & PF1_IM)) ? true : false; // bool enableDefault = (isIm || !(PopUpOptions.actions&ACT_DEF_IMONLY)) ? true : false; bool enableDefaultGen = (m_hContact || !(PopUpOptions.actions&ACT_DEF_NOGLOBAL)) ? true : false; @@ -1042,7 +1037,7 @@ struct ReplyEditData bool IsMsgServiceNameW(HANDLE hContact) { if (g_popup.isMirUnicode) { char szServiceName[100]; - char *szProto = (char *) CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM) hContact, 0); + char *szProto = GetContactProto(hContact); if (szProto == NULL) return false; @@ -1055,13 +1050,13 @@ bool IsMsgServiceNameW(HANDLE hContact) { BOOL IsUtfSendAvailable(HANDLE hContact) { - char* szProto = (char *) CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM) hContact, 0); + char* szProto = GetContactProto(hContact); if(szProto == NULL) return FALSE; //check for MetaContact and get szProto from subcontact if(strcmp(szProto, gszMetaProto)==0) { HANDLE hSubContact = (HANDLE)CallService(MS_MC_GETDEFAULTCONTACT, (WPARAM)hContact, 0); if (!hSubContact) return FALSE; - szProto = (char *) CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM) hSubContact, 0); + szProto = GetContactProto(hSubContact); } return(CallProtoService(szProto, PS_GETCAPS, PFLAGNUM_4, 0) & PF4_IMSENDUTF) ? TRUE : FALSE; } @@ -1072,7 +1067,7 @@ void AddMessageToDB(HANDLE hContact, char *msg, int flag/*bool utf*/) dbei.cbSize = sizeof(dbei); dbei.eventType = EVENTTYPE_MESSAGE; dbei.flags = DBEF_SENT | ((flag&PREF_UTF)==PREF_UTF ? DBEF_UTF : 0); - dbei.szModule = (char *)CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)hContact, 0); + dbei.szModule = GetContactProto(hContact); dbei.timestamp = time(NULL); if(g_popup.isOsUnicode && !((flag&PREF_UTF)==PREF_UTF) && (flag&PREF_UNICODE)==PREF_UNICODE) dbei.cbBlob = (lstrlenW((LPWSTR)msg) + 1)*sizeof(WCHAR/*TCHAR*/); diff --git a/plugins/Popup/src/services.cpp b/plugins/Popup/src/services.cpp index d0c98c9903..c74bcbbe55 100644 --- a/plugins/Popup/src/services.cpp +++ b/plugins/Popup/src/services.cpp @@ -254,7 +254,7 @@ INT_PTR PopUp_AddPopUp2(WPARAM wParam, LPARAM lParam) // Check if contact handle is valid. char *proto = NULL; if (ppd->lchContact) - proto = (char *)CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)ppd->lchContact, 0); + proto = GetContactProto(ppd->lchContact); BYTE bShowMode = proto ? DBGetContactSettingByte(ppd->lchContact, MODULNAME, "ShowMode", PU_SHOWMODE_AUTO) : PU_SHOWMODE_AUTO; @@ -292,7 +292,7 @@ INT_PTR PopUp_AddPopUp2(WPARAM wParam, LPARAM lParam) if (proto) { char prefix[128]; - mir_snprintf(prefix, sizeof(prefix), "Protocol Status/%s", (char *)CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)ppd->lchContact, 0)); + mir_snprintf(prefix, sizeof(prefix), "Protocol Status/%s", GetContactProto(ppd->lchContact)); if (DBGetContactSettingDword(NULL, MODULNAME, prefix, 0) & Proto_Status2Flag_My(CallProtoService(proto, PS_GETSTATUS, 0, 0))) return -1; diff --git a/plugins/QuickContacts/src/quickcontacts.cpp b/plugins/QuickContacts/src/quickcontacts.cpp index de2424ac0c..3860e7a494 100644 --- a/plugins/QuickContacts/src/quickcontacts.cpp +++ b/plugins/QuickContacts/src/quickcontacts.cpp @@ -345,7 +345,7 @@ void SortArray(void) int GetStatus(HANDLE hContact, char *proto = NULL) { if (proto == NULL) - proto = (char *) CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM) hContact, 0); + proto = GetContactProto(hContact); if (proto == NULL) return ID_STATUS_OFFLINE; @@ -380,7 +380,7 @@ void LoadContacts(HWND hwndDlg, BOOL show_all) hContact != NULL; hContact = db_find_next(hContact)) { - char *pszProto = (char *) CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)hContact, 0); + char *pszProto = GetContactProto(hContact); if(pszProto != NULL) { // Get meta @@ -510,7 +510,7 @@ void EnableButtons(HWND hwndDlg, HANDLE hContact) // Get caps INT_PTR caps = 0; - char *pszProto = (char *) CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)hContact, 0); + char *pszProto = GetContactProto(hContact); if (pszProto != NULL) caps = CallProtoService(pszProto, PS_GETCAPS, PFLAGNUM_1, 0); diff --git a/plugins/QuickMessages/src/Utils.cpp b/plugins/QuickMessages/src/Utils.cpp index 28611d2c7c..81f267ffe3 100644 --- a/plugins/QuickMessages/src/Utils.cpp +++ b/plugins/QuickMessages/src/Utils.cpp @@ -475,7 +475,7 @@ TCHAR* ParseString(HANDLE hContact,TCHAR* ptszQValIn,TCHAR* ptszText,TCHAR* ptsz int NameLenght=0; TCHAR* ptszName=NULL; - ptszName=mir_a2u((char*)CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)hContact, 0)); + ptszName=mir_a2u(GetContactProto(hContact)); NameLenght=(int)_tcslen(ptszName); @@ -539,7 +539,7 @@ TCHAR* ParseString(HANDLE hContact,TCHAR* ptszQValIn,TCHAR* ptszText,TCHAR* ptsz ci.dwFlag =CNF_FIRSTNAME|CNF_UNICODE; - ci.szProto=(char*)CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)hContact, 0); + ci.szProto=GetContactProto(hContact); if (!CallService(MS_CONTACT_GETCONTACTINFO,0,(LPARAM)&ci)&&ci.pszVal){ NameLenght=(int)_tcslen(ci.pszVal); ptszName=ci.pszVal; @@ -573,7 +573,7 @@ TCHAR* ParseString(HANDLE hContact,TCHAR* ptszQValIn,TCHAR* ptszText,TCHAR* ptsz ZeroMemory(&ci,sizeof(CONTACTINFO)); ci.cbSize = sizeof(CONTACTINFO); ci.hContact = hContact; - ci.szProto=(char*)CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)hContact, 0); + ci.szProto=GetContactProto(hContact); ci.dwFlag =CNF_LASTNAME|CNF_UNICODE; diff --git a/plugins/RecentContacts/src/RecentContacts.cpp b/plugins/RecentContacts/src/RecentContacts.cpp index a22cff3b6a..2e1b0b409e 100644 --- a/plugins/RecentContacts/src/RecentContacts.cpp +++ b/plugins/RecentContacts/src/RecentContacts.cpp @@ -246,7 +246,7 @@ INT_PTR CALLBACK ShowListMainDlgProc(HWND hDlg, UINT msg, WPARAM wParam, LPARAM continue; if (LastUCOpt.HideOffline == 1) { - szProto = (char*)CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)curContact->second, 0); + szProto = GetContactProto(curContact->second); if (szProto != NULL && DBGetContactSettingWord((HANDLE)curContact->second, szProto, "Status", ID_STATUS_OFFLINE) == ID_STATUS_OFFLINE) continue; } diff --git a/plugins/Scriver/src/chat/clist.cpp b/plugins/Scriver/src/chat/clist.cpp index 34205bfb4a..836277f933 100644 --- a/plugins/Scriver/src/chat/clist.cpp +++ b/plugins/Scriver/src/chat/clist.cpp @@ -91,7 +91,7 @@ END_GROUPLOOP: BOOL CList_SetOffline(HANDLE hContact, BOOL bHide) { if ( hContact ) { - char * szProto = (char *) CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM) hContact, 0); + char * szProto = GetContactProto(hContact); DBWriteContactSettingWord(hContact, szProto,"ApparentMode",(LPARAM) 0); DBWriteContactSettingWord(hContact, szProto, "Status", ID_STATUS_OFFLINE); return TRUE; @@ -104,7 +104,7 @@ BOOL CList_SetAllOffline(BOOL bHide, const char *pszModule) { HANDLE hContact = db_find_first(); while ( hContact ) { - char *szProto = (char *) CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM) hContact, 0); + char *szProto = GetContactProto(hContact); if ( MM_FindModule( szProto )) { if (!pszModule || (pszModule && !strcmp(pszModule, szProto))) { int i = DBGetContactSettingByte(hContact, szProto, "ChatRoom", 0); @@ -128,7 +128,7 @@ int CList_RoomDoubleclicked(WPARAM wParam,LPARAM lParam) if (!hContact) return 0; - szProto = (char *) CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM) hContact, 0); + szProto = GetContactProto(hContact); if ( MM_FindModule(szProto)) { if (DBGetContactSettingByte(hContact, szProto, "ChatRoom", 0) == 0) return 0; @@ -170,7 +170,7 @@ INT_PTR CList_JoinChat(WPARAM wParam, LPARAM lParam) { HANDLE hContact = (HANDLE)wParam; if ( hContact ) { - char* szProto = (char*)CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM) hContact, 0); + char* szProto = GetContactProto(hContact); if ( szProto ) { if ( DBGetContactSettingWord( hContact, szProto, "Status", 0 ) == ID_STATUS_OFFLINE ) CallProtoService( szProto, PS_JOINCHAT, wParam, lParam ); @@ -185,7 +185,7 @@ INT_PTR CList_LeaveChat(WPARAM wParam, LPARAM lParam) { HANDLE hContact = (HANDLE)wParam; if ( hContact ) { - char* szProto = (char*)CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM) hContact, 0); + char* szProto = GetContactProto(hContact); if ( szProto ) CallProtoService( szProto, PS_LEAVECHAT, wParam, lParam ); } @@ -196,7 +196,7 @@ int CList_PrebuildContactMenu(WPARAM wParam, LPARAM lParam) { HANDLE hContact = (HANDLE)wParam; if ( hContact ) { - char* szProto = (char*)CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM) hContact, 0); + char* szProto = GetContactProto(hContact); CLISTMENUITEM clmi = {0}; clmi.cbSize = sizeof(CLISTMENUITEM); diff --git a/plugins/Scriver/src/globals.cpp b/plugins/Scriver/src/globals.cpp index 113cf79437..1c71dbb959 100644 --- a/plugins/Scriver/src/globals.cpp +++ b/plugins/Scriver/src/globals.cpp @@ -475,7 +475,7 @@ static int ackevent(WPARAM wParam, LPARAM lParam) { dbei.flags = DBEF_SENT | (( item->flags & PREF_RTL) ? DBEF_RTL : 0 ); if ( item->flags & PREF_UTF ) dbei.flags |= DBEF_UTF; - dbei.szModule = (char *) CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM) item->hContact, 0); + dbei.szModule = GetContactProto(item->hContact); dbei.timestamp = time(NULL); dbei.cbBlob = lstrlenA(item->sendBuffer) + 1; if ( !( item->flags & PREF_UTF )) diff --git a/plugins/Scriver/src/msgdialog.cpp b/plugins/Scriver/src/msgdialog.cpp index b4a27aa27d..757f74aaa5 100644 --- a/plugins/Scriver/src/msgdialog.cpp +++ b/plugins/Scriver/src/msgdialog.cpp @@ -164,7 +164,7 @@ void NotifyLocalWinEvent(HANDLE hContact, HWND hwnd, unsigned int type) { static BOOL IsUtfSendAvailable(HANDLE hContact) { - char* szProto = (char *) CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM) hContact, 0); + char* szProto = GetContactProto(hContact); if ( szProto == NULL ) return FALSE; @@ -264,11 +264,10 @@ void SetStatusIcon(struct SrmmWindowData *dat) { if ((INT_PTR)szMetaProto != CALLSERVICE_NOTFOUND && strcmp(dat->szProto, szMetaProto) == 0 && DBGetContactSettingByte(NULL,"CLC","Meta",0) == 0) { hContact = (HANDLE)CallService(MS_MC_GETMOSTONLINECONTACT,(WPARAM)dat->windowData.hContact, 0); - if (hContact != NULL) { - szProto = (char*)CallService(MS_PROTO_GETCONTACTBASEPROTO,(WPARAM)hContact,0); - } else { + if (hContact != NULL) + szProto = GetContactProto(hContact); + else hContact = dat->windowData.hContact; - } } Skin_ReleaseIcon(dat->statusIcon); @@ -767,7 +766,7 @@ INT_PTR CALLBACK DlgProcMessage(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lP dat->hwndParent = GetParent(hwndDlg); dat->parent = (ParentWindowData *) GetWindowLongPtr(dat->hwndParent, GWLP_USERDATA); dat->windowData.hwndLog = NULL; - dat->szProto = (char *) CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM) dat->windowData.hContact, 0); + dat->szProto = GetContactProto(dat->windowData.hContact); dat->avatarPic = 0; if (dat->windowData.hContact && dat->szProto != NULL) dat->wStatus = DBGetContactSettingWord(dat->windowData.hContact, dat->szProto, "Status", ID_STATUS_OFFLINE); @@ -1889,7 +1888,7 @@ INT_PTR CALLBACK DlgProcMessage(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lP if (dat->szProto!=NULL && strcmp(dat->szProto,"MetaContacts")==0) { HANDLE hContact = (HANDLE) CallService(MS_MC_GETMOSTONLINECONTACT, (WPARAM) dat->windowData.hContact, 0); if (hContact!=NULL) { - smaddInfo.Protocolname = (char*) CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)hContact, 0); + smaddInfo.Protocolname = GetContactProto(hContact); } } GetWindowRect(GetDlgItem(hwndDlg, IDC_SMILEYS), &rc); diff --git a/plugins/Scriver/src/msglog.cpp b/plugins/Scriver/src/msglog.cpp index bb768cbb95..6c610bd0cd 100644 --- a/plugins/Scriver/src/msglog.cpp +++ b/plugins/Scriver/src/msglog.cpp @@ -1087,7 +1087,7 @@ void StreamInEvents(HWND hwndDlg, HANDLE hDbEventFirst, int count, int fAppend) if (dat->szProto!=NULL && strcmp(dat->szProto,"MetaContacts")==0) { HANDLE hContact = (HANDLE) CallService(MS_MC_GETMOSTONLINECONTACT, (WPARAM) dat->windowData.hContact, 0); if (hContact!=NULL) { - smre.Protocolname = (char*) CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)hContact, 0); + smre.Protocolname = GetContactProto(hContact); } } if (fi.chrg.cpMin > 0) { diff --git a/plugins/Scriver/src/msgs.cpp b/plugins/Scriver/src/msgs.cpp index 7708b6c1c0..1a9450776e 100644 --- a/plugins/Scriver/src/msgs.cpp +++ b/plugins/Scriver/src/msgs.cpp @@ -63,12 +63,11 @@ static int SRMMStatusToPf2(int status) int IsAutoPopup(HANDLE hContact) { if (g_dat->flags & SMF_AUTOPOPUP) { - char *szProto = (char *) CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM) hContact, 0); + char *szProto = GetContactProto(hContact); if (strcmp(szProto, "MetaContacts") == 0 ) { hContact = (HANDLE)CallService(MS_MC_GETMOSTONLINECONTACT,(WPARAM)hContact, 0); - if (hContact != NULL) { - szProto = (char*)CallService(MS_PROTO_GETCONTACTBASEPROTO,(WPARAM)hContact,0); - } + if (hContact != NULL) + szProto = GetContactProto(hContact); } if (szProto && (g_dat->openFlags & SRMMStatusToPf2(CallProtoService(szProto, PS_GETSTATUS, 0, 0)))) { return 1; @@ -150,18 +149,13 @@ static INT_PTR SendMessageCommandW(WPARAM wParam, LPARAM lParam) HWND hwnd; NewMessageWindowLParam newData = { 0 }; - { - /* does the HCONTACT's protocol support IM messages? */ - char *szProto = (char *) CallService(MS_PROTO_GETCONTACTBASEPROTO, wParam, 0); - if (szProto) { - if (!CallProtoService(szProto, PS_GETCAPS, PFLAGNUM_1, 0) & PF1_IMSEND) - return 1; - } - else { - /* unknown contact */ - return 1; - } //if - } + /* does the HCONTACT's protocol support IM messages? */ + char *szProto = GetContactProto((HANDLE)wParam); + if (szProto == NULL) + return 1; /* unknown contact */ + + if (!CallProtoService(szProto, PS_GETCAPS, PFLAGNUM_1, 0) & PF1_IMSEND) + return 1; if ((hwnd = WindowList_Find(g_dat->hMessageWindowList, (HANDLE) wParam))) { if (lParam) { @@ -194,7 +188,7 @@ static INT_PTR SendMessageCommand(WPARAM wParam, LPARAM lParam) NewMessageWindowLParam newData = { 0 }; { - char *szProto = (char *) CallService(MS_PROTO_GETCONTACTBASEPROTO, wParam, 0); + char *szProto = GetContactProto((HANDLE)wParam); //logInfo("Show message window for: %s (%s)", CallService(MS_CLIST_GETCONTACTDISPLAYNAME, wParam, 0), szProto); if (szProto) { /* does the HCONTACT's protocol support IM messages? */ @@ -284,7 +278,7 @@ static int TypingMessage(WPARAM wParam, LPARAM lParam) static int MessageSettingChanged(WPARAM wParam, LPARAM lParam) { DBCONTACTWRITESETTING *cws = (DBCONTACTWRITESETTING *) lParam; - char *szProto = (char *) CallService(MS_PROTO_GETCONTACTBASEPROTO, wParam, 0); + char *szProto = GetContactProto((HANDLE)wParam); if (lstrcmpA(cws->szModule, "CList") && (szProto == NULL || lstrcmpA(cws->szModule, szProto))) return 0; WindowList_Broadcast(g_dat->hMessageWindowList, DM_CLISTSETTINGSCHANGED, wParam, lParam); @@ -385,7 +379,7 @@ static INT_PTR GetWindowData(WPARAM wParam, LPARAM lParam) static int PrebuildContactMenu(WPARAM wParam, LPARAM lParam) { HANDLE hContact = (HANDLE)wParam; if ( hContact ) { - char* szProto = (char*)CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM) hContact, 0); + char* szProto = GetContactProto(hContact); CLISTMENUITEM clmi = {0}; clmi.cbSize = sizeof(CLISTMENUITEM); diff --git a/plugins/Scriver/src/msgwindow.cpp b/plugins/Scriver/src/msgwindow.cpp index 6e306db168..4003851adf 100644 --- a/plugins/Scriver/src/msgwindow.cpp +++ b/plugins/Scriver/src/msgwindow.cpp @@ -353,7 +353,7 @@ static void AddChild(ParentWindowData *dat, HWND hwnd, HANDLE hContact) MessageWindowTabData *mwtd = (MessageWindowTabData *) mir_alloc(sizeof(MessageWindowTabData)); mwtd->hwnd = hwnd; mwtd->hContact = hContact; - mwtd->szProto = (char *) CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM) hContact, 0); + mwtd->szProto = GetContactProto(hContact); mwtd->parent = dat; dat->childrenCount++; tci.mask = TCIF_PARAM | TCIF_IMAGE | TCIF_TEXT; diff --git a/plugins/Scriver/src/sendqueue.cpp b/plugins/Scriver/src/sendqueue.cpp index 1a85d67d4f..fe02397c6e 100644 --- a/plugins/Scriver/src/sendqueue.cpp +++ b/plugins/Scriver/src/sendqueue.cpp @@ -28,7 +28,7 @@ static char *MsgServiceName(HANDLE hContact) { char szServiceName[100]; - char *szProto = (char *) CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM) hContact, 0); + char *szProto = GetContactProto(hContact); if (szProto == NULL) return PSS_MESSAGE; diff --git a/plugins/SecureIM/src/crypt_metacontacts.cpp b/plugins/SecureIM/src/crypt_metacontacts.cpp index f36c7e4dd3..065ad5145d 100644 --- a/plugins/SecureIM/src/crypt_metacontacts.cpp +++ b/plugins/SecureIM/src/crypt_metacontacts.cpp @@ -3,7 +3,7 @@ BOOL isProtoMetaContacts(HANDLE hContact) { if(bMetaContacts) { - LPSTR proto = (LPSTR)CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)hContact, 0); + LPSTR proto = GetContactProto(hContact); if ( proto && strcmp(proto,"MetaContacts")==0 ) { return true; } diff --git a/plugins/SecureIM/src/crypt_misc.cpp b/plugins/SecureIM/src/crypt_misc.cpp index 7e0055913d..fb65f29798 100644 --- a/plugins/SecureIM/src/crypt_misc.cpp +++ b/plugins/SecureIM/src/crypt_misc.cpp @@ -5,7 +5,7 @@ int SendBroadcast( HANDLE hContact, int type, int result, HANDLE hProcess, LPARA ACKDATA ack; memset(&ack,0,sizeof(ack)); ack.cbSize = sizeof( ACKDATA ); - ack.szModule = (char*)CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)hContact, 0); + ack.szModule = GetContactProto(hContact); ack.hContact = hContact; ack.type = type; ack.result = result; diff --git a/plugins/SecureIM/src/dbevent.cpp b/plugins/SecureIM/src/dbevent.cpp index 7b26631502..6f5f1bc80b 100644 --- a/plugins/SecureIM/src/dbevent.cpp +++ b/plugins/SecureIM/src/dbevent.cpp @@ -7,7 +7,7 @@ void HistoryLog(HANDLE hContact, LPCSTR szText) { memset(&dbei, 0, sizeof(dbei)); dbei.cbSize = sizeof(dbei); - dbei.szModule = (char *)CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)hContact, 0); + dbei.szModule = GetContactProto(hContact); dbei.flags = DBEF_SENT|DBEF_READ; dbei.timestamp = time(NULL); dbei.eventType = EVENTTYPE_MESSAGE; diff --git a/plugins/SecureIM/src/svcs_clist.cpp b/plugins/SecureIM/src/svcs_clist.cpp index 45299d8611..e7aa7f8379 100644 --- a/plugins/SecureIM/src/svcs_clist.cpp +++ b/plugins/SecureIM/src/svcs_clist.cpp @@ -120,7 +120,7 @@ int __cdecl onRebuildContactMenu(WPARAM wParam,LPARAM lParam) { return 0; } -// char *szProto = (char*)CallService(MS_PROTO_GETCONTACTBASEPROTO,(WPARAM)hContact,0); +// char *szProto = GetContactProto(hContact,0); // if (szProto==NULL) // || DBGetContactSettingDword(hContact, szProto, "Status", ID_STATUS_OFFLINE) == ID_STATUS_OFFLINE) // return 0; diff --git a/plugins/SecureIM/src/svcs_proto.cpp b/plugins/SecureIM/src/svcs_proto.cpp index 8d2aade148..eb5466c329 100644 --- a/plugins/SecureIM/src/svcs_proto.cpp +++ b/plugins/SecureIM/src/svcs_proto.cpp @@ -890,7 +890,7 @@ INT_PTR __cdecl onSendMsg(WPARAM wParam, LPARAM lParam) { DBEVENTINFO dbei; HANDLE hC = getMostOnline(pccsd->hContact); ZeroMemory(&dbei, sizeof(dbei)); dbei.cbSize = sizeof(dbei); - dbei.szModule = (char *)CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)hC, 0); + dbei.szModule = GetContactProto(hC, 0); dbei.flags = DBEF_SENT; dbei.timestamp = time(NULL); dbei.eventType = EVENTTYPE_MESSAGE; diff --git a/plugins/SeenPlugin/src/menu.cpp b/plugins/SeenPlugin/src/menu.cpp index e0c48146a8..010f960e5e 100644 --- a/plugins/SeenPlugin/src/menu.cpp +++ b/plugins/SeenPlugin/src/menu.cpp @@ -42,7 +42,7 @@ int BuildContactMenu(WPARAM wparam,LPARAM lparam) { int id = -1, isetting; HANDLE hContact = (HANDLE)wparam; - char *szProto = (char*)CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)hContact, 0); + char *szProto = GetContactProto(hContact); CLISTMENUITEM cmi = { sizeof(cmi) }; if (!IsWatchedProtocol(szProto) || !db_get_b(NULL,S_MOD,"MenuItem",1)) diff --git a/plugins/SeenPlugin/src/userinfo.cpp b/plugins/SeenPlugin/src/userinfo.cpp index ab9ad36840..2bf3649a02 100644 --- a/plugins/SeenPlugin/src/userinfo.cpp +++ b/plugins/SeenPlugin/src/userinfo.cpp @@ -77,7 +77,7 @@ INT_PTR CALLBACK UserinfoDlgProc(HWND hdlg,UINT msg,WPARAM wparam,LPARAM lparam) int UserinfoInit(WPARAM wparam,LPARAM lparam) { - char *proto = (char *)CallService(MS_PROTO_GETCONTACTBASEPROTO, lparam, 0); + char *proto = GetContactProto((HANDLE)lparam); if ( IsWatchedProtocol(proto)) { OPTIONSDIALOGPAGE uip = { sizeof(uip) }; uip.hInstance = hInstance; diff --git a/plugins/SeenPlugin/src/utils.cpp b/plugins/SeenPlugin/src/utils.cpp index 5e2143eb8c..c307fe1411 100644 --- a/plugins/SeenPlugin/src/utils.cpp +++ b/plugins/SeenPlugin/src/utils.cpp @@ -168,7 +168,7 @@ TCHAR *ParseString(TCHAR *szstring, HANDLE hcontact, BYTE isfile) CONTACTINFO ci = { sizeof(CONTACTINFO) }; ci.hContact = hcontact; - ci.szProto = hcontact ? (char*)CallService(MS_PROTO_GETCONTACTBASEPROTO,(WPARAM)hcontact,0) : courProtoName; + ci.szProto = hcontact ? GetContactProto(hcontact) : courProtoName; TCHAR *d = sztemp; for (TCHAR *p = szstring; *p; p++) { @@ -612,7 +612,7 @@ int UpdateValues(WPARAM wparam,LPARAM lparam) // avoid repeating the offline status if ((prevStatus|0x8000)<=ID_STATUS_OFFLINE) return 0; - proto = (char *)CallService(MS_PROTO_GETCONTACTBASEPROTO, wparam, 0); + proto = GetContactProto((HANDLE)wparam); db_set_b((HANDLE)wparam, S_MOD, "Offline", 1); { DWORD t; @@ -626,18 +626,15 @@ int UpdateValues(WPARAM wparam,LPARAM lparam) if (!db_get_b(NULL,S_MOD,"IgnoreOffline",1)) { - char * sProto; if ( db_get_b(NULL,S_MOD,"FileOutput",0)) FileWrite((HANDLE)wparam); - if (CallProtoService(sProto = - (char *)CallService(MS_PROTO_GETCONTACTBASEPROTO, wparam, 0), - PS_GETSTATUS,0,0 - )>ID_STATUS_OFFLINE) { + char *sProto = GetContactProto((HANDLE)wparam); + if (CallProtoService(sProto, PS_GETSTATUS, 0, 0) > ID_STATUS_OFFLINE) { myPlaySound((HANDLE)wparam, ID_STATUS_OFFLINE, prevStatus); - if ( db_get_b(NULL, S_MOD, "UsePopups", 0)) { + if ( db_get_b(NULL, S_MOD, "UsePopups", 0)) ShowPopup((HANDLE)wparam, sProto, ID_STATUS_OFFLINE); - } } + } if ( db_get_b(NULL, S_MOD, "KeepHistory", 0)) HistoryWrite((HANDLE)wparam); @@ -658,7 +655,8 @@ int UpdateValues(WPARAM wparam,LPARAM lparam) if ( db_get_b(NULL, S_MOD, "FileOutput", 0)) FileWrite((HANDLE)wparam); if (prevStatus != cws->value.wVal) myPlaySound((HANDLE)wparam, cws->value.wVal, prevStatus); if ( db_get_b(NULL, S_MOD, "UsePopups", 0)) - if (prevStatus != cws->value.wVal) ShowPopup((HANDLE)wparam, (char *)CallService(MS_PROTO_GETCONTACTBASEPROTO, wparam, 0), cws->value.wVal|0x8000); + if (prevStatus != cws->value.wVal) + ShowPopup((HANDLE)wparam, GetContactProto((HANDLE)wparam), cws->value.wVal|0x8000); if ( db_get_b(NULL, S_MOD, "KeepHistory", 0)) HistoryWrite((HANDLE)wparam); if ( db_get_b((HANDLE)wparam, S_MOD, "OnlineAlert", 0)) ShowHistory((HANDLE)wparam, 1); @@ -687,7 +685,7 @@ static DWORD __stdcall cleanThread(logthread_info* infoParam) HANDLE hcontact = db_find_first(); while(hcontact != NULL) { - char *contactProto = (char *)CallService(MS_PROTO_GETCONTACTBASEPROTO,(WPARAM)hcontact,0); + char *contactProto = GetContactProto(hcontact); if (contactProto) { if ( !strncmp(infoParam->sProtoName, contactProto, MAXMODULELABELLENGTH)) { WORD oldStatus = db_get_w(hcontact,S_MOD,"StatusTriger",ID_STATUS_OFFLINE) | 0x8000; diff --git a/plugins/SendScreenshotPlus/src/CSend.cpp b/plugins/SendScreenshotPlus/src/CSend.cpp index eae8ecad55..27797db234 100644 --- a/plugins/SendScreenshotPlus/src/CSend.cpp +++ b/plugins/SendScreenshotPlus/src/CSend.cpp @@ -65,7 +65,7 @@ CSend::~CSend(){ //--------------------------------------------------------------------------- void CSend::SetContact(HANDLE hContact) { m_hContact = hContact; - m_pszProto = (char*)CallService(MS_PROTO_GETCONTACTBASEPROTO,(WPARAM)hContact,0); + m_pszProto = GetContactProto(hContact); m_ChatRoom = DBGetContactSettingByte(hContact, m_pszProto, "ChatRoom", 0); m_PFflag = hasCap(PF1_URLSEND); m_PFflag = hasCap(PF1_CHAT); diff --git a/plugins/SendScreenshotPlus/src/Main.cpp b/plugins/SendScreenshotPlus/src/Main.cpp index 393406a91e..3398f5580b 100644 --- a/plugins/SendScreenshotPlus/src/Main.cpp +++ b/plugins/SendScreenshotPlus/src/Main.cpp @@ -208,8 +208,8 @@ INT_PTR service_CaptureAndSendDesktop(WPARAM wParam, LPARAM lParam) { LPTSTR pszPath = GetCustomPath(); if(pszPath) { - LPSTR pszProto = (LPSTR)CallService(MS_PROTO_GETCONTACTBASEPROTO,wParam,0); - bool bChatRoom = DBGetContactSettingByte((HANDLE)wParam, pszProto, "ChatRoom", 0) != 0; + LPSTR pszProto = GetContactProto((HANDLE)wParam); + bool bChatRoom = DBGetContactSettingByte((HANDLE)wParam, pszProto, "ChatRoom", 0) != 0; frmMain->m_opt_chkTimed = false; frmMain->m_opt_tabCapture = 1; frmMain->m_opt_cboxDesktop = 0; diff --git a/plugins/SimpleAR/src/Main.cpp b/plugins/SimpleAR/src/Main.cpp index 62c5a34ce6..e00a1f6a64 100644 --- a/plugins/SimpleAR/src/Main.cpp +++ b/plugins/SimpleAR/src/Main.cpp @@ -194,7 +194,7 @@ INT addEvent(WPARAM wParam, LPARAM lParam) if (!fEnabled || !hContact || !hDBEvent) return FALSE; /// unspecifyed error - char* pszProto = (char*)CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)hContact, 0); + char* pszProto = GetContactProto(hContact); int status = CallProtoService(pszProto, PS_GETSTATUS, 0, 0); if (status == 40072 || status == 40077 || status == 40078) return FALSE; diff --git a/plugins/SimpleStatusMsg/src/awaymsg.cpp b/plugins/SimpleStatusMsg/src/awaymsg.cpp index 1861034b62..6c31c8ec4e 100644 --- a/plugins/SimpleStatusMsg/src/awaymsg.cpp +++ b/plugins/SimpleStatusMsg/src/awaymsg.cpp @@ -105,7 +105,7 @@ static INT_PTR CALLBACK ReadAwayMsgDlgProc(HWND hwndDlg, UINT message, WPARAM wP { TCHAR str[256], format[128]; TCHAR *contactName = (TCHAR*)CallService(MS_CLIST_GETCONTACTDISPLAYNAME, (WPARAM)dat->hContact, GCDNF_TCHAR); - char *szProto = (char*)CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)dat->hContact, 0); + char *szProto = GetContactProto(dat->hContact); WORD dwStatus = DBGetContactSettingWord(dat->hContact, szProto, "Status", ID_STATUS_OFFLINE); TCHAR *status = (TCHAR*)CallService(MS_CLIST_GETSTATUSMODEDESCRIPTION, dwStatus, GSMDF_TCHAR); @@ -374,7 +374,7 @@ static int AwayMsgPreBuildMenu(WPARAM wParam, LPARAM lParam) { CLISTMENUITEM clmi = {0}; TCHAR str[128]; - char *szProto = (char *)CallService(MS_PROTO_GETCONTACTBASEPROTO, wParam, 0); + char *szProto = GetContactProto((HANDLE)wParam); int iHidden = szProto ? DBGetContactSettingByte((HANDLE)wParam, szProto, "ChatRoom", 0) : 0; char *szMsg; int iStatus; diff --git a/plugins/SimpleStatusMsg/src/main.cpp b/plugins/SimpleStatusMsg/src/main.cpp index 81396b8f97..d572945340 100644 --- a/plugins/SimpleStatusMsg/src/main.cpp +++ b/plugins/SimpleStatusMsg/src/main.cpp @@ -1899,7 +1899,7 @@ static int OnICQStatusMsgRequest(WPARAM wParam, LPARAM lParam, LPARAM lMirParam) hContact = db_find_first(); while (hContact) { - szProto = (char *)CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)hContact, 0); + szProto = GetContactProto(hContact); if (szProto != NULL && !strcmp(szProto, (char *)lMirParam) && DBGetContactSettingDword(hContact, szProto, "UIN", 0) == (DWORD)lParam) { bContactFound = TRUE; diff --git a/plugins/SmileyAdd/src/dlgboxsubclass.cpp b/plugins/SmileyAdd/src/dlgboxsubclass.cpp index 03a0a6e5fd..1970577b48 100644 --- a/plugins/SmileyAdd/src/dlgboxsubclass.cpp +++ b/plugins/SmileyAdd/src/dlgboxsubclass.cpp @@ -324,11 +324,8 @@ static void MsgWndDetect(HWND hwndDlg, HANDLE hContact, msgData* datm) dat.hContact = hContact; // Get the protocol for this contact to display correct smileys. - char *protonam = (char*) CallService(MS_PROTO_GETCONTACTBASEPROTO, - (WPARAM)DecodeMetaContact(dat.hContact), 0); - - if (protonam) - { + char *protonam = GetContactProto( DecodeMetaContact(dat.hContact)); + if (protonam) { strncpy(dat.ProtocolName, protonam, sizeof(dat.ProtocolName)); dat.ProtocolName[sizeof(dat.ProtocolName)-1] = 0; } diff --git a/plugins/SmileyAdd/src/services.cpp b/plugins/SmileyAdd/src/services.cpp index 3dae4a086d..58bb73781e 100644 --- a/plugins/SmileyAdd/src/services.cpp +++ b/plugins/SmileyAdd/src/services.cpp @@ -53,7 +53,7 @@ SmileyPackType* GetSmileyPack(const char* proto, HANDLE hContact, SmileyPackCTyp if (categoryName.empty() && !opt.UseOneForAll) { - char *protonam = (char*) CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)hContact, 0); + char *protonam = GetContactProto(hContact); if (protonam != NULL) { DBVARIANT dbv; @@ -410,7 +410,7 @@ int RebuildContactMenu(WPARAM wParam, LPARAM) SmileyCategoryListType::SmileyCategoryVectorType& smc = *g_SmileyCategories.GetSmileyCategoryList(); - char* protnam = (char*) CallService(MS_PROTO_GETCONTACTBASEPROTO, wParam, 0); + char* protnam = GetContactProto((HANDLE)wParam); bool haveMenu = IsSmileyProto(protnam); if (haveMenu && opt.UseOneForAll) { diff --git a/plugins/SmileyAdd/src/smileys.cpp b/plugins/SmileyAdd/src/smileys.cpp index bc085120e5..ef88e952e0 100644 --- a/plugins/SmileyAdd/src/smileys.cpp +++ b/plugins/SmileyAdd/src/smileys.cpp @@ -192,7 +192,7 @@ void SmileyType::CallSmileyService(HANDLE hContact) if (name[0] == '/') { - proto = (const char*) CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)hContact, 0); + proto = (const char*)GetContactProto(hContact); if (proto == NULL) return; } mir_snprintf(str, sizeof(str), "%s%s", proto, T2A_SM(name.c_str())); @@ -905,7 +905,7 @@ void SmileyCategoryListType::DeleteAccountAsCategory(PROTOACCOUNT *acc) HANDLE hContact = db_find_first(); while (hContact != NULL) { - char* proto = (char*)CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)hContact, 0); + char* proto = GetContactProto(hContact); if (proto) { DBVARIANT dbv; @@ -931,7 +931,7 @@ void SmileyCategoryListType::DeleteAccountAsCategory(PROTOACCOUNT *acc) void SmileyCategoryListType::AddContactTransportAsCategory(HANDLE hContact, const bkstring& defaultFile) { - char* proto = (char*)CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)hContact, 0); + char* proto = GetContactProto(hContact); if (proto == NULL) return; DBVARIANT dbv; diff --git a/plugins/SpellChecker/src/spellchecker.cpp b/plugins/SpellChecker/src/spellchecker.cpp index 014214de10..25980828c0 100644 --- a/plugins/SpellChecker/src/spellchecker.cpp +++ b/plugins/SpellChecker/src/spellchecker.cpp @@ -1237,7 +1237,7 @@ void GetUserProtoLanguageSetting(Dialog *dlg, HANDLE hContact, char *group, char void GetUserLanguageSetting(Dialog *dlg, char *setting) { - char *proto = (char *) CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM) dlg->hContact, 0); + char *proto = GetContactProto(dlg->hContact); if (proto == NULL) return; diff --git a/plugins/StopSpamMod/src/utilities.cpp b/plugins/StopSpamMod/src/utilities.cpp index ae1d8ab939..e4c3813211 100755 --- a/plugins/StopSpamMod/src/utilities.cpp +++ b/plugins/StopSpamMod/src/utilities.cpp @@ -409,7 +409,7 @@ void CleanProtocolTmpThread(std::string proto) std::list contacts; for(HANDLE hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) { - char *proto_tmp = (char*)CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)hContact, 0); + char *proto_tmp = GetContactProto(hContact); if(proto_tmp) if(!strcmp(proto.c_str(), proto_tmp)) if(DBGetContactSettingByte(hContact, "CList", "NotOnList", 0)|| (_T("Not In List")== DBGetContactSettingStringPAN(hContact,"CList","Group",_T("")))) @@ -439,7 +439,7 @@ void CleanProtocolExclThread(std::string proto) std::list contacts; for(HANDLE hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) { - char *proto_tmp = (char*)CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)hContact, 0); + char *proto_tmp = GetContactProto(hContact); if(proto_tmp) if(!strcmp(proto.c_str(), proto_tmp)) if(DBGetContactSettingByte(hContact, "CList", "NotOnList", 0) && DBGetContactSettingByte(hContact, pluginName, "Excluded", 0)) @@ -498,9 +498,9 @@ void HistoryLogFunc(HANDLE hContact, std::string message) return; std::string msg = message; msg.append("\n"); - msg.append("Protocol: ").append((char*)CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)hContact, 0)).append(" Contact: "); + msg.append("Protocol: ").append(GetContactProto(hContact)).append(" Contact: "); msg.append(toUTF8((TCHAR*)CallService(MS_CLIST_GETCONTACTDISPLAYNAME, (WPARAM) hContact, GCDNF_TCHAR))).append(" ID: "); - msg.append(toUTF8(GetContactUid(hContact,toUTF16((char*)CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)hContact, 0))))); + msg.append(toUTF8(GetContactUid(hContact,toUTF16(GetContactProto(hContact))))); HistoryLog(NULL, (char*)msg.c_str(), EVENTTYPE_MESSAGE, DBEF_READ); } } diff --git a/plugins/StopSpamPlus/src/services.cpp b/plugins/StopSpamPlus/src/services.cpp index bc54f5485d..534fbc9a40 100644 --- a/plugins/StopSpamPlus/src/services.cpp +++ b/plugins/StopSpamPlus/src/services.cpp @@ -31,7 +31,7 @@ INT_PTR RemoveTempContacts(WPARAM wParam,LPARAM lParam) dbv.ptszVal = NULL; if ( DBGetContactSettingByte(hContact, "CList", "NotOnList", 0) || DBGetContactSettingByte(hContact, "CList", "Hidden", 0 ) || (dbv.ptszVal != NULL && (_tcsstr(dbv.ptszVal, _T("Not In List")) || _tcsstr(dbv.ptszVal, TranslateT("Not In List"))))) { - char *szProto = (char *) CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)hContact, 0); + char *szProto = GetContactProto(hContact); if ( szProto != NULL ) { // Check if protocol uses server side lists DWORD caps = CallProtoService(szProto, PS_GETCAPS, PFLAGNUM_1, 0); diff --git a/plugins/TabSRMM/src/chat/clist.cpp b/plugins/TabSRMM/src/chat/clist.cpp index dbcbb27ee8..628a7372ab 100644 --- a/plugins/TabSRMM/src/chat/clist.cpp +++ b/plugins/TabSRMM/src/chat/clist.cpp @@ -105,7 +105,7 @@ HANDLE CList_AddRoom(const char* pszModule, const TCHAR* pszRoom, const TCHAR* p BOOL CList_SetOffline(HANDLE hContact, BOOL bHide) { if (hContact) { - char* szProto = (char*)CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM) hContact, 0); + char* szProto = GetContactProto(hContact); if (szProto == NULL) return FALSE; @@ -124,7 +124,7 @@ BOOL CList_SetAllOffline(BOOL bHide, const char *pszModule) hContact = db_find_first(); while (hContact) { - szProto = (char *) CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM) hContact, 0); + szProto = GetContactProto(hContact); if (MM_FindModule(szProto)) { if (!pszModule || (pszModule && !strcmp(pszModule, szProto))) { int i = M->GetByte(hContact, szProto, "ChatRoom", 0); @@ -151,7 +151,7 @@ int CList_RoomDoubleclicked(WPARAM wParam, LPARAM lParam) if (!hContact) return 0; - szProto = (char*)CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM) hContact, 0); + szProto = GetContactProto(hContact); if (MM_FindModule(szProto)) { if (M->GetByte(hContact, szProto, "ChatRoom", 0) == 0) return 0; @@ -196,7 +196,7 @@ INT_PTR CList_JoinChat(WPARAM wParam, LPARAM lParam) { HANDLE hContact = (HANDLE)wParam; if ( hContact ) { - char* szProto = (char*)CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM) hContact, 0); + char* szProto = GetContactProto(hContact); if ( szProto ) { if ( DBGetContactSettingWord( hContact, szProto, "Status", 0 ) == ID_STATUS_OFFLINE ) CallProtoService( szProto, PS_JOINCHAT, wParam, lParam ); @@ -211,7 +211,7 @@ INT_PTR CList_LeaveChat(WPARAM wParam, LPARAM lParam) { HANDLE hContact = (HANDLE)wParam; if ( hContact ) { - char* szProto = (char*)CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM) hContact, 0); + char* szProto = GetContactProto(hContact); if ( szProto ) CallProtoService( szProto, PS_LEAVECHAT, wParam, lParam ); } @@ -222,7 +222,7 @@ int CList_PrebuildContactMenu(WPARAM wParam, LPARAM lParam) { HANDLE hContact = (HANDLE)wParam; if ( hContact ) { - char* szProto = (char*)CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM) hContact, 0); + char* szProto = GetContactProto(hContact); CLISTMENUITEM clmi = {0}; clmi.cbSize = sizeof(CLISTMENUITEM); @@ -308,7 +308,7 @@ HANDLE CList_FindRoom(const char* pszModule, const TCHAR* pszRoom) { HANDLE hContact = db_find_first(); while (hContact) { - char* szProto = (char*)CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM) hContact, 0); + char* szProto = GetContactProto(hContact); if (szProto && !lstrcmpiA(szProto, pszModule)) { if (M->GetByte(hContact, szProto, "ChatRoom", 0) != 0) { DBVARIANT dbv; diff --git a/plugins/TabSRMM/src/chat/services.cpp b/plugins/TabSRMM/src/chat/services.cpp index 52664447a3..5690e08154 100644 --- a/plugins/TabSRMM/src/chat/services.cpp +++ b/plugins/TabSRMM/src/chat/services.cpp @@ -464,7 +464,7 @@ HWND CreateNewRoom(TContainerData *pContainer, SESSION_INFO *si, BOOL bActivateT } else lstrcpyn(newcontactname, _T("_U_"), SIZEOF(newcontactname)); - char *szProto = (char *) CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM) newData.hContact, 0); + char *szProto = GetContactProto(newData.hContact); WORD wStatus = szProto == NULL ? ID_STATUS_OFFLINE : DBGetContactSettingWord((HANDLE) newData.hContact, szProto, "Status", ID_STATUS_OFFLINE); char *szStatus = (char *) CallService(MS_CLIST_GETSTATUSMODEDESCRIPTION, szProto == NULL ? ID_STATUS_OFFLINE : DBGetContactSettingWord((HANDLE)newData.hContact, szProto, "Status", ID_STATUS_OFFLINE), 0); diff --git a/plugins/TabSRMM/src/chat/window.cpp b/plugins/TabSRMM/src/chat/window.cpp index bcf331f15c..6d85d6244a 100644 --- a/plugins/TabSRMM/src/chat/window.cpp +++ b/plugins/TabSRMM/src/chat/window.cpp @@ -1962,7 +1962,7 @@ INT_PTR CALLBACK RoomWndProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPar si = psi; dat->si = psi; dat->hContact = psi->hContact; - dat->szProto = (char *)CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)psi->hContact, 0); + dat->szProto = GetContactProto(psi->hContact); dat->bType = SESSIONTYPE_CHAT; dat->Panel = new CInfoPanel(dat); diff --git a/plugins/TabSRMM/src/contactcache.cpp b/plugins/TabSRMM/src/contactcache.cpp index 3c8dead289..046ed7377e 100644 --- a/plugins/TabSRMM/src/contactcache.cpp +++ b/plugins/TabSRMM/src/contactcache.cpp @@ -51,7 +51,7 @@ CContactCache::CContactCache(const HANDLE hContact) m_nMax = 0; if (hContact) { - m_szProto = reinterpret_cast(::CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)m_hContact, 0)); + m_szProto = ::GetContactProto(m_hContact); if (m_szProto) m_tszProto = mir_a2t(m_szProto); initPhaseTwo(); @@ -171,7 +171,7 @@ void CContactCache::updateMeta(bool fForce) HANDLE hSubContact = (HANDLE)CallService(MS_MC_GETMOSTONLINECONTACT, (WPARAM)m_hContact, 0); if (hSubContact && (hSubContact != m_hSubContact || fForce)) { m_hSubContact = hSubContact; - m_szMetaProto = (char *)CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)m_hSubContact, 0); + m_szMetaProto = GetContactProto(m_hSubContact); if (m_szMetaProto) { PROTOACCOUNT *acc = reinterpret_cast(::CallService(MS_PROTO_GETACCOUNT, 0, (LPARAM)m_szMetaProto)); if (acc && acc->tszAccountName) diff --git a/plugins/TabSRMM/src/container.cpp b/plugins/TabSRMM/src/container.cpp index eb3b58c457..952607d419 100644 --- a/plugins/TabSRMM/src/container.cpp +++ b/plugins/TabSRMM/src/container.cpp @@ -1026,7 +1026,7 @@ panel_found: if (dat && dat->bType == SESSIONTYPE_CHAT) { SESSION_INFO *si = (SESSION_INFO *)dat->si; if (si && dat->hContact) { - char* szProto = (char*)CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM) dat->hContact, 0); + char* szProto = GetContactProto(dat->hContact); if ( szProto ) CallProtoService( szProto, PS_LEAVECHAT, (WPARAM)dat->hContact, 0 ); } @@ -1106,7 +1106,7 @@ panel_found: if (contactOK) { char szFinalService[512]; - mir_snprintf(szFinalService, 512, "%s/%s", (char *)CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)hContact, 0), item->szService); + mir_snprintf(szFinalService, 512, "%s/%s", GetContactProto(hContact), item->szService); if (ServiceExists(szFinalService)) CallService(szFinalService, wwParam, llParam); else @@ -1122,7 +1122,7 @@ panel_found: if (item->dwFlags & BUTTON_ISCONTACTDBACTION || item->dwFlags & BUTTON_DBACTIONONCONTACT) { contactOK = ServiceParamsOK(item, &wwParam, &llParam, hContact); if (contactOK && item->dwFlags & BUTTON_ISCONTACTDBACTION) - szModule = (char *)CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)hContact, 0); + szModule = GetContactProto(hContact); finalhContact = hContact; } else @@ -2606,7 +2606,7 @@ HMENU TSAPI BuildMCProtocolMenu(HWND hwndDlg) { iNumProtos = (int)CallService(MS_MC_GETNUMCONTACTS, (WPARAM)dat->hContact, 0); iDefaultProtoByNum = (int)CallService(MS_MC_GETDEFAULTCONTACTNUM, (WPARAM)dat->hContact, 0); hContactMostOnline = (HANDLE)CallService(MS_MC_GETMOSTONLINECONTACT, (WPARAM)dat->hContact, 0); - szProtoMostOnline = (char *)CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)hContactMostOnline, 0); + szProtoMostOnline = GetContactProto(hContactMostOnline); isForced = M->GetDword(dat->hContact, "tabSRMM_forced", -1); for (i=0; i < iNumProtos; i++) { diff --git a/plugins/TabSRMM/src/generic_msghandlers.cpp b/plugins/TabSRMM/src/generic_msghandlers.cpp index 2b04d1813c..bffd4951a7 100644 --- a/plugins/TabSRMM/src/generic_msghandlers.cpp +++ b/plugins/TabSRMM/src/generic_msghandlers.cpp @@ -1053,7 +1053,7 @@ void TSAPI DM_SetDBButtonStates(HWND hwndChild, struct TWindowData *dat) continue; } if (buttonItem->dwFlags & BUTTON_ISCONTACTDBACTION) - szModule = (char *)CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)hContact, 0); + szModule = GetContactProto(hContact); hFinalContact = hContact; } else hFinalContact = 0; diff --git a/plugins/TabSRMM/src/mim.cpp b/plugins/TabSRMM/src/mim.cpp index e49b85c21d..9381dc7356 100644 --- a/plugins/TabSRMM/src/mim.cpp +++ b/plugins/TabSRMM/src/mim.cpp @@ -666,7 +666,7 @@ int CMimAPI::PrebuildContactMenu(WPARAM wParam, LPARAM lParam) { HANDLE hContact = (HANDLE)wParam; if ( hContact ) { - char* szProto = (char*)CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM) hContact, 0); + char* szProto = GetContactProto(hContact); CLISTMENUITEM clmi = {0}; clmi.cbSize = sizeof(CLISTMENUITEM); @@ -812,13 +812,12 @@ int CMimAPI::MessageEventAdded(WPARAM wParam, LPARAM lParam) if (dwStatusMask == -1) bAllowAutoCreate = TRUE; else { - char *szProto = (char *)CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)wParam, 0); + char *szProto = GetContactProto((HANDLE)wParam); DWORD dwStatus = 0; if (PluginConfig.g_MetaContactsAvail && szProto && !strcmp(szProto, (char *)CallService(MS_MC_GETPROTOCOLNAME, 0, 0))) { HANDLE hSubconttact = (HANDLE)CallService(MS_MC_GETMOSTONLINECONTACT, wParam, 0); - - szProto = (char *)CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)hSubconttact, 0); + szProto = GetContactProto(hSubconttact); } if (szProto) { dwStatus = (DWORD)CallProtoService(szProto, PS_GETSTATUS, 0, 0); diff --git a/plugins/TabSRMM/src/modplus.cpp b/plugins/TabSRMM/src/modplus.cpp index 3e9865f5f5..ea4f8389fe 100644 --- a/plugins/TabSRMM/src/modplus.cpp +++ b/plugins/TabSRMM/src/modplus.cpp @@ -59,7 +59,7 @@ static char* getMirVer(HANDLE hContact) char *msg = NULL; DBVARIANT dbv = {0}; - szProto = (char*) CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)hContact, 0); + szProto = GetContactProto(hContact); if ( !szProto ) return (NULL); diff --git a/plugins/TabSRMM/src/msgdialog.cpp b/plugins/TabSRMM/src/msgdialog.cpp index f53bf2ebbf..f574c34378 100644 --- a/plugins/TabSRMM/src/msgdialog.cpp +++ b/plugins/TabSRMM/src/msgdialog.cpp @@ -103,7 +103,7 @@ static BOOL IsStringValidLinkA(char* pszText) BOOL TSAPI IsUtfSendAvailable(HANDLE hContact) { - char* szProto = (char *) CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM) hContact, 0); + char* szProto = GetContactProto(hContact); if (szProto == NULL) return FALSE; diff --git a/plugins/TabSRMM/src/msgdlgutils.cpp b/plugins/TabSRMM/src/msgdlgutils.cpp index b8e9cb202b..918fb3afde 100644 --- a/plugins/TabSRMM/src/msgdlgutils.cpp +++ b/plugins/TabSRMM/src/msgdlgutils.cpp @@ -413,7 +413,7 @@ int TSAPI MsgWindowMenuHandler(TWindowData *dat, int selection, int menuId) if (dat && dat->bType == SESSIONTYPE_CHAT) { SESSION_INFO *si = (SESSION_INFO *)dat->si; if ( (si != NULL) && (dat->hContact != NULL)) { - char* szProto = (char*)CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM) dat->hContact, 0); + char* szProto = GetContactProto(dat->hContact); if ( szProto ) CallProtoService( szProto, PS_LEAVECHAT, (WPARAM)dat->hContact, 0 ); } diff --git a/plugins/TabSRMM/src/msgs.cpp b/plugins/TabSRMM/src/msgs.cpp index cd022728a0..6e92fc517e 100644 --- a/plugins/TabSRMM/src/msgs.cpp +++ b/plugins/TabSRMM/src/msgs.cpp @@ -302,7 +302,7 @@ INT_PTR SendMessageCommand_W(WPARAM wParam, LPARAM lParam) } /* does the HCONTACT's protocol support IM messages? */ - szProto = (char *) CallService(MS_PROTO_GETCONTACTBASEPROTO, wParam, 0); + szProto = GetContactProto((HANDLE)wParam); if (szProto) { if (!CallProtoService(szProto, PS_GETCAPS, PFLAGNUM_1, 0) & PF1_IMSEND) return 0; @@ -361,7 +361,7 @@ INT_PTR SendMessageCommand(WPARAM wParam, LPARAM lParam) } /* does the HCONTACT's protocol support IM messages? */ - szProto = (char *) CallService(MS_PROTO_GETCONTACTBASEPROTO, wParam, 0); + szProto = GetContactProto((HANDLE)wParam); if (szProto) { if (!CallProtoService(szProto, PS_GETCAPS, PFLAGNUM_1, 0) & PF1_IMSEND) return 0; @@ -703,7 +703,7 @@ HWND TSAPI CreateNewTabForContact(struct TContainerData *pContainer, HANDLE hCon newData.hContact = hContact; newData.isWchar = isSend; newData.szInitialText = pszInitialText; - szProto = (char *) CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM) newData.hContact, 0); + szProto = GetContactProto(newData.hContact); ZeroMemory((void*)&newData.item, sizeof(newData.item)); diff --git a/plugins/TabSRMM/src/sendlater.cpp b/plugins/TabSRMM/src/sendlater.cpp index 804107d9c8..632db61eab 100644 --- a/plugins/TabSRMM/src/sendlater.cpp +++ b/plugins/TabSRMM/src/sendlater.cpp @@ -535,7 +535,7 @@ HANDLE CSendLater::processAck(const ACKDATA *ack) dbei.cbSize = sizeof(dbei); dbei.eventType = EVENTTYPE_MESSAGE; dbei.flags = DBEF_SENT; - dbei.szModule = (char *) CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)((*it)->hContact), 0); + dbei.szModule = GetContactProto(((*it)->hContact)); dbei.timestamp = time(NULL); dbei.cbBlob = lstrlenA((*it)->sendBuffer) + 1; dbei.flags |= DBEF_UTF; diff --git a/plugins/TabSRMM/src/sendqueue.cpp b/plugins/TabSRMM/src/sendqueue.cpp index d6b70ffc10..98b36e2d06 100644 --- a/plugins/TabSRMM/src/sendqueue.cpp +++ b/plugins/TabSRMM/src/sendqueue.cpp @@ -54,7 +54,7 @@ static char *pss_msgw = "/SendMsgW"; char *SendQueue::MsgServiceName(const HANDLE hContact = 0, const TWindowData *dat = 0, int dwFlags = 0) { char szServiceName[100]; - char *szProto = (char *) CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM) hContact, 0); + char *szProto = GetContactProto(hContact); if (szProto == NULL) return pss_msg; @@ -208,7 +208,7 @@ static void DoSplitSendW(LPVOID param) HANDLE hContact = job->hOwner; DWORD dwFlags = job->dwFlags; int chunkSize = job->chunkSize / 2; - char *szProto = (char *) CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM) hContact, 0); + char *szProto = GetContactProto(hContact); if (szProto == NULL) svcName = pss_msg; @@ -808,7 +808,7 @@ inform_and_discard: dbei.cbSize = sizeof(dbei); dbei.eventType = EVENTTYPE_MESSAGE; dbei.flags = DBEF_SENT; - dbei.szModule = (char *) CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM) m_jobs[iFound].hOwner, 0); + dbei.szModule = GetContactProto(m_jobs[iFound].hOwner); dbei.timestamp = time(NULL); dbei.cbBlob = lstrlenA(m_jobs[iFound].sendBuffer) + 1; @@ -906,7 +906,7 @@ int SendQueue::doSendLater(int iJobIndex, TWindowData *dat, HANDLE hContact, boo dbei.cbSize = sizeof(dbei); dbei.eventType = EVENTTYPE_MESSAGE; dbei.flags = DBEF_SENT | DBEF_UTF; - dbei.szModule = (char *) CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM) dat->hContact, 0); + dbei.szModule = GetContactProto(dat->hContact); dbei.timestamp = time(NULL); dbei.cbBlob = lstrlenA(utfText) + 1; dbei.pBlob = (PBYTE) utfText; diff --git a/plugins/TabSRMM/src/templates.cpp b/plugins/TabSRMM/src/templates.cpp index 6d40f928e1..24880019a5 100644 --- a/plugins/TabSRMM/src/templates.cpp +++ b/plugins/TabSRMM/src/templates.cpp @@ -164,10 +164,10 @@ INT_PTR CALLBACK DlgProcTemplateEditor(HWND hwndDlg, UINT msg, WPARAM wParam, LP SendDlgItemMessage(hwndDlg, IDC_PREVIEW, EM_EXLIMITTEXT, 0, 0x80000000); dat->hContact = db_find_first(); - dat->szProto = (char *)CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)dat->hContact, 0); + dat->szProto = GetContactProto(dat->hContact); while(dat->szProto == 0 && dat->hContact != 0) { dat->hContact = db_find_next(dat->hContact); - dat->szProto = (char *)CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)dat->hContact, 0); + dat->szProto = GetContactProto(dat->hContact); } dat->dwFlags = dat->pContainer->theme.dwFlags; diff --git a/plugins/TabSRMM/src/trayicon.cpp b/plugins/TabSRMM/src/trayicon.cpp index 848765070f..a653564415 100644 --- a/plugins/TabSRMM/src/trayicon.cpp +++ b/plugins/TabSRMM/src/trayicon.cpp @@ -252,7 +252,7 @@ void TSAPI AddContactToFavorites(HANDLE hContact, const TCHAR *szNickname, const } if (szProto == NULL) - szProto = (char *)CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)hContact, 0); + szProto = GetContactProto(hContact); if (szProto) { if (wStatus == 0) wStatus = DBGetContactSettingWord((HANDLE)hContact, szProto, "Status", ID_STATUS_OFFLINE); diff --git a/plugins/TabSRMM/src/typingnotify.cpp b/plugins/TabSRMM/src/typingnotify.cpp index adfdbfee5c..52633e3304 100644 --- a/plugins/TabSRMM/src/typingnotify.cpp +++ b/plugins/TabSRMM/src/typingnotify.cpp @@ -289,7 +289,7 @@ static INT_PTR CALLBACK DlgProcOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARA break; while (hContact) { - szProto = (char *) CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)hContact, 0); + szProto = GetContactProto(hContact); if (szProto != NULL) break; hContact = db_find_next(hContact); diff --git a/plugins/TabSRMM/src/userprefs.cpp b/plugins/TabSRMM/src/userprefs.cpp index b23380910f..164191d833 100644 --- a/plugins/TabSRMM/src/userprefs.cpp +++ b/plugins/TabSRMM/src/userprefs.cpp @@ -74,23 +74,22 @@ static INT_PTR CALLBACK DlgProcUserPrefs(HWND hwndDlg, UINT msg, WPARAM wParam, case WM_INITDIALOG: { DWORD sCodePage; int i; - DWORD maxhist = M->GetDword((HANDLE)lParam, "maxhist", 0); - BYTE bIEView = M->GetByte((HANDLE)lParam, "ieview", 0); - BYTE bHPP = M->GetByte((HANDLE)lParam, "hpplog", 0); - int iLocalFormat = M->GetDword((HANDLE)lParam, "sendformat", 0); - BYTE bRTL = M->GetByte((HANDLE)lParam, "RTL", 0); - BYTE bLTR = M->GetByte((HANDLE)lParam, "RTL", 1); - BYTE bSplit = M->GetByte((HANDLE)lParam, "splitoverride", 0); - BYTE bInfoPanel = M->GetByte((HANDLE)lParam, "infopanel", 0); - BYTE bAvatarVisible = M->GetByte((HANDLE)lParam, "hideavatar", -1); - char *szProto = (char *)CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)lParam, 0); + hContact = (HANDLE)lParam; + DWORD maxhist = M->GetDword(hContact, "maxhist", 0); + BYTE bIEView = M->GetByte(hContact, "ieview", 0); + BYTE bHPP = M->GetByte(hContact, "hpplog", 0); + int iLocalFormat = M->GetDword(hContact, "sendformat", 0); + BYTE bRTL = M->GetByte(hContact, "RTL", 0); + BYTE bLTR = M->GetByte(hContact, "RTL", 1); + BYTE bSplit = M->GetByte(hContact, "splitoverride", 0); + BYTE bInfoPanel = M->GetByte(hContact, "infopanel", 0); + BYTE bAvatarVisible = M->GetByte(hContact, "hideavatar", -1); + char *szProto = GetContactProto(hContact); int def_log_index = 1, hpp_log_index = 1, ieview_log_index = 1; have_ieview = ServiceExists(MS_IEVIEW_WINDOW); have_hpp = ServiceExists("History++/ExtGrid/NewWindow"); - hContact = (HANDLE)lParam; - TranslateDialogDefault(hwndDlg); SetWindowLongPtr(hwndDlg, GWLP_USERDATA, (LONG_PTR)lParam); diff --git a/plugins/TipperYM/src/message_pump.cpp b/plugins/TipperYM/src/message_pump.cpp index 7032ad84b2..db57fadf07 100644 --- a/plugins/TipperYM/src/message_pump.cpp +++ b/plugins/TipperYM/src/message_pump.cpp @@ -58,7 +58,7 @@ bool NeedWaitForContent(CLCINFOTIPEX *clcitex) if (opt.bWaitForContent && IsContactTooltip(clcitex)) { - char *szProto = (char *)CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)clcitex->hItem, 0); + char *szProto = GetContactProto(clcitex->hItem); if (!szProto) return false; if (opt.bWaitForStatusMsg && !bStatusMsgReady) diff --git a/plugins/TipperYM/src/popwin.cpp b/plugins/TipperYM/src/popwin.cpp index 34cf0f596a..d7a3ae6c80 100644 --- a/plugins/TipperYM/src/popwin.cpp +++ b/plugins/TipperYM/src/popwin.cpp @@ -378,7 +378,7 @@ LRESULT CALLBACK PopupWindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lPa TCHAR *swzNick = (TCHAR *)CallService(MS_CLIST_GETCONTACTDISPLAYNAME, (WPARAM)pwd->hContact, GCDNF_TCHAR); _tcsncpy(pwd->swzTitle, swzNick, TITLE_TEXT_LEN); - char *szProto = (char *)CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)pwd->hContact, 0); + char *szProto = GetContactProto(pwd->hContact); pwd->spiTitle = Smileys_PreParse(pwd->swzTitle, -1, szProto); // get extra icons @@ -1266,7 +1266,7 @@ LRESULT CALLBACK PopupWindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lPa pwd->rows = (RowData *)mir_realloc(pwd->rows, sizeof(RowData) * (pwd->iRowCount + 1)); } - char *szProto = (char *)CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)pwd->hContact, 0); + char *szProto = GetContactProto(pwd->hContact); pwd->rows[pwd->iRowCount].swzLabel = mir_tstrdup(buff_label); pwd->rows[pwd->iRowCount].swzValue = mir_tstrdup(buff); @@ -1772,7 +1772,7 @@ LRESULT CALLBACK PopupWindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lPa HANDLE hContact = db_find_first(); while (hContact) { - char *proto = (char *)CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)hContact, 0); + char *proto = GetContactProto(hContact); if (proto && !strcmp(proto, pa->szModuleName)) { if (DBGetContactSettingWord(hContact, proto, "Status", ID_STATUS_OFFLINE) != ID_STATUS_OFFLINE) @@ -1932,7 +1932,7 @@ LRESULT CALLBACK PopupWindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lPa { if (DBGetContactSettingByte(hContact, MODULE, "FavouriteContact", 0)) { - char *proto = (char *)CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)hContact, 0); + char *proto = GetContactProto(hContact); if (proto) { WORD wStatus = DBGetContactSettingWord(hContact, proto, "Status", ID_STATUS_OFFLINE); diff --git a/plugins/TipperYM/src/subst.cpp b/plugins/TipperYM/src/subst.cpp index 4ba14de1e3..9320430577 100644 --- a/plugins/TipperYM/src/subst.cpp +++ b/plugins/TipperYM/src/subst.cpp @@ -159,7 +159,7 @@ bool Uid(HANDLE hContact, char *szProto, TCHAR *buff, int bufflen) { char *tmpProto = NULL; - if (hContact) tmpProto = ( char* )CallService(MS_PROTO_GETCONTACTBASEPROTO,(WPARAM)hContact, 0); + if (hContact) tmpProto = GetContactProto(hContact); else tmpProto = szProto; if (tmpProto) @@ -258,7 +258,7 @@ TCHAR *GetStatusMessageText(HANDLE hContact) TCHAR *swzMsg = 0; DBVARIANT dbv; - char *szProto = ( char* )CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)hContact, 0); + char *szProto = GetContactProto(hContact); if (szProto) { if (!strcmp(szProto, szMetaModuleName)) @@ -310,7 +310,7 @@ bool GetSysSubstText(HANDLE hContact, TCHAR *swzRawSpec, TCHAR *buff, int buffle } else if (!_tcscmp(swzRawSpec, _T("proto"))) { - char *szProto = (char*)CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)hContact, 0); + char *szProto = GetContactProto(hContact); if (szProto) { a2t(szProto, buff, bufflen); @@ -343,7 +343,7 @@ bool GetSysSubstText(HANDLE hContact, TCHAR *swzRawSpec, TCHAR *buff, int buffle } else if (!_tcscmp(swzRawSpec, _T("uidname"))) { - char *szProto = ( char* )CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)hContact, 0); + char *szProto = GetContactProto(hContact); return UidName(szProto, buff, bufflen); } else if (!_tcscmp(swzRawSpec, _T("status_msg"))) @@ -426,7 +426,7 @@ bool GetSysSubstText(HANDLE hContact, TCHAR *swzRawSpec, TCHAR *buff, int buffle int iNumber = 1; HANDLE hTmpContact = hContact; - char *szProto = ( char* )CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)hContact, 0); + char *szProto = GetContactProto(hContact); if (szProto && !strcmp(szProto, szMetaModuleName)) { iNumber = CallService(MS_MC_GETNUMCONTACTS, (WPARAM)hContact, 0); @@ -519,7 +519,7 @@ bool GetSubstText(HANDLE hContact, const DISPLAYSUBST &ds, TCHAR *buff, int buff return transFunc(hContact, ds.szModuleName, ds.szSettingName, buff, bufflen) != 0; case DVT_PROTODB: { - char *szProto = ( char* )CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)hContact, 0); + char *szProto = GetContactProto(hContact); if (szProto) { if (transFunc(hContact, szProto, ds.szSettingName, buff, bufflen) != 0) @@ -543,7 +543,7 @@ bool GetRawSubstText(HANDLE hContact, char *szRawSpec, TCHAR *buff, int bufflen) szRawSpec[i] = 0; if (strlen(szRawSpec) == 0) { - char *szProto = ( char* )CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)hContact, 0); + char *szProto = GetContactProto(hContact); if (szProto) { if (translations[0].transFunc(hContact, szProto, &szRawSpec[i + 1], buff, bufflen) != 0) @@ -624,7 +624,7 @@ bool ApplySubst(HANDLE hContact, const TCHAR *swzSource, bool parseTipperVarsFir p++; if (*p) { - char *cp = ( char* )CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)hContact, 0); + char *cp = GetContactProto(hContact); if (cp != NULL) { PROTOACCOUNT *acc = ProtoGetAccount(cp); @@ -916,13 +916,13 @@ TCHAR *GetProtoExtraStatusMessage(char *szProto) if (ServiceExists(MS_VARS_FORMATSTRING)) { HANDLE hContact = db_find_first(); - char *proto = ( char* )CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)hContact, 0); + char *proto = GetContactProto(hContact); while(!proto) { hContact = db_find_next(hContact); if (hContact) { - proto = ( char* )CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)hContact, 0); + proto = GetContactProto(hContact); } else { diff --git a/plugins/TooltipNotify/src/TooltipNotify.cpp b/plugins/TooltipNotify/src/TooltipNotify.cpp index 0029da7b93..bcdca4125a 100644 --- a/plugins/TooltipNotify/src/TooltipNotify.cpp +++ b/plugins/TooltipNotify/src/TooltipNotify.cpp @@ -986,7 +986,7 @@ TCHAR *CTooltipNotify::MakeTooltipString(HANDLE hContact, int iStatus, TCHAR *sz const TCHAR* szIs = TranslateT("is"); const char* szProto = - hContact==0 ? "Proto" : (char*)::CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)hContact, 0); + hContact==0 ? "Proto" : (char*)::GetContactProto(hContact); const TCHAR* szContactName = (TCHAR *)::CallService(MS_CLIST_GETCONTACTDISPLAYNAME, (WPARAM)hContact, GCDNF_TCHAR); diff --git a/plugins/UserInfoEx/src/Flags/svc_flags.cpp b/plugins/UserInfoEx/src/Flags/svc_flags.cpp index 95d0259ce4..a5a0e926fb 100644 --- a/plugins/UserInfoEx/src/Flags/svc_flags.cpp +++ b/plugins/UserInfoEx/src/Flags/svc_flags.cpp @@ -205,8 +205,7 @@ void KillBufferedFunctions() static INT_PTR ServiceDetectContactOriginCountry(WPARAM wParam,LPARAM lParam) { WORD countryNumber; - char *pszProto = - pszProto=(char*)CallService(MS_PROTO_GETCONTACTBASEPROTO,wParam,0); + char *pszProto = GetContactProto((HANDLE)wParam); /* UserinfoEx */ if (countryNumber = (int)DB::Setting::GetWord((HANDLE)wParam,USERINFO,SET_CONTACT_ORIGIN_COUNTRY,0)) return (INT_PTR)countryNumber; diff --git a/plugins/Variables/src/contact.cpp b/plugins/Variables/src/contact.cpp index 1e525d8d5c..bfe4da507e 100644 --- a/plugins/Variables/src/contact.cpp +++ b/plugins/Variables/src/contact.cpp @@ -118,7 +118,7 @@ TCHAR* getContactInfoT(BYTE type, HANDLE hContact) if (hContact == NULL) return NULL; - szProto = (char*)CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)hContact, 0); + szProto = GetContactProto(hContact); if (szProto == NULL) return NULL; @@ -241,17 +241,12 @@ int getContactFromString( CONTACTSINFO* ci ) if (ci == NULL) return -1; - if (ci->flags&CI_UNICODE) { - - tszContact = NEWTSTR_ALLOCA(ci->tszContact); - - } + if (ci->flags & CI_UNICODE) + tszContact = NEWTSTR_ALLOCA(ci->tszContact); else { - - WCHAR* tmp = mir_a2t(ci->szContact); - tszContact = NEWTSTR_ALLOCA(tmp); - mir_free(tmp); - + WCHAR* tmp = mir_a2t(ci->szContact); + tszContact = NEWTSTR_ALLOCA(tmp); + mir_free(tmp); } if ((tszContact == NULL) || (_tcslen(tszContact) == 0)) return -1; @@ -281,7 +276,7 @@ int getContactFromString( CONTACTSINFO* ci ) szFind = NULL; bMatch = FALSE; ZeroMemory(&dbv, sizeof(DBVARIANT)); - szProto = (char *)CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)hContact, 0); + szProto = GetContactProto(hContact); if (szProto == NULL) { hContact = db_find_next(hContact); continue; @@ -443,7 +438,7 @@ static int contactSettingChanged(WPARAM wParam, LPARAM lParam) continue; dbw = (DBCONTACTWRITESETTING*)lParam; - szProto = (char *)CallService(MS_PROTO_GETCONTACTBASEPROTO, wParam,0); + szProto = GetContactProto((HANDLE)wParam); if (szProto == NULL) continue; @@ -505,7 +500,7 @@ TCHAR *encodeContactToString(HANDLE hContact) DBVARIANT dbv; ZeroMemory(&dbv, sizeof(DBVARIANT)); - szProto = (char *)CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)hContact, 0); + szProto = GetContactProto(hContact); tszUniqueId = getContactInfoT(CNF_UNIQUEID, hContact); if (szProto == NULL || tszUniqueId == NULL) return NULL; diff --git a/plugins/Variables/src/parse_metacontacts.cpp b/plugins/Variables/src/parse_metacontacts.cpp index 8831e7a192..9bf44fb4c3 100644 --- a/plugins/Variables/src/parse_metacontacts.cpp +++ b/plugins/Variables/src/parse_metacontacts.cpp @@ -51,7 +51,7 @@ static TCHAR *parseGetParent(ARGUMENTSINFO *ai) TCHAR* res = NULL; TCHAR* szUniqueID = NULL; - char* szProto = (char *)CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)hContact, 0); + char* szProto = GetContactProto(hContact); if (szProto != NULL) szUniqueID = getContactInfoT(CNF_UNIQUEID, hContact); @@ -112,7 +112,7 @@ static TCHAR *parseGetDefault(ARGUMENTSINFO *ai) TCHAR* res = NULL; TCHAR* szUniqueID = NULL; - char* szProto = (char *)CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)hContact, 0); + char* szProto = GetContactProto(hContact); if (szProto != NULL) szUniqueID = getContactInfoT(CNF_UNIQUEID, hContact); @@ -172,7 +172,7 @@ static TCHAR *parseGetMostOnline(ARGUMENTSINFO *ai) TCHAR* res = NULL; TCHAR* szUniqueID = NULL; - char* szProto = (char *)CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)hContact, 0); + char* szProto = GetContactProto(hContact); if (szProto != NULL) szUniqueID = getContactInfoT(CNF_UNIQUEID, hContact); diff --git a/plugins/Variables/src/parse_miranda.cpp b/plugins/Variables/src/parse_miranda.cpp index f5492eea77..178fe6eb68 100644 --- a/plugins/Variables/src/parse_miranda.cpp +++ b/plugins/Variables/src/parse_miranda.cpp @@ -476,7 +476,7 @@ static TCHAR *parseSpecialContact(ARGUMENTSINFO *ai) ai->flags |= AIF_DONTPARSE; TCHAR *res = NULL; TCHAR *szUniqueID = NULL; - char *szProto = (char *)CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)ai->fi->hContact, 0); + char *szProto = GetContactProto(ai->fi->hContact); if (szProto != NULL) szUniqueID = getContactInfoT(CNF_UNIQUEID, ai->fi->hContact); diff --git a/plugins/WhenWasIt/src/WhenWasIt.cpp b/plugins/WhenWasIt/src/WhenWasIt.cpp index de77127c7e..c99b540a22 100644 --- a/plugins/WhenWasIt/src/WhenWasIt.cpp +++ b/plugins/WhenWasIt/src/WhenWasIt.cpp @@ -29,8 +29,6 @@ int hLangpack; CommonData commonData = {0}; - - PLUGININFOEX pluginInfo = { sizeof(PLUGININFOEX), __PLUGIN_DISPLAY_NAME, @@ -41,13 +39,12 @@ PLUGININFOEX pluginInfo = { __COPYRIGHT, __AUTHORWEB, UNICODE_AWARE, - {0x2ff96c84, 0xb0b5, 0x470e, {0xbb, 0xf9, 0x90, 0x7b, 0x9f, 0x3f, 0x5d, 0x2f}} //{2ff96c84-b0b5-470e-bbf9-907b9f3f5d2f} + //{2ff96c84-b0b5-470e-bbf9-907b9f3f5d2f} + {0x2ff96c84, 0xb0b5, 0x470e, {0xbb, 0xf9, 0x90, 0x7b, 0x9f, 0x3f, 0x5d, 0x2f}} }; extern "C" __declspec(dllexport) PLUGININFOEX *MirandaPluginInfoEx(DWORD mirandaVersion) { -// Log("%s", "Entering function " __FUNCTION__); -// Log("%s", "Leaving function " __FUNCTION__); return &pluginInfo; } @@ -62,22 +59,15 @@ extern "C" int __declspec(dllexport) Load(void) mir_getLP(&pluginInfo); INITCOMMONCONTROLSEX icex; - icex.dwSize = sizeof(icex); icex.dwICC = ICC_DATE_CLASSES; - InitCommonControlsEx(&icex); - Log("%s", "Initialising miranda memory functions"); - LoadIcons(); - //hBirthdaysDlg = CreateDialog(hInstance, MAKEINTRESOURCE(IDD_BIRTHDAYS), NULL, DlgProcBirthdays); + Log("%s", "Creating service functions ..."); InitServices(); - - //Log("%s", "Creating events ..."); - //CreateEvents(); - + Log("%s", "Hooking events ..."); HookEvents(); @@ -93,14 +83,10 @@ extern "C" int __declspec(dllexport) Unload() Log("%s", "Entering function " __FUNCTION__); if (hBirthdaysDlg) - { SendMessage(hBirthdaysDlg, WM_CLOSE, 0, 0); - } if (hUpcomingDlg) - { SendMessage(hUpcomingDlg, WM_CLOSE, 0, 0); - } WindowList_Broadcast(hAddBirthdayWndsList, WM_CLOSE, 0, 0); @@ -112,10 +98,8 @@ extern "C" int __declspec(dllexport) Unload() Log("%s", "Destroying service functions ..."); DestroyServices(); - - + Log("%s", "Leaving function " __FUNCTION__); - return 0; } @@ -123,9 +107,7 @@ bool WINAPI DllMain(HINSTANCE hinstDLL,DWORD fdwReason,LPVOID lpvReserved) { hInstance = hinstDLL; if (fdwReason == DLL_PROCESS_ATTACH) - { - DisableThreadLibraryCalls(hinstDLL); - } - + DisableThreadLibraryCalls(hinstDLL); + return TRUE; } diff --git a/plugins/WhenWasIt/src/birthdays.cpp b/plugins/WhenWasIt/src/birthdays.cpp index baed614aad..d69207b444 100644 --- a/plugins/WhenWasIt/src/birthdays.cpp +++ b/plugins/WhenWasIt/src/birthdays.cpp @@ -90,7 +90,7 @@ void CBirthdays::Realloc(int increaseCapacity) int CBirthdays::Add(HANDLE hContact, HANDLE hClistIcon) { - if (!Contains(hContact)) + if ( !Contains(hContact)) { EnsureCapacity(); TBirthdayContact *item = (TBirthdayContact *) malloc(sizeof(TBirthdayContact)); diff --git a/plugins/WhenWasIt/src/date_utils.cpp b/plugins/WhenWasIt/src/date_utils.cpp index e35710a2ca..856a2711ab 100644 --- a/plugins/WhenWasIt/src/date_utils.cpp +++ b/plugins/WhenWasIt/src/date_utils.cpp @@ -31,58 +31,43 @@ time_t Today() int IsDOBValid(int year, int month, int day) { - return ((year != 0) && (month != 0) && (day != 0)); + return (year != 0 && month != 0 && day != 0); } int GetContactDOB(HANDLE hContact, int &year, int &month, int &day) { - int res = DOB_USERINFO; - - //TCHAR *contact = GetContactName(hContact, NULL); - year = DBGetContactSettingWord(hContact, "UserInfo", "DOBy", 0); - month = DBGetContactSettingByte(hContact, "UserInfo", "DOBm", 0); - day = DBGetContactSettingByte(hContact, "UserInfo", "DOBd", 0); - - if (!IsDOBValid(year, month, day)) - { - res = DOB_MBIRTHDAY; - year = DBGetContactSettingWord(hContact, "mBirthday", "BirthYear", 0); - month = DBGetContactSettingByte(hContact, "mBirthday", "BirthMonth", 0); - day = DBGetContactSettingByte(hContact, "mBirthday", "BirthDay", 0); - } - - if (!IsDOBValid(year, month, day)) - { - res = DOB_PROTOCOL; - char protocol[512]; - GetContactProtocol(hContact, protocol, sizeof(protocol)); - year = DBGetContactSettingWord(hContact, protocol, "BirthYear", 0); - month = DBGetContactSettingByte(hContact, protocol, "BirthMonth", 0); - day = DBGetContactSettingByte(hContact, protocol, "BirthDay", 0); - } - - if (!IsDOBValid(year, month, day)) - { - res = DOB_BIRTHDAYREMINDER; - year = DBGetContactSettingWord(hContact, "BirthDay", "BirthYear", 0); - month = DBGetContactSettingByte(hContact, "BirthDay", "BirthMonth", 0); - day = DBGetContactSettingByte(hContact, "BirthDay", "BirthDay", 0); - } - - if (!IsDOBValid(year, month, day)) - { - res = DOB_MICQBIRTHDAY; - year = DBGetContactSettingDword(hContact, "micqBirthday", "BirthYear", 0); - month = DBGetContactSettingDword(hContact, "micqBirthday", "BirthMonth", 0); - day = DBGetContactSettingDword(hContact, "micqBirthday", "BirthDay", 0); - } - - if (!IsDOBValid(year, month, day)) - { - res = DOB_UNKNOWN; - } - //free(contact); - return res; + year = db_get_w(hContact, "UserInfo", "DOBy", 0); + month = db_get_b(hContact, "UserInfo", "DOBm", 0); + day = db_get_b(hContact, "UserInfo", "DOBd", 0); + if ( IsDOBValid(year, month, day)) + return DOB_USERINFO; + + year = db_get_w(hContact, "mBirthday", "BirthYear", 0); + month = db_get_b(hContact, "mBirthday", "BirthMonth", 0); + day = db_get_b(hContact, "mBirthday", "BirthDay", 0); + if ( IsDOBValid(year, month, day)) + return DOB_MBIRTHDAY; + + char *szProto = GetContactProto(hContact); + year = db_get_w(hContact, szProto, "BirthYear", 0); + month = db_get_b(hContact, szProto, "BirthMonth", 0); + day = db_get_b(hContact, szProto, "BirthDay", 0); + if ( IsDOBValid(year, month, day)) + return DOB_PROTOCOL; + + year = db_get_w(hContact, "BirthDay", "BirthYear", 0); + month = db_get_b(hContact, "BirthDay", "BirthMonth", 0); + day = db_get_b(hContact, "BirthDay", "BirthDay", 0); + if ( IsDOBValid(year, month, day)) + return DOB_BIRTHDAYREMINDER; + + year = db_get_dw(hContact, "micqBirthday", "BirthYear", 0); + month = db_get_dw(hContact, "micqBirthday", "BirthMonth", 0); + day = db_get_dw(hContact, "micqBirthday", "BirthDay", 0); + if ( IsDOBValid(year, month, day)) + return DOB_MICQBIRTHDAY; + + return DOB_UNKNOWN; } int GetContactAge(HANDLE hContact) @@ -97,43 +82,35 @@ int GetContactAge(HANDLE hContact) char GetContactGender(HANDLE hContact) { - char gender = DBGetContactSettingByte(hContact, "UserInfo", "Gender", 'U'); + char gender = db_get_b(hContact, "UserInfo", "Gender", 'U'); if (gender == 'U') - { - char protocol[512]; - GetContactProtocol(hContact, protocol, sizeof(protocol)); - - gender = DBGetContactSettingByte(hContact, protocol, "Gender", 'U'); - } + gender = db_get_b(hContact, GetContactProto(hContact), "Gender", 'U'); + return gender; } int IsLeapYear(int year) { - int yes = ((year % 400 == 0) || ((year % 4 == 0) && (year % 100 != 0))); - return yes; + return ((year % 400 == 0) || ((year % 4 == 0) && (year % 100 != 0))); } unsigned int GetDaysDifference(time_t time1, time_t time2) { errno = 0; double diff = difftime(time1, time2); - if (errno == 0) - { - diff = diff / (60 * 60 * 24); - int days = (int) floor(diff); - if (days < 0) - { - struct tm *date = gmtime(&time1); - int leap = 0; - if ((date->tm_mon > 2) && (IsLeapYear(date->tm_year))) //if month > feb and it's a leap year - { - leap = 1; - } - days = 365 + days + leap; - } - return days; + if (errno == 0) { + diff = diff / (60 * 60 * 24); + int days = (int) floor(diff); + if (days < 0) { + struct tm *date = gmtime(&time1); + int leap = 0; + if ((date->tm_mon > 2) && (IsLeapYear(date->tm_year))) //if month > feb and it's a leap year + leap = 1; + + days = 365 + days + leap; } + return days; + } return 0x7fffffff; } @@ -158,37 +135,34 @@ int GetDaysDifferenceAfter(time_t time1, time_t time2) unsigned int DaysToBirthday(time_t now, int ctYear, int ctMonth, int ctDay) { - if (IsDOBValid(ctYear, ctMonth, ctDay)) - { - struct tm ct = {0}; - struct tm *tmp = gmtime(&now); - ct.tm_year = tmp->tm_year; - ct.tm_mon = ctMonth - 1; - ct.tm_mday = ctDay; - time_t ctBirthday = mktime(&ct); - return GetDaysDifference(ctBirthday, now); - } + if ( IsDOBValid(ctYear, ctMonth, ctDay)) { + struct tm ct = {0}; + struct tm *tmp = gmtime(&now); + ct.tm_year = tmp->tm_year; + ct.tm_mon = ctMonth - 1; + ct.tm_mday = ctDay; + time_t ctBirthday = mktime(&ct); + return GetDaysDifference(ctBirthday, now); + } return -1; } int DaysAfterBirthday(time_t now, int ctYear, int ctMonth, int ctDay) { - if (IsDOBValid(ctYear, ctMonth, ctDay)) - { + if ( IsDOBValid(ctYear, ctMonth, ctDay)) { struct tm ct = {0}; struct tm *tmp = gmtime(&now); ct.tm_year = tmp->tm_year; ct.tm_mon = ctMonth - 1; ct.tm_mday = ctDay; time_t ctBirthday = mktime(&ct); - + return GetDaysDifferenceAfter(ctBirthday, now); } - + return -1; } - void FillProtocol(char *&sYear, char *&sMonth, char *&sDay) { sYear = "BirthYear"; @@ -218,66 +192,54 @@ int SaveBirthday(HANDLE hContact, int year, int month, int day, int mode) char *sYear, *sdYear, *sd2Year; char *sMonth, *sdMonth, *sd2Month; char *sDay, *sdDay, *sd2Day; - char protocol[256]; - GetContactProtocol(hContact, protocol, sizeof(protocol)); + char *protocol = GetContactProto(hContact); - switch (mode) - { - case SAVE_MODE_MBIRTHDAY: - { - FillmBirthday(sModule, sYear, sMonth, sDay); - FillStandard(sdModule, sdYear, sdMonth, sdDay); - sd2Module = protocol; - FillProtocol(sd2Year, sd2Month, sd2Day); - - break; - } - - case SAVE_MODE_PROTOCOL: - { - sModule = protocol; - FillProtocol(sYear, sMonth, sDay); - - FillmBirthday(sd2Module, sd2Year, sd2Month, sd2Day); - FillStandard(sdModule, sdYear, sdMonth, sdDay); - - break; - } - - case SAVE_MODE_STANDARD: - default: - { - FillStandard(sModule, sYear, sMonth, sDay); - FillmBirthday(sdModule, sdYear, sdMonth, sdDay); - sd2Module = protocol; - FillProtocol(sd2Year, sd2Month, sd2Day); - break; - } - } - - if (mode == SAVE_MODE_DELETEALL) - { - DBDeleteContactSetting(hContact, sModule, sYear); - DBDeleteContactSetting(hContact, sModule, sMonth); - DBDeleteContactSetting(hContact, sModule, sDay); - } - else{ - db_set_dw(hContact, sModule, sYear, year); - db_set_b(hContact, sModule, sMonth, month); - db_set_b(hContact, sModule, sDay, day); - } - - DBDeleteContactSetting(hContact, sdModule, sdYear); - DBDeleteContactSetting(hContact, sdModule, sdMonth); - DBDeleteContactSetting(hContact, sdModule, sdDay); + switch (mode) { + case SAVE_MODE_MBIRTHDAY: + FillmBirthday(sModule, sYear, sMonth, sDay); + FillStandard(sdModule, sdYear, sdMonth, sdDay); + sd2Module = protocol; + FillProtocol(sd2Year, sd2Month, sd2Day); + break; + + case SAVE_MODE_PROTOCOL: + sModule = protocol; + FillProtocol(sYear, sMonth, sDay); + + FillmBirthday(sd2Module, sd2Year, sd2Month, sd2Day); + FillStandard(sdModule, sdYear, sdMonth, sdDay); + break; + + case SAVE_MODE_STANDARD: + default: + FillStandard(sModule, sYear, sMonth, sDay); + FillmBirthday(sdModule, sdYear, sdMonth, sdDay); + sd2Module = protocol; + FillProtocol(sd2Year, sd2Month, sd2Day); + break; + } + + if (mode == SAVE_MODE_DELETEALL) { + db_unset(hContact, sModule, sYear); + db_unset(hContact, sModule, sMonth); + db_unset(hContact, sModule, sDay); + } + else { + db_set_dw(hContact, sModule, sYear, year); + db_set_b(hContact, sModule, sMonth, month); + db_set_b(hContact, sModule, sDay, day); + } + + db_unset(hContact, sdModule, sdYear); + db_unset(hContact, sdModule, sdMonth); + db_unset(hContact, sdModule, sdDay); - DBDeleteContactSetting(hContact, sd2Module, sd2Year); - DBDeleteContactSetting(hContact, sd2Module, sd2Month); - DBDeleteContactSetting(hContact, sd2Module, sd2Day); + db_unset(hContact, sd2Module, sd2Year); + db_unset(hContact, sd2Module, sd2Month); + db_unset(hContact, sd2Module, sd2Day); - DBDeleteContactSetting(hContact, "BirthDay", "BirthYear"); - DBDeleteContactSetting(hContact, "BirthDay", "BirthMonth"); - DBDeleteContactSetting(hContact, "BirthDay", "BirthDay"); - + db_unset(hContact, "BirthDay", "BirthYear"); + db_unset(hContact, "BirthDay", "BirthMonth"); + db_unset(hContact, "BirthDay", "BirthDay"); return 0; -} \ No newline at end of file +} diff --git a/plugins/WhenWasIt/src/dlg_handlers.cpp b/plugins/WhenWasIt/src/dlg_handlers.cpp index 01eba03640..3f7f0f25cf 100644 --- a/plugins/WhenWasIt/src/dlg_handlers.cpp +++ b/plugins/WhenWasIt/src/dlg_handlers.cpp @@ -140,8 +140,6 @@ int EnlargeControl(HWND hCtrl, HWND hGroup, SIZE oldSize) int offset = (rect.right - rect.left) - oldSize.cx; SetWindowPos(hCtrl, HWND_TOP, 0, 0, size.cx + offset, oldSize.cy, SWP_NOMOVE); SetWindowPos(hCtrl, HWND_BOTTOM, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE); - //RedrawWindow(hCtrl, NULL, NULL, RDW_ERASE | RDW_INVALIDATE | RDW_ALLCHILDREN | RDW_ERASENOW); - return 0; } @@ -211,7 +209,6 @@ INT_PTR CALLBACK DlgProcOptions(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lPara CheckDlgButton(hWnd, IDC_OPENINBACKGROUND, (commonData.bOpenInBackground) ? BST_CHECKED : BST_UNCHECKED); CheckDlgButton(hWnd, IDC_NOBIRTHDAYS_POPUP, (commonData.bNoBirthdaysPopup) ? BST_CHECKED : BST_UNCHECKED); - //CheckDlgButton(hWnd, IDC_SHOW_CURRENT_AGE, (bShowCurrentAge) ? BST_CHECKED : BST_UNCHECKED); SendMessage(GetDlgItem(hWnd, IDC_AGE_COMBOBOX), CB_SETCURSEL, commonData.cShowAgeMode, 0); CheckDlgButton(hWnd, IDC_IGNORE_SUBCONTACTS, (commonData.bIgnoreSubcontacts) ? BST_CHECKED : BST_UNCHECKED); @@ -222,8 +219,7 @@ INT_PTR CALLBACK DlgProcOptions(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lPara CheckDlgButton(hWnd, IDC_USE_DIALOG, (commonData.bUseDialog) ? BST_CHECKED : BST_UNCHECKED); EnableDialogGroup(hWnd, commonData.bUseDialog); - if (ServiceExists(MS_POPUP_ADDPOPUPEX)) - { + if (ServiceExists(MS_POPUP_ADDPOPUPEX)) { CheckDlgButton(hWnd, IDC_USE_POPUPS, commonData.bUsePopups ? BST_CHECKED : BST_UNCHECKED); EnablePopupsGroup(hWnd, commonData.bUsePopups); } @@ -325,7 +321,7 @@ INT_PTR CALLBACK DlgProcOptions(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lPara GetWindowText(GetDlgItem(hWnd, IDC_CHECK_INTERVAL), buffer, maxSize); commonData.checkInterval = _ttol(buffer); - if (!commonData.checkInterval) { commonData.checkInterval = CHECK_INTERVAL; } + if ( !commonData.checkInterval) { commonData.checkInterval = CHECK_INTERVAL; } GetWindowText(GetDlgItem(hWnd, IDC_POPUP_TIMEOUT), buffer, maxSize); TCHAR *pos; @@ -421,16 +417,14 @@ INT_PTR CALLBACK DlgProcAddBirthday(HWND hWnd, UINT msg, WPARAM wParam, LPARAM l HANDLE hContact = (HANDLE) GetWindowLongPtr(hWnd, GWLP_USERDATA); const int maxSize = 2048; TCHAR buffer[maxSize]; - char protocol[256]; - GetContactProtocol(hContact, protocol, sizeof(protocol)); - + char *protocol = GetContactProto(hContact); TCHAR *name = GetContactName(hContact, protocol); _stprintf(buffer, TranslateT("Set birthday for %s:"), name); free(name); SetWindowText(hWnd, buffer); HWND hDate = GetDlgItem(hWnd, IDC_DATE); int loc = GetContactDOB(hContact, year, month, day); - if (IsDOBValid(year, month, day)) { + if ( IsDOBValid(year, month, day)) { SYSTEMTIME st = {0}; st.wDay = day; st.wMonth = month; @@ -470,7 +464,7 @@ INT_PTR CALLBACK DlgProcAddBirthday(HWND hWnd, UINT msg, WPARAM wParam, LPARAM l szCurrentModuleTooltip = NULL; break; } - //CreateToolTip(GetDlgItem(hWnd, IDC_COMPATIBILITY), hWnd, szTooltipText); + CreateToolTip(GetDlgItem(hWnd, IDC_COMPATIBILITY), szTooltipText, 500); if (szCurrentModuleTooltip) CreateToolTip(hDate, szCurrentModuleTooltip, 400); @@ -497,14 +491,11 @@ INT_PTR CALLBACK DlgProcAddBirthday(HWND hWnd, UINT msg, WPARAM wParam, LPARAM l SYSTEMTIME st; HANDLE hContact = (HANDLE) GetWindowLongPtr(hWnd, GWLP_USERDATA); HWND hDate = GetDlgItem(hWnd, IDC_DATE); - if (DateTime_GetSystemtime(hDate, &st) == GDT_VALID) - { + if (DateTime_GetSystemtime(hDate, &st) == GDT_VALID) { int mode = SendMessage(GetDlgItem(hWnd, IDC_COMPATIBILITY), CB_GETCURSEL, 0, 0); //SAVE modes in date_utils.h are synced SaveBirthday(hContact, st.wYear, st.wMonth, st.wDay, mode); } - else{ - SaveBirthday(hContact, 0, 0, 0, SAVE_MODE_DELETEALL); - } + else SaveBirthday(hContact, 0, 0, 0, SAVE_MODE_DELETEALL); if (hBirthdaysDlg != NULL) SendMessage(hBirthdaysDlg, WWIM_UPDATE_BIRTHDAY, (WPARAM) hContact, NULL); @@ -530,54 +521,31 @@ void AddAnchorWindowToDeferList(HDWP &hdWnds, HWND window, RECT *rParent, WINDOW TCHAR *GetBirthdayModule(int module, HANDLE hContact, TCHAR *birthdayModule, int size) { - switch (module) - { - case DOB_MBIRTHDAY: - { - _tcsncpy(birthdayModule, _T("mBirthday"), size); - - break; - } - - case DOB_PROTOCOL: - { - char protocol[512]; - GetContactProtocol(hContact, protocol, sizeof(protocol)); + switch (module) { + case DOB_MBIRTHDAY: + _tcsncpy(birthdayModule, _T("mBirthday"), size); + break; - _sntprintf(birthdayModule, size, TranslateT("%S protocol"), protocol); + case DOB_PROTOCOL: + _sntprintf(birthdayModule, size, TranslateT("%S protocol"), GetContactProto(hContact)); + break; - - break; - } - - case DOB_BIRTHDAYREMINDER: - { - _tcsncpy(birthdayModule, _T("Birthday Reminder"), size); - - break; - } - - case DOB_USERINFO: - { - _tcsncpy(birthdayModule, _T("UserInfo"), size); - - break; - } + case DOB_BIRTHDAYREMINDER: + _tcsncpy(birthdayModule, _T("Birthday Reminder"), size); + break; - case DOB_MICQBIRTHDAY: - { - _tcsncpy(birthdayModule, _T("mICQBirthday"), size); + case DOB_USERINFO: + _tcsncpy(birthdayModule, _T("UserInfo"), size); + break; - break; - } - - default: - { - _tcsncpy(birthdayModule, NA, size); - - break; - } - } + case DOB_MICQBIRTHDAY: + _tcsncpy(birthdayModule, _T("mICQBirthday"), size); + break; + + default: + _tcsncpy(birthdayModule, NA, size); + break; + } return birthdayModule; } @@ -629,7 +597,7 @@ int UpdateBirthdayEntry(HWND hList, HANDLE hContact, int entry, int bShowAll, in int year, month, day; TCHAR *name; int module; - char protocol[512]; + char *protocol; LVITEM item = {0}; int currentYear; @@ -638,8 +606,7 @@ int UpdateBirthdayEntry(HWND hList, HANDLE hContact, int entry, int bShowAll, in int res = entry; - if (bShowCurrentAge) - { + if (bShowCurrentAge) { time_t now = Today(); struct tm *today = gmtime(&now); currentDay = today->tm_mday + 1; @@ -651,7 +618,7 @@ int UpdateBirthdayEntry(HWND hList, HANDLE hContact, int entry, int bShowAll, in item.iItem = entry; module = GetContactDOB(hContact, year, month, day); - if ((bShowAll) || (IsDOBValid(year, month, day))) { + if (bShowAll || IsDOBValid(year, month, day)) { lastColumn = -1; //list isn't sorted anymore dtb = DaysToBirthday(Today(), year, month, day); age = GetContactAge(hContact); @@ -661,7 +628,7 @@ int UpdateBirthdayEntry(HWND hList, HANDLE hContact, int entry, int bShowAll, in item.lParam = (LPARAM) hContact; - GetContactProtocol(hContact, protocol, sizeof(protocol)); + protocol = GetContactProto(hContact); MultiByteToWideChar(CP_ACP, MB_USEGLYPHCHARS, protocol, -1, buffer, maxSize); @@ -750,13 +717,11 @@ void SetBirthdaysCount(HWND hWnd) int LoadBirthdays(HWND hWnd, int bShowAll) { - HANDLE hContact = db_find_first(); HWND hList = GetDlgItem(hWnd, IDC_BIRTHDAYS_LIST); - //int bShowCurrentAge = DBGetContactSettingByte(NULL, ModuleName, "ShowCurrentAge", 0); - ListView_DeleteAllItems(hList); int count = 0; + HANDLE hContact = db_find_first(); while (hContact) { count = UpdateBirthdayEntry(hList, hContact, count, bShowAll, commonData.cShowAgeMode, 1); hContact = db_find_next(hContact); @@ -796,11 +761,11 @@ INT_PTR CALLBACK DlgProcBirthdays(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lPa col.cx = 50; ListView_InsertColumn(hList, 4, &col); col.pszText = TranslateT("Module"); - col.cx = 110; + col.cx = 108; ListView_InsertColumn(hList, 5, &col); LoadBirthdays(hWnd, 0); - int column = DBGetContactSettingByte(NULL, ModuleName, "SortColumn", 0); + int column = db_get_b(NULL, ModuleName, "SortColumn", 0); BirthdaysSortParams params = {0}; params.hList = GetDlgItem(hWnd, IDC_BIRTHDAYS_LIST); @@ -808,10 +773,8 @@ INT_PTR CALLBACK DlgProcBirthdays(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lPa ListView_SortItemsEx(params.hList, BirthdaysCompare, (LPARAM) ¶ms); Utils_RestoreWindowPosition(hWnd,NULL,ModuleName,"BirthdayList"); - - return TRUE; - break; } + return TRUE; case WM_DESTROY: hBirthdaysDlg = NULL; @@ -829,7 +792,7 @@ INT_PTR CALLBACK DlgProcBirthdays(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lPa HANDLE hContact = (HANDLE) wParam; int i; int count = ListView_GetItemCount(hList); - //int bShowCurrentAge = DBGetContactSettingByte(NULL, ModuleName, "ShowCurrentAge", 0); + //int bShowCurrentAge = db_get_b(NULL, ModuleName, "ShowCurrentAge", 0); LVITEM item = {0}; int found = 0; @@ -842,7 +805,7 @@ INT_PTR CALLBACK DlgProcBirthdays(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lPa found = 1; } } - if (!found) + if ( !found) UpdateBirthdayEntry(hList, hContact, count, IsDlgButtonChecked(hWnd, IDC_SHOW_ALL), commonData.cShowAgeMode, 1); SetBirthdaysCount(hWnd); @@ -1053,4 +1016,4 @@ INT_PTR CALLBACK DlgProcPopup(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) } return DefWindowProc(hWnd, msg, wParam, lParam); -} \ No newline at end of file +} diff --git a/plugins/WhenWasIt/src/hooked_events.cpp b/plugins/WhenWasIt/src/hooked_events.cpp index 26ba840ee5..fc47b37771 100644 --- a/plugins/WhenWasIt/src/hooked_events.cpp +++ b/plugins/WhenWasIt/src/hooked_events.cpp @@ -219,8 +219,8 @@ int OnExtraImageApply(WPARAM wParam, LPARAM lParam) return 0; int count = CallService(MS_DB_CONTACT_GETCOUNT, 0, 0); - int hidden = DBGetContactSettingByte(hContact, "CList", "Hidden", 0); - int ignored = DBGetContactSettingDword(hContact, "Ignore", "Mask1", 0); + int hidden = db_get_b(hContact, "CList", "Hidden", 0); + int ignored = db_get_dw(hContact, "Ignore", "Mask1", 0); ignored = ((ignored & 0x3f) != 0) ? 1 : 0; int ok = 1; if (commonData.notifyFor & EXCLUDE_HIDDEN) @@ -274,10 +274,10 @@ int UpdateTimers() hCheckTimer = NULL; } - long interval = DBGetContactSettingDword(NULL, ModuleName, "Interval", CHECK_INTERVAL); + long interval = db_get_dw(NULL, ModuleName, "Interval", CHECK_INTERVAL); interval *= 1000 * 60 * 60; //go from miliseconds to hours hCheckTimer = SetTimer(NULL, 0, interval, (TIMERPROC) OnCheckTimer); - if (!hDateChangeTimer) + if ( !hDateChangeTimer) hDateChangeTimer = SetTimer(NULL, 0, 1000 * DATE_CHANGE_CHECK_INTERVAL, (TIMERPROC) OnDateChangeTimer); return 0; diff --git a/plugins/WhenWasIt/src/icons.cpp b/plugins/WhenWasIt/src/icons.cpp index 6ac1627e97..d8099345f0 100644 --- a/plugins/WhenWasIt/src/icons.cpp +++ b/plugins/WhenWasIt/src/icons.cpp @@ -121,7 +121,7 @@ void FreeIcon(HICON &icon) void FreeIcons() { static int bFreed = 0; - if (!bFreed) { + if ( !bFreed) { FreeIcon(hiCheckMenu); FreeIcon(hiListMenu); FreeIcon(hiAddBirthdayContact); diff --git a/plugins/WhenWasIt/src/notifiers.cpp b/plugins/WhenWasIt/src/notifiers.cpp index 7bc8e437ec..0c82dfadfc 100644 --- a/plugins/WhenWasIt/src/notifiers.cpp +++ b/plugins/WhenWasIt/src/notifiers.cpp @@ -70,7 +70,7 @@ int PopupNotifyBirthday(HANDLE hContact, int dtb, int age) TCHAR *name = GetContactName(hContact, NULL); const int MAX_SIZE = 1024; TCHAR text[MAX_SIZE]; - //int bIgnoreSubcontacts = DBGetContactSettingByte(NULL, ModuleName, "IgnoreSubcontacts", FALSE); + //int bIgnoreSubcontacts = db_get_b(NULL, ModuleName, "IgnoreSubcontacts", FALSE); if (commonData.bIgnoreSubcontacts) { HANDLE hMetacontact = (HANDLE) CallService(MS_MC_GETMETACONTACT, (WPARAM) hContact, 0); @@ -122,7 +122,7 @@ int PopupNotifyMissedBirthday(HANDLE hContact, int dab, int age) TCHAR *name = GetContactName(hContact, NULL); const int MAX_SIZE = 1024; TCHAR text[MAX_SIZE]; - //int bIgnoreSubcontacts = DBGetContactSettingByte(NULL, ModuleName, "IgnoreSubcontacts", FALSE); + //int bIgnoreSubcontacts = db_get_b(NULL, ModuleName, "IgnoreSubcontacts", FALSE); if (commonData.bIgnoreSubcontacts) { HANDLE hMetacontact = (HANDLE) CallService(MS_MC_GETMETACONTACT, (WPARAM) hContact, 0); if (hMetacontact && hMetacontact != hContact) //not main metacontact @@ -174,7 +174,7 @@ int DialogNotifyBirthday(HANDLE hContact, int dtb, int age) TCHAR text[MAX_SIZE]; BuildDTBText(dtb, name, text, MAX_SIZE); - if (!hUpcomingDlg) { + if ( !hUpcomingDlg) { hUpcomingDlg = CreateDialog(hInstance, MAKEINTRESOURCE(IDD_UPCOMING), NULL, DlgProcUpcoming); ShowWindow(hUpcomingDlg, commonData.bOpenInBackground ? SW_SHOWNOACTIVATE : SW_SHOW); } @@ -200,7 +200,7 @@ int DialogNotifyMissedBirthday(HANDLE hContact, int dab, int age) TCHAR text[MAX_SIZE]; BuildDABText(dab, name, text, MAX_SIZE); - if (!hUpcomingDlg) { + if ( !hUpcomingDlg) { hUpcomingDlg = CreateDialog(hInstance, MAKEINTRESOURCE(IDD_UPCOMING), NULL, DlgProcUpcoming); ShowWindow(hUpcomingDlg, commonData.bOpenInBackground ? SW_SHOWNOACTIVATE : SW_SHOW); } diff --git a/plugins/WhenWasIt/src/services.cpp b/plugins/WhenWasIt/src/services.cpp index 76e9b36518..32241b33b9 100644 --- a/plugins/WhenWasIt/src/services.cpp +++ b/plugins/WhenWasIt/src/services.cpp @@ -37,26 +37,26 @@ int InitServices() { Log("%s", "Entering function " __FUNCTION__); - commonData.foreground = DBGetContactSettingDword(NULL, ModuleName, "Foreground", FOREGROUND_COLOR); - commonData.background = DBGetContactSettingDword(NULL, ModuleName, "Background", BACKGROUND_COLOR); - commonData.checkInterval = DBGetContactSettingWord(NULL, ModuleName, "CheckInterval", CHECK_INTERVAL); - commonData.daysInAdvance = DBGetContactSettingWord(NULL, ModuleName, "DaysInAdvance", DAYS_TO_NOTIFY); - commonData.daysAfter = DBGetContactSettingWord(NULL, ModuleName, "DaysAfter", DAYS_TO_NOTIFY_AFTER); - commonData.popupTimeout = DBGetContactSettingWord(NULL, ModuleName, "PopupTimeout", POPUP_TIMEOUT); - commonData.popupTimeoutToday = DBGetContactSettingWord(NULL, ModuleName, "PopupTimeoutToday", commonData.popupTimeout); - commonData.bUsePopups = DBGetContactSettingByte(NULL, ModuleName, "UsePopups", TRUE); - commonData.bUseDialog = DBGetContactSettingByte(NULL, ModuleName, "UseDialog", TRUE); - commonData.bIgnoreSubcontacts = DBGetContactSettingByte(NULL, ModuleName, "IgnoreSubcontacts", FALSE); - commonData.cShowAgeMode = DBGetContactSettingByte(NULL, ModuleName, "ShowCurrentAge", FALSE); - commonData.bNoBirthdaysPopup = DBGetContactSettingByte(NULL, ModuleName, "NoBirthdaysPopup", FALSE); - commonData.bOpenInBackground = DBGetContactSettingByte(NULL, ModuleName, "OpenInBackground", FALSE); - commonData.cSoundNearDays = DBGetContactSettingByte(NULL, ModuleName, "SoundNearDays", BIRTHDAY_NEAR_DEFAULT_DAYS); - commonData.cDefaultModule = DBGetContactSettingByte(NULL, ModuleName, "DefaultModule", 0); - commonData.lPopupClick = DBGetContactSettingByte(NULL, ModuleName, "PopupLeftClick", 2); - commonData.rPopupClick = DBGetContactSettingByte(NULL, ModuleName, "PopupRightClick", 1); - commonData.bOncePerDay = DBGetContactSettingByte(NULL, ModuleName, "OncePerDay", 0); - commonData.cDlgTimeout = DBGetContactSettingWord(NULL, ModuleName, "DlgTimeout", POPUP_TIMEOUT); - commonData.notifyFor = DBGetContactSettingByte(NULL, ModuleName, "NotifyFor", 0); + commonData.foreground = db_get_dw(NULL, ModuleName, "Foreground", FOREGROUND_COLOR); + commonData.background = db_get_dw(NULL, ModuleName, "Background", BACKGROUND_COLOR); + commonData.checkInterval = db_get_w(NULL, ModuleName, "CheckInterval", CHECK_INTERVAL); + commonData.daysInAdvance = db_get_w(NULL, ModuleName, "DaysInAdvance", DAYS_TO_NOTIFY); + commonData.daysAfter = db_get_w(NULL, ModuleName, "DaysAfter", DAYS_TO_NOTIFY_AFTER); + commonData.popupTimeout = db_get_w(NULL, ModuleName, "PopupTimeout", POPUP_TIMEOUT); + commonData.popupTimeoutToday = db_get_w(NULL, ModuleName, "PopupTimeoutToday", commonData.popupTimeout); + commonData.bUsePopups = db_get_b(NULL, ModuleName, "UsePopups", TRUE); + commonData.bUseDialog = db_get_b(NULL, ModuleName, "UseDialog", TRUE); + commonData.bIgnoreSubcontacts = db_get_b(NULL, ModuleName, "IgnoreSubcontacts", FALSE); + commonData.cShowAgeMode = db_get_b(NULL, ModuleName, "ShowCurrentAge", FALSE); + commonData.bNoBirthdaysPopup = db_get_b(NULL, ModuleName, "NoBirthdaysPopup", FALSE); + commonData.bOpenInBackground = db_get_b(NULL, ModuleName, "OpenInBackground", FALSE); + commonData.cSoundNearDays = db_get_b(NULL, ModuleName, "SoundNearDays", BIRTHDAY_NEAR_DEFAULT_DAYS); + commonData.cDefaultModule = db_get_b(NULL, ModuleName, "DefaultModule", 0); + commonData.lPopupClick = db_get_b(NULL, ModuleName, "PopupLeftClick", 2); + commonData.rPopupClick = db_get_b(NULL, ModuleName, "PopupRightClick", 1); + commonData.bOncePerDay = db_get_b(NULL, ModuleName, "OncePerDay", 0); + commonData.cDlgTimeout = db_get_w(NULL, ModuleName, "DlgTimeout", POPUP_TIMEOUT); + commonData.notifyFor = db_get_b(NULL, ModuleName, "NotifyFor", 0); hsCheckBirthdays = CreateServiceFunction(MS_WWI_CHECK_BIRTHDAYS, CheckBirthdaysService); hsShowList = CreateServiceFunction(MS_WWI_LIST_SHOW, ShowListService); @@ -94,9 +94,8 @@ int NotifyContactBirthday(HANDLE hContact, time_t now, int daysInAdvance) GetContactDOB(hContact, year, month, day); int daysToBirthday = DaysToBirthday(now, year, month, day); if (daysInAdvance >= daysToBirthday) - { - return daysToBirthday; - } + return daysToBirthday; + return -1; } @@ -120,15 +119,15 @@ int NotifyMissedContactBirthday(HANDLE hContact, time_t now, int daysAfter) //the timer functions call this service with lParam = 1 //lParam = 0 - force check, lParam - 1 do not force it. + INT_PTR CheckBirthdaysService(WPARAM wParam, LPARAM lParam) { bBirthdayFound = 0; //no birthdays have been found in the given interval - //int bNoBirthdaysPopup = DBGetContactSettingByte(NULL, ModuleName, "NoBirthdaysPopup", FALSE); SYSTEMTIME today; GetLocalTime(&today); - DWORD lastChecked = DBGetContactSettingDword(NULL, ModuleName, "LastChecked", 0); //get last checked date + DWORD lastChecked = db_get_dw(NULL, ModuleName, "LastChecked", 0); //get last checked date int lcDay = LOBYTE(LOWORD(lastChecked)); int lcMonth = HIBYTE(LOWORD(lastChecked)); int lcYear = HIWORD(lastChecked); @@ -139,42 +138,32 @@ INT_PTR CheckBirthdaysService(WPARAM wParam, LPARAM lParam) savedDaysAfter = commonData.daysAfter; //save value if ((daysAfter > commonData.daysAfter) && (commonData.daysAfter > 0))//check for passed birthdays - { commonData.daysAfter = daysAfter; //bigger values of the two - } if ((lParam) && (commonData.bOncePerDay)) //if force check then we don't take OncePerDay into account - { - if ((lcDay == today.wDay) && (lcMonth == today.wMonth) && (lcYear == today.wYear)) - { + if (lcDay == today.wDay && lcMonth == today.wMonth && lcYear == today.wYear) return 0; //already checked today - } - } bShouldCheckBirthdays = 1; RefreshAllContactListIcons(); if ((!bBirthdayFound) && (commonData.bNoBirthdaysPopup)) - { PopupNotifyNoBirthdays(); - } + bShouldCheckBirthdays = 0; - + commonData.daysAfter = savedDaysAfter; //restore previous value if (lParam) //if not forced - i.e. timer check - { db_set_dw(NULL, ModuleName, "LastChecked", MAKELONG(MAKEWORD(today.wDay, today.wMonth), today.wYear)); //write the value in DB so we don't check again today - } return 0; } INT_PTR ShowListService(WPARAM wParam, LPARAM lParam) { - if (!hBirthdaysDlg) - { - hBirthdaysDlg = CreateDialog(hInstance, MAKEINTRESOURCE(IDD_BIRTHDAYS), NULL, DlgProcBirthdays); - } + if ( !hBirthdaysDlg) + hBirthdaysDlg = CreateDialog(hInstance, MAKEINTRESOURCE(IDD_BIRTHDAYS), NULL, DlgProcBirthdays); + ShowWindow(hBirthdaysDlg, SW_SHOW); return 0; } @@ -182,18 +171,16 @@ INT_PTR ShowListService(WPARAM wParam, LPARAM lParam) INT_PTR AddBirthdayService(WPARAM wParam, LPARAM lParam) { HWND hWnd = WindowList_Find(hAddBirthdayWndsList, (HANDLE) wParam); - if (!hWnd) - { - hWnd = CreateDialog(hInstance, MAKEINTRESOURCE(IDD_ADD_BIRTHDAY), NULL, DlgProcAddBirthday); - if (hWnd == NULL) - { - TCHAR buffer[1024]; - _stprintf(buffer, _T("Error #%d while trying to create add birthday dialog"), GetLastError()); - MessageBox(0, buffer, _T("Error"), MB_OK); - } - WindowList_Add(hAddBirthdayWndsList, hWnd, (HANDLE) wParam); - SetWindowLongPtr(hWnd, GWLP_USERDATA, wParam); + if ( !hWnd) { + hWnd = CreateDialog(hInstance, MAKEINTRESOURCE(IDD_ADD_BIRTHDAY), NULL, DlgProcAddBirthday); + if (hWnd == NULL) { + TCHAR buffer[1024]; + _stprintf(buffer, _T("Error #%d while trying to create add birthday dialog"), GetLastError()); + MessageBox(0, buffer, _T("Error"), MB_OK); } + WindowList_Add(hAddBirthdayWndsList, hWnd, (HANDLE) wParam); + SetWindowLongPtr(hWnd, GWLP_USERDATA, wParam); + } return ShowWindow(hWnd, SW_SHOW); } @@ -205,55 +192,39 @@ void ShowPopupMessage(TCHAR *title, TCHAR *message, HICON icon) _tcscpy(pd.lptzText, message); pd.colorText = commonData.foreground; pd.colorBack = commonData.background; - PUAddPopUpT(&pd); } DWORD WINAPI RefreshUserDetailsWorkerThread(LPVOID param) { - //MessageBox(0, "Inside worker thread", "Info", MB_OK); - //POPUPDATA pd = {0}; - //pd.lchIcon = hiRefreshUserDetails; - //strcpy(pd.lpzContactName, Translate("WhenWasIt")); - //strcpy(pd.lpzText, Translate("Starting to refresh user details")); - //PUAddPopUp(&pd); ShowPopupMessage(TranslateT("WhenWasIt"), TranslateT("Starting to refresh user details"), hiRefreshUserDetails); - int delay = DBGetContactSettingWord(NULL, ModuleName, "UpdateDelay", REFRESH_DETAILS_DELAY); - HANDLE hContact = db_find_first(); + int delay = db_get_w(NULL, ModuleName, "UpdateDelay", REFRESH_DETAILS_DELAY); int res; - while (hContact != NULL) - { - res = CallContactService(hContact, PSS_GETINFO, 0, 0); - hContact = db_find_next(hContact); - if (hContact) - { - Sleep(delay); //sleep for a few seconds between requests - } - } - //strcpy(pd.lpzText, Translate("Done refreshing user details")); - //PUAddPopUp(&pd); + + HANDLE hContact = db_find_first(); + while (hContact != NULL) { + res = CallContactService(hContact, PSS_GETINFO, 0, 0); + hContact = db_find_next(hContact); + if (hContact) + Sleep(delay); //sleep for a few seconds between requests + } ShowPopupMessage(TranslateT("WhenWasIt"), TranslateT("Done refreshing user details"), hiRefreshUserDetails); - //MessageBox(0, "Leaving worker thread", "Info", MB_OK); return 0; } INT_PTR RefreshUserDetailsService(WPARAM wParam, LPARAM lParam) { DWORD threadID; - //MessageBox(0, "Before CreateThread()", "Info", MB_OK); HANDLE result = CreateThread(NULL, 0, RefreshUserDetailsWorkerThread, NULL, 0, &threadID); - //MessageBox(0, "After CreateThread()", "Info", MB_OK); - if (!result) - { - TCHAR buffer[1024]; - _stprintf(buffer, _T("Could not create worker thread. Error#%d - threadID %d"), GetLastError(), threadID); - MessageBox(0, buffer, _T("Error"), MB_OK | MB_ICONERROR); + if ( !result) { + TCHAR buffer[1024]; + _stprintf(buffer, _T("Could not create worker thread. Error#%d - threadID %d"), GetLastError(), threadID); + MessageBox(0, buffer, _T("Error"), MB_OK | MB_ICONERROR); } + if ((result != NULL) && (result != INVALID_HANDLE_VALUE)) - { CloseHandle(result); - } - + return 0; } @@ -270,16 +241,15 @@ INT_PTR ImportBirthdaysService(WPARAM wParam, LPARAM lParam) of.nMaxFile = 1024; of.lpstrTitle = TranslateT("Please select a file to import birthdays from ..."); of.Flags = OFN_FILEMUSTEXIST; - - if (GetOpenFileName(&of)) - { - TCHAR buffer[2048]; - mir_sntprintf(buffer, SIZEOF(buffer), TranslateT("Importing birthdays from file: %s"), fileName); - ShowPopupMessage(TranslateT("WhenWasIt"), buffer, hiImportBirthdays); - DoImport(fileName); - ShowPopupMessage(TranslateT("WhenWasIt"), TranslateT("Done importing birthdays"), hiImportBirthdays); - } - + + if ( GetOpenFileName(&of)) { + TCHAR buffer[2048]; + mir_sntprintf(buffer, SIZEOF(buffer), TranslateT("Importing birthdays from file: %s"), fileName); + ShowPopupMessage(TranslateT("WhenWasIt"), buffer, hiImportBirthdays); + DoImport(fileName); + ShowPopupMessage(TranslateT("WhenWasIt"), TranslateT("Done importing birthdays"), hiImportBirthdays); + } + return 0; } @@ -295,126 +265,100 @@ INT_PTR ExportBirthdaysService(WPARAM wParam, LPARAM lParam) of.lpstrFile = fileName; of.nMaxFile = 1024; of.lpstrTitle = TranslateT("Please select a file to export birthdays to ..."); - //of.Flags = OFN_ENABLESIZING | OFN_EXPLORER; - - if (GetSaveFileName(&of)) - { - TCHAR buffer[2048]; - TCHAR *fn = _tcsrchr(fileName, _T('\\')) + 1; - if (!_tcschr(fn, _T('.'))) - { - _tcscat(fileName, _T(BIRTHDAY_EXTENSION)); - } - _stprintf(buffer, TranslateT("Exporting birthdays to file: %s"), fileName); - ShowPopupMessage(TranslateT("WhenWasIt"), buffer, hiExportBirthdays); - DoExport(fileName); - ShowPopupMessage(TranslateT("WhenWasIt"), TranslateT("Done exporting birthdays"), hiExportBirthdays); - } - + + if ( GetSaveFileName(&of)) { + TCHAR buffer[2048]; + TCHAR *fn = _tcsrchr(fileName, _T('\\')) + 1; + if ( !_tcschr(fn, _T('.'))) + _tcscat(fileName, _T(BIRTHDAY_EXTENSION)); + + _stprintf(buffer, TranslateT("Exporting birthdays to file: %s"), fileName); + ShowPopupMessage(TranslateT("WhenWasIt"), buffer, hiExportBirthdays); + DoExport(fileName); + ShowPopupMessage(TranslateT("WhenWasIt"), TranslateT("Done exporting birthdays"), hiExportBirthdays); + } + return 0; } int DoImport(TCHAR *fileName) { FILE *fin = _tfopen(fileName, _T("rt")); - if (!fin) - { - MessageBox(0, _T("Could not open file to import birthdays"), _T("Error"), MB_OK | MB_ICONERROR); - return 1; - } + if ( !fin) { + MessageBox(0, _T("Could not open file to import birthdays"), _T("Error"), MB_OK | MB_ICONERROR); + return 1; + } - HANDLE hContact; - int year, month, day; - TCHAR *szHandle; - TCHAR *szProto; - const int maxSize = 4096; - TCHAR buffer[maxSize]; - int tmp, tmp2; - int mode = commonData.cDefaultModule; //DBGetContactSettingByte(NULL, ModuleName, "DefaultModule", 0); - TCHAR *delAccount, *delProto; + int mode = commonData.cDefaultModule; - while (!feof(fin)) - { - _fgetts(buffer, maxSize, fin); - if (buffer[0] == _T(COMMENT_CHAR)) - { - continue; - } + while (!feof(fin)) { + TCHAR buffer[4096]; + _fgetts(buffer, SIZEOF(buffer), fin); + if (buffer[0] == _T(COMMENT_CHAR)) + continue; + + TCHAR *delAccount = _tcsstr(buffer, _T(" : ")); + if (delAccount) { + int tmp = delAccount[0]; + delAccount[0] = _T('\0'); + TCHAR *delProto = _tcsrchr(buffer, _T('@')); + if (delProto) { + int tmp2 = delProto[0]; + delProto[0] = _T('\0'); + + TCHAR *szHandle = buffer; + TCHAR *szProto = delProto + 1; + HANDLE hContact = GetContactFromID(szHandle, szProto); + if (hContact) { + delProto[0] = tmp; + delAccount[0] = tmp; - delAccount = _tcsstr(buffer, _T(" : ")); - if (delAccount) - { - tmp = delAccount[0]; - delAccount[0] = _T('\0'); - delProto = _tcsrchr(buffer, _T('@')); - if (delProto) - { - tmp2 = delProto[0]; - delProto[0] = _T('\0'); - - szHandle = buffer; - szProto = delProto + 1; - hContact = GetContactFromID(szHandle, szProto); - if (hContact) - { - delProto[0] = tmp; - delAccount[0] = tmp; - _stscanf(delAccount, _T(" : %02d/%02d/%04d"), &day, &month, &year); - SaveBirthday(hContact, year, month, day, mode); - } - else{ - TCHAR tmp[2048]; - _stprintf(tmp, TranslateT(NOTFOUND_FORMAT), szHandle, szProto); - ShowPopupMessage(TranslateT("Warning"), tmp, hiImportBirthdays); - } - } + int year, month, day; + _stscanf(delAccount, _T(" : %02d/%02d/%04d"), &day, &month, &year); + SaveBirthday(hContact, year, month, day, mode); + } + else { + TCHAR tmp[2048]; + _stprintf(tmp, TranslateT(NOTFOUND_FORMAT), szHandle, szProto); + ShowPopupMessage(TranslateT("Warning"), tmp, hiImportBirthdays); } + } } - - fclose(fin); + } + fclose(fin); return 0; } int DoExport(TCHAR *fileName) { FILE *fout = _tfopen(fileName, _T("wt")); - if (!fout) - { - MessageBox(0, _T("Could not open file to export birthdays"), _T("Error"), MB_OK | MB_ICONERROR); - return 1; - } + if ( !fout) { + MessageBox(0, _T("Could not open file to export birthdays"), _T("Error"), MB_OK | MB_ICONERROR); + return 1; + } _ftprintf(fout, _T("%c%s"), _T(COMMENT_CHAR), _T("Please do not edit this file by hand. Use the export function of WhenWasIt plugin.\n")); _ftprintf(fout, _T("%c%s"), _T(COMMENT_CHAR), _T("Warning! Please do not mix Unicode and Ansi exported birthday files. You should use the same version (Ansi/Unicode) of WhenWasIt that was used to export the info.\n")); - _ftprintf(fout, _T("%c%s"), _T(COMMENT_CHAR), _T("This file was exported with a Unicode version of WhenWasIt. Please only use a Unicode version of the plugin to import the birthdays.\n")); - + HANDLE hContact = db_find_first(); - int year, month, day; - TCHAR *szHandle; - char szProto[256]; - - while (hContact) - { - GetContactDOB(hContact, year, month, day); - if (IsDOBValid(year, month, day)) - { - szProto[0] = '\0'; - GetContactProtocol(hContact, szProto, sizeof(szProto)); - szHandle = GetContactID(hContact, szProto); - - if ((szHandle) && (strlen(szProto) > 0)) - { - _ftprintf(fout, _T(BIRTHDAYS_EXPORT_FORMAT), szHandle, szProto, day, month, year); - } - - if (szHandle) free(szHandle); - } - - hContact = db_find_next(hContact); + while (hContact) { + int year, month, day; + GetContactDOB(hContact, year, month, day); + if ( IsDOBValid(year, month, day)) { + char *szProto = GetContactProto(hContact); + TCHAR *szHandle = GetContactID(hContact, szProto); + + if ((szHandle) && (strlen(szProto) > 0)) + _ftprintf(fout, _T(BIRTHDAYS_EXPORT_FORMAT), szHandle, szProto, day, month, year); + + if (szHandle) + free(szHandle); } - + + hContact = db_find_next(hContact); + } + fclose(fout); - return 0; -} \ No newline at end of file +} diff --git a/plugins/WhenWasIt/src/utils.cpp b/plugins/WhenWasIt/src/utils.cpp index 96a86ee8be..9d59dd9067 100644 --- a/plugins/WhenWasIt/src/utils.cpp +++ b/plugins/WhenWasIt/src/utils.cpp @@ -37,7 +37,7 @@ int Log(char *format, ...) va_list vararg; int tBytes; FILE *fout = fopen(LOG_FILE, "at"); - if (!fout) + if ( !fout) { // MessageBox(0, "can't open file", NULL, MB_OK); return -1; @@ -159,161 +159,94 @@ int GetStringFromDatabase(char *szSettingName, char *szError, char *szResult, si #pragma warning (disable: 4312) TCHAR *GetContactName(HANDLE hContact, char *szProto) { - CONTACTINFO ctInfo; - int ret; - char proto[200]; - - ZeroMemory((void *) &ctInfo, sizeof(ctInfo)); - ctInfo.cbSize = sizeof(ctInfo); - if (szProto) - { - ctInfo.szProto = szProto; - } - else{ - GetContactProtocol(hContact, proto, sizeof(proto)); - ctInfo.szProto = proto; - } - ctInfo.dwFlag = CNF_DISPLAY; - - ctInfo.dwFlag += CNF_UNICODE; - + CONTACTINFO ctInfo = { sizeof(ctInfo) }; + ctInfo.szProto = (szProto) ? szProto : GetContactProto(hContact); + ctInfo.dwFlag = CNF_DISPLAY | CNF_UNICODE; ctInfo.hContact = hContact; //_debug_message("retrieving contact name for %d", hContact); - ret = CallService(MS_CONTACT_GETCONTACTINFO, 0, (LPARAM) &ctInfo); + int ret = CallService(MS_CONTACT_GETCONTACTINFO, 0, (LPARAM) &ctInfo); //_debug_message(" contact name %s", ctInfo.pszVal); TCHAR *buffer; - if (!ret) - { + if ( !ret) buffer = _tcsdup(ctInfo.pszVal); - } + mir_free(ctInfo.pszVal); if (ret) - { return NULL; - } return buffer; } -#pragma warning (default: 4312) - -#pragma warning (disable: 4312) -void GetContactProtocol(HANDLE hContact, char *szProto, int size) -{ - GetStringFromDatabase(hContact, "Protocol", "p", NULL, szProto, size); -} -#pragma warning (default: 4312) -#pragma warning (disable: 4312) TCHAR *GetContactID(HANDLE hContact) { - char protocol[256]; - GetContactProtocol(hContact, protocol, sizeof(protocol)); - - return GetContactID(hContact, protocol); + return GetContactID(hContact, GetContactProto(hContact)); } TCHAR *GetContactID(HANDLE hContact, char *szProto) { - CONTACTINFO ctInfo; - int ret; - - ZeroMemory((void *) &ctInfo, sizeof(ctInfo)); - ctInfo.cbSize = sizeof(ctInfo); + CONTACTINFO ctInfo = { sizeof(ctInfo) }; ctInfo.szProto = szProto; - ctInfo.dwFlag = CNF_UNIQUEID; - - ctInfo.dwFlag |= CNF_UNICODE; - + ctInfo.dwFlag = CNF_UNIQUEID | CNF_UNICODE; ctInfo.hContact = hContact; - ret = CallService(MS_CONTACT_GETCONTACTINFO, 0, (LPARAM) &ctInfo); + int ret = CallService(MS_CONTACT_GETCONTACTINFO, 0, (LPARAM) &ctInfo); TCHAR *buffer; - if (!ret) - { - TCHAR tmp[16]; - switch (ctInfo.type) - { - case CNFT_BYTE: - { - _stprintf(tmp, _T("%d"), ctInfo.bVal); - buffer = _tcsdup(tmp); - - break; - } - - case CNFT_WORD: - { - _stprintf(tmp, _T("%d"), ctInfo.wVal); - buffer = _tcsdup(tmp); - - break; - } - - case CNFT_DWORD: - { - _stprintf(tmp, _T("%ld"), ctInfo.dVal); - buffer = _tcsdup(tmp); - - break; - } - - case CNFT_ASCIIZ: - default: - { - buffer = _tcsdup(ctInfo.pszVal); - - break; - } - } - - + if ( !ret) { + TCHAR tmp[16]; + switch (ctInfo.type) { + case CNFT_BYTE: + _stprintf(tmp, _T("%d"), ctInfo.bVal); + buffer = _tcsdup(tmp); + break; + + case CNFT_WORD: + _stprintf(tmp, _T("%d"), ctInfo.wVal); + buffer = _tcsdup(tmp); + break; + + case CNFT_DWORD: + _stprintf(tmp, _T("%ld"), ctInfo.dVal); + buffer = _tcsdup(tmp); + break; + + default: + buffer = _tcsdup(ctInfo.pszVal); + break; } + } + mir_free(ctInfo.pszVal); - if (!ret) - { - return buffer; - } - else{ - return NULL; - } + return (!ret) ? buffer : NULL; } -#pragma warning (default: 4312) -#pragma warning (disable: 4312) HANDLE GetContactFromID(TCHAR *szID, char *szProto) { HANDLE hContact = db_find_first(); TCHAR *szHandle; - char cProtocol[256]; int found = 0; - while (hContact) - { - GetContactProtocol(hContact, cProtocol, sizeof(cProtocol)); - szHandle = GetContactID(hContact, cProtocol); - if ((szHandle) && (_tcsicmp(szHandle, szID) == 0) && (_stricmp(szProto, cProtocol) == 0)) - { - found = 1; - } - if (szHandle) free(szHandle); - - if (found) - { - break; - } - hContact = db_find_next(hContact); - } + while (hContact) { + char *szProto = GetContactProto(hContact); + szHandle = GetContactID(hContact, szProto); + if (szHandle && !_tcsicmp(szHandle, szID) && !_stricmp(szProto, szProto)) + found = 1; + + if (szHandle) + free(szHandle); + + if (found) + break; + + hContact = db_find_next(hContact); + } return hContact; } -#pragma warning (default: 4312) -#pragma warning (disable: 4312) HANDLE GetContactFromID(TCHAR *szID, wchar_t *szProto) { char protocol[1024]; WideCharToMultiByte(CP_ACP, 0, szProto, -1, protocol, sizeof(protocol), NULL, NULL); return GetContactFromID(szID, protocol); } -#pragma warning (default: 4312) void ScreenToClient(HWND hWnd, LPRECT rect) { @@ -331,37 +264,31 @@ void ScreenToClient(HWND hWnd, LPRECT rect) void AnchorMoveWindow(HWND window, const WINDOWPOS *parentPos, int anchors) { - RECT rParent; - RECT rChild; - if (parentPos->flags & SWP_NOSIZE) - { - return; - } + return; + + RECT rParent; GetWindowRect(parentPos->hwnd, &rParent); - rChild = AnchorCalcPos(window, &rParent, parentPos, anchors); + + RECT rChild = AnchorCalcPos(window, &rParent, parentPos, anchors); MoveWindow(window, rChild.left, rChild.top, rChild.right - rChild.left, rChild.bottom - rChild.top, FALSE); } RECT AnchorCalcPos(HWND window, const RECT *rParent, const WINDOWPOS *parentPos, int anchors) { RECT rChild; - RECT rTmp; - GetWindowRect(window, &rChild); ScreenToClient(parentPos->hwnd, &rChild); int cx = rParent->right - rParent->left; int cy = rParent->bottom - rParent->top; if ((cx == parentPos->cx) && (cy == parentPos->cy)) - { - return rChild; - } + return rChild; + if (parentPos->flags & SWP_NOSIZE) - { - return rChild; - } + return rChild; + RECT rTmp; rTmp.left = parentPos->x - rParent->left; rTmp.right = (parentPos->x + parentPos->cx) - rParent->right; rTmp.bottom = (parentPos->y + parentPos->cy) - rParent->bottom; @@ -374,20 +301,16 @@ RECT AnchorCalcPos(HWND window, const RECT *rParent, const WINDOWPOS *parentPos, rChild.bottom += cy; //expanded the window accordingly, now we need to enforce the anchors if ((anchors & ANCHOR_LEFT) && (!(anchors & ANCHOR_RIGHT))) - { - rChild.right -= cx; - } + rChild.right -= cx; + if ((anchors & ANCHOR_TOP) && (!(anchors & ANCHOR_BOTTOM))) - { - rChild.bottom -= cy; - } + rChild.bottom -= cy; + if ((anchors & ANCHOR_RIGHT) && (!(anchors & ANCHOR_LEFT))) - { - rChild.left += cx; - } + rChild.left += cx; + if ((anchors & ANCHOR_BOTTOM) && (!(anchors & ANCHOR_TOP))) - { - rChild.top += cy; - } + rChild.top += cy; + return rChild; } \ No newline at end of file diff --git a/plugins/WhenWasIt/src/utils.h b/plugins/WhenWasIt/src/utils.h index 6d76c72d2a..6468ab63bc 100644 --- a/plugins/WhenWasIt/src/utils.h +++ b/plugins/WhenWasIt/src/utils.h @@ -49,6 +49,5 @@ TCHAR *GetContactID(HANDLE hContact); TCHAR *GetContactID(HANDLE hContact, char *szProto); HANDLE GetContactFromID(TCHAR *szID, char *szProto); HANDLE GetContactFromID(TCHAR *szID, wchar_t *szProto); -void GetContactProtocol(HANDLE hContact, char *szProto, int size); #endif \ No newline at end of file -- cgit v1.2.3