From 5f8a607f900a42e27bf166b86185001aadf3e9f2 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Thu, 27 Feb 2014 13:50:53 +0000 Subject: more fun: - MS_AWAYMSG_GETSTATUSMSGW/T is present in any MIID_SRAWAY plugin, so there's no need to check its existence; - therefore MS_AWAYMSG_GETSTATUSMSG considered useless, cause it has no references git-svn-id: http://svn.miranda-ng.org/main/trunk@8293 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- plugins/BossKeyPlus/src/BossKey.cpp | 13 ++------- plugins/NewAwaySysMod/src/AwaySys.cpp | 1 - plugins/NewAwaySysMod/src/Services.cpp | 12 ++------- plugins/NewAwaySysMod/src/Services.h | 1 - plugins/SimpleStatusMsg/src/main.cpp | 13 +-------- .../StatusPlugins/AdvancedAutoAway/msgoptions.cpp | 21 +++++---------- plugins/StatusPlugins/commonstatus.cpp | 31 +++------------------- 7 files changed, 15 insertions(+), 77 deletions(-) (limited to 'plugins') diff --git a/plugins/BossKeyPlus/src/BossKey.cpp b/plugins/BossKeyPlus/src/BossKey.cpp index 15c0b1b480..188e1ec57f 100644 --- a/plugins/BossKeyPlus/src/BossKey.cpp +++ b/plugins/BossKeyPlus/src/BossKey.cpp @@ -201,16 +201,7 @@ BOOL CALLBACK EnumWindowsProc(HWND hWnd,LPARAM) TCHAR* GetDefStatusMsg(unsigned uStatus, const char* szProto) { - INT_PTR res = CallService (MS_AWAYMSG_GETSTATUSMSGT, (WPARAM)uStatus, (LPARAM)szProto ); - if (res == CALLSERVICE_NOTFOUND ) - { - char* tmp = ( char* )CallService(MS_AWAYMSG_GETSTATUSMSG, (WPARAM)uStatus, (LPARAM)szProto ); - TCHAR *ret = mir_a2t( tmp ); - mir_free( tmp ); - return ret; - } - else - return (TCHAR *) res; + return (TCHAR*)CallService (MS_AWAYMSG_GETSTATUSMSGT, uStatus, (LPARAM)szProto); } void SetStatus(const char* szProto, unsigned status, TCHAR *tszAwayMsg) @@ -220,7 +211,7 @@ void SetStatus(const char* szProto, unsigned status, TCHAR *tszAwayMsg) if ( CallProtoService( szProto, PS_SETAWAYMSGT, status, (LPARAM) tszAwayMsg ) == CALLSERVICE_NOTFOUND ) { char *szAwayMsg = mir_t2a(tszAwayMsg); - CallProtoService( szProto, PS_SETAWAYMSG, status, (LPARAM) szAwayMsg ); + CallProtoService( szProto, PS_SETAWAYMSG, status, (LPARAM)szAwayMsg ); mir_free(szAwayMsg); } } diff --git a/plugins/NewAwaySysMod/src/AwaySys.cpp b/plugins/NewAwaySysMod/src/AwaySys.cpp index 2ee9c2832a..bcfd76cecc 100644 --- a/plugins/NewAwaySysMod/src/AwaySys.cpp +++ b/plugins/NewAwaySysMod/src/AwaySys.cpp @@ -680,7 +680,6 @@ int MirandaLoaded(WPARAM, LPARAM) CreateServiceFunction(MS_AWAYSYS_AUTOREPLY_ON, srvAutoreplyOn); CreateServiceFunction(MS_AWAYSYS_AUTOREPLY_OFF, srvAutoreplyOff); CreateServiceFunction(MS_AWAYSYS_AUTOREPLY_USEDEFAULT, srvAutoreplyUseDefault); - CreateServiceFunction(MS_AWAYMSG_GETSTATUSMSG, GetStatusMsg); CreateServiceFunction(MS_AWAYMSG_GETSTATUSMSGW, GetStatusMsgW); CreateServiceFunction(MS_NAS_GETSTATEA, GetStateA); diff --git a/plugins/NewAwaySysMod/src/Services.cpp b/plugins/NewAwaySysMod/src/Services.cpp index bce50f84d3..686ad07cac 100644 --- a/plugins/NewAwaySysMod/src/Services.cpp +++ b/plugins/NewAwaySysMod/src/Services.cpp @@ -50,19 +50,11 @@ __inline void PSSetStatus(char *szProto, WORD Status, int bNoClistSetStatusMode // called by GamerStatus and built-in miranda autoaway module // wParam = (int)status, lParam = 0 // MS_AWAYMSG_GETSTATUSMSG "SRAway/GetStatusMessage" -INT_PTR GetStatusMsg(WPARAM wParam, LPARAM) -{ - LogMessage("MS_AWAYMSG_GETSTATUSMSG called. status=%d", wParam); - char *szMsg = mir_t2a(GetDynamicStatMsg(INVALID_CONTACT_ID, NULL, 0, wParam)); - LogMessage("returned szMsg:\n%s", szMsg ? szMsg : "NULL"); - return (INT_PTR)szMsg; -} - INT_PTR GetStatusMsgW(WPARAM wParam, LPARAM) { - LogMessage("MS_AWAYMSG_GETSTATUSMSG called. status=%d", wParam); + LogMessage("MS_AWAYMSG_GETSTATUSMSGW called. status=%d", wParam); WCHAR *szMsg = mir_t2u(GetDynamicStatMsg(INVALID_CONTACT_ID, NULL, 0, wParam)); - LogMessage("returned szMsg:\n%S", szMsg ? szMsg : L"NULL"); + LogMessage("returned szMsgW:\n%S", szMsg ? szMsg : L"NULL"); return (INT_PTR)szMsg; } diff --git a/plugins/NewAwaySysMod/src/Services.h b/plugins/NewAwaySysMod/src/Services.h index 2aac3c7cc0..ca81be7f75 100644 --- a/plugins/NewAwaySysMod/src/Services.h +++ b/plugins/NewAwaySysMod/src/Services.h @@ -17,7 +17,6 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -INT_PTR GetStatusMsg(WPARAM wParam, LPARAM lParam); INT_PTR GetStatusMsgW(WPARAM wParam, LPARAM lParam); INT_PTR SetStatusMode(WPARAM wParam, LPARAM lParam); // int IgnoreNextStatusChange(WPARAM wParam, LPARAM lParam); diff --git a/plugins/SimpleStatusMsg/src/main.cpp b/plugins/SimpleStatusMsg/src/main.cpp index f57160395d..530c769fa2 100644 --- a/plugins/SimpleStatusMsg/src/main.cpp +++ b/plugins/SimpleStatusMsg/src/main.cpp @@ -58,7 +58,7 @@ extern "C" __declspec(dllexport) PLUGININFOEX* MirandaPluginInfoEx(DWORD miranda return &pluginInfo; } -extern "C" __declspec(dllexport) const MUUID MirandaInterfaces[] = {MIID_SRAWAY, MIID_LAST}; +extern "C" __declspec(dllexport) const MUUID MirandaInterfaces[] = { MIID_SRAWAY, MIID_LAST }; #ifdef _DEBUG void log2file(const char *fmt, ...) @@ -1976,15 +1976,6 @@ static INT_PTR sttGetAwayMessageT(WPARAM wParam, LPARAM lParam) return (INT_PTR)GetAwayMessage((int)wParam, (char*)lParam, TRUE, NULL); } - -static INT_PTR sttGetAwayMessage(WPARAM wParam, LPARAM lParam) -{ - TCHAR* msg = GetAwayMessage((int)wParam, (char*)lParam, TRUE, NULL); - char* res = mir_t2a(msg); - mir_free(msg); - return (INT_PTR)res; -} - extern "C" int __declspec(dllexport) Load(void) { mir_getLP(&pluginInfo); @@ -1997,8 +1988,6 @@ extern "C" int __declspec(dllexport) Load(void) HookEvent(ME_SYSTEM_MODULESLOADED, OnModulesLoaded); HookEvent(ME_PROTO_ACCLISTCHANGED, OnAccListChanged); - - CreateServiceFunction(MS_AWAYMSG_GETSTATUSMSG, sttGetAwayMessage); CreateServiceFunction(MS_AWAYMSG_GETSTATUSMSGW, sttGetAwayMessageT); CreateServiceFunction(MS_SIMPLESTATUSMSG_SETSTATUS, SetStatusModeFromExtern); diff --git a/plugins/StatusPlugins/AdvancedAutoAway/msgoptions.cpp b/plugins/StatusPlugins/AdvancedAutoAway/msgoptions.cpp index 5de614c838..ec254d3203 100644 --- a/plugins/StatusPlugins/AdvancedAutoAway/msgoptions.cpp +++ b/plugins/StatusPlugins/AdvancedAutoAway/msgoptions.cpp @@ -122,23 +122,15 @@ INT_PTR CALLBACK DlgProcAutoAwayMsgOpts(HWND hwndDlg, UINT msg, WPARAM wParam, L settings[last]->msg = ( char* )realloc(settings[last]->msg, len+1); SendDlgItemMessageA(hwndDlg, IDC_STATUSMSG, WM_GETTEXT, (LPARAM)(len+1), (WPARAM)settings[last]->msg); } + if (i != -1) { if (settings[i]->msg != NULL) SetDlgItemTextA(hwndDlg, IDC_STATUSMSG, settings[i]->msg); - else if (ServiceExists(MS_AWAYMSG_GETSTATUSMSGT)) { - TCHAR *msg = (TCHAR*)CallService(MS_AWAYMSG_GETSTATUSMSGT, (WPARAM)settings[i]->status, 0); - if (msg != NULL) { - SetDlgItemText(hwndDlg, IDC_STATUSMSG, msg); - mir_free(msg); - } - } - else if (ServiceExists(MS_AWAYMSG_GETSTATUSMSG)) { - char *msg = (char*)CallService(MS_AWAYMSG_GETSTATUSMSG, (WPARAM)settings[i]->status, 0); - if (msg != NULL) { - SetDlgItemTextA(hwndDlg, IDC_STATUSMSG, msg); - mir_free(msg); - } + else { + ptrT msg((TCHAR*)CallService(MS_AWAYMSG_GETSTATUSMSGT, settings[i]->status, 0)); + SetDlgItemText(hwndDlg, IDC_STATUSMSG, (msg != NULL) ? msg : _T("")); } + if (settings[i]->useCustom) { EnableWindow(GetDlgItem(hwndDlg, IDC_STATUSMSG), TRUE); EnableWindow(GetDlgItem(hwndDlg, IDC_VARIABLESHELP), TRUE); @@ -150,7 +142,8 @@ INT_PTR CALLBACK DlgProcAutoAwayMsgOpts(HWND hwndDlg, UINT msg, WPARAM wParam, L EnableWindow(GetDlgItem(hwndDlg, IDC_VARIABLESHELP), FALSE); CheckDlgButton(hwndDlg, IDC_RADUSEMIRANDA, TRUE); CheckDlgButton(hwndDlg, IDC_RADUSECUSTOM, FALSE); - } } + } + } last = i; } break; diff --git a/plugins/StatusPlugins/commonstatus.cpp b/plugins/StatusPlugins/commonstatus.cpp index 3f2963748d..74218f4ebf 100644 --- a/plugins/StatusPlugins/commonstatus.cpp +++ b/plugins/StatusPlugins/commonstatus.cpp @@ -119,34 +119,9 @@ TCHAR* GetDefaultStatusMessage(PROTOCOLSETTINGEX *ps, int newstatus) return mir_tstrdup(ps->szMsg); } - if (ServiceExists(MS_AWAYMSG_GETSTATUSMSGT)) { - TCHAR* tMsg = (TCHAR*)CallService(MS_AWAYMSG_GETSTATUSMSGT, newstatus, (LPARAM)ps->szName); - log_debugA("CommonStatus: Status message retrieved from general awaysys (TCHAR)"); - return tMsg; - } - - if (ServiceExists(MS_AWAYMSG_GETSTATUSMSG)) { - char *tMsg; - if (ServiceExists(MS_SA_ISSARUNNING) && CallService(MS_SA_ISSARUNNING, 0, 0)) - tMsg = (char*)CallService(MS_AWAYMSG_GETSTATUSMSG, (WPARAM)newstatus, (LPARAM)ps->szName); - else - tMsg = (char*)CallService(MS_AWAYMSG_GETSTATUSMSG, (WPARAM)newstatus, 0); - - log_debugA("CommonStatus: Status message retrieved from general awaysys"); - - TCHAR* result = mir_a2t(tMsg); - mir_free(tMsg); - return result; - } - - /* awaysys doesn't define the service above */ - TCHAR* tMsg = GetDefaultMessage(newstatus); - if (tMsg != NULL) { - log_debugA("CommonStatus: Status message retrieved from defaults"); - return mir_tstrdup(tMsg); - } - - return NULL; + TCHAR *tMsg = (TCHAR*)CallService(MS_AWAYMSG_GETSTATUSMSGT, newstatus, (LPARAM)ps->szName); + log_debugA("CommonStatus: Status message retrieved from general awaysys: %S", tMsg); + return tMsg; } static int equalsGlobalStatus(PROTOCOLSETTINGEX **ps) -- cgit v1.2.3