From 60066ee3ab1d80569d5c13fc9c14fe082aa28be4 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Mon, 24 Feb 2014 15:18:45 +0000 Subject: restored compatibility between NAS & SS plugins git-svn-id: http://svn.miranda-ng.org/main/trunk@8258 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- plugins/ExternalAPI/m_statusplugins.h | 2 +- plugins/NewAwaySysMod/src/AwaySys.cpp | 104 ++++++++------------------ plugins/NewAwaySysMod/src/Common.h | 2 +- plugins/NewAwaySysMod/src/version.h | 2 +- plugins/StatusPlugins/StartupStatus/version.h | 2 +- plugins/StatusPlugins/commonstatus.cpp | 4 +- 6 files changed, 38 insertions(+), 78 deletions(-) diff --git a/plugins/ExternalAPI/m_statusplugins.h b/plugins/ExternalAPI/m_statusplugins.h index 065d91119f..a242805c97 100644 --- a/plugins/ExternalAPI/m_statusplugins.h +++ b/plugins/ExternalAPI/m_statusplugins.h @@ -47,7 +47,7 @@ typedef struct { #define MS_CS_GETPROTOCOUNT "CommonStatus/GetProtocolCount" // added dec '04 // wParam = PROTOCOLSETTINGEX*** (keep it like this for compatibility) -// lParam = 0 +// lParam = (int) settings count #define ME_CS_STATUSCHANGEEX "CommonStatus/StatusChangeEx" // -- startup status -- diff --git a/plugins/NewAwaySysMod/src/AwaySys.cpp b/plugins/NewAwaySysMod/src/AwaySys.cpp index d9bca61bb8..cad89b6c49 100644 --- a/plugins/NewAwaySysMod/src/AwaySys.cpp +++ b/plugins/NewAwaySysMod/src/AwaySys.cpp @@ -42,7 +42,6 @@ #include "Services.h" #include "version.h" -//NightFox #include HINSTANCE g_hInstance; @@ -54,10 +53,7 @@ HGENMENU g_hToggleSOEMenuItem, g_hToggleSOEContactMenuItem; HGENMENU g_hAutoreplyOnContactMenuItem, g_hAutoreplyOffContactMenuItem, g_hAutoreplyUseDefaultContactMenuItem; bool g_fNoProcessing = false; // tells the status change proc not to do anything int g_bIsIdle = false; -HANDLE hMainThread; -int g_CSProtoCount = 0; // CommonStatus - StartupStatus and AdvancedAutoAway VAR_PARSE_DATA VarParseData; -INT_PTR (*g_OldCallService)(const char *, WPARAM, LPARAM) = NULL; static IconItem iconList[] = { { LPGEN("Toggle On"), "on", IDI_SOE_DISABLED }, @@ -90,8 +86,7 @@ extern "C" __declspec(dllexport) PLUGININFOEX *MirandaPluginInfoEx(DWORD miranda return &pluginInfo; } -//NightFox -int ModernOptInitialise(WPARAM wParam, LPARAM lParam); +///////////////////////////////////////////////////////////////////////////////////////// TCString GetDynamicStatMsg(MCONTACT hContact, char *szProto, DWORD UIN, int iStatus) { @@ -291,7 +286,7 @@ int StatusChanged(WPARAM wParam, LPARAM lParam) #define ID_STATUS_DISABLED 41083 // wParam = PROTOCOLSETTINGEX** protoSettings -int CSStatusChange(WPARAM wParam, LPARAM) // CommonStatus plugins (StartupStatus and AdvancedAutoAway) +int CSStatusChange(WPARAM wParam, LPARAM lParam) // CommonStatus plugins (StartupStatus and AdvancedAutoAway) { PROTOCOLSETTINGEX **ps = *(PROTOCOLSETTINGEX***)wParam; if (!ps) @@ -299,8 +294,9 @@ int CSStatusChange(WPARAM wParam, LPARAM) // CommonStatus plugins (StartupStatus LogMessage("ME_CS_STATUSCHANGEEX event:"); - for (int i = 0; i < g_CSProtoCount; i++) { - LogMessage("%d: cbSize=%d, szProto=%s, status=%d, lastStatus=%d, szMsg:", i + 1, ps[i]->cbSize, ps[i]->szName ? (char*)ps[i]->szName : "NULL", ps[i]->status, ps[i]->lastStatus, ps[i]->szMsg ? ps[i]->szMsg : _T("NULL")); + for (int i = 0; i < lParam; i++) { + LogMessage("%d: cbSize=%d, szProto=%s, status=%d, lastStatus=%d, szMsg:", + i + 1, ps[i]->cbSize, ps[i]->szName ? (char*)ps[i]->szName : "NULL", ps[i]->status, ps[i]->lastStatus, ps[i]->szMsg ? ps[i]->szMsg : _T("NULL")); if (ps[i]->status != ID_STATUS_DISABLED) { if (ps[i]->status != ID_STATUS_CURRENT) g_ProtoStates[ps[i]->szName].Status = (ps[i]->status == ID_STATUS_LAST) ? ps[i]->lastStatus : ps[i]->status; @@ -318,13 +314,6 @@ static int IdleChangeEvent(WPARAM, LPARAM lParam) return 0; } -// wParam = numAccs -int CSModuleLoaded(WPARAM wParam, LPARAM) // StartupStatus and AdvancedAutoAway -{ - g_CSProtoCount = wParam; - return 0; -} - int PreBuildContactMenu(WPARAM hContact, LPARAM) { char *szProto = GetContactProto(hContact); @@ -548,6 +537,28 @@ static int ContactSettingsInit(WPARAM wParam, LPARAM) return 0; } +///////////////////////////////////////////////////////////////////////////////////////// +// variables + +struct +{ + TCHAR *Name; + char *Descr; + int Flags; +} +static Variables[] = +{ + { VAR_AWAYSINCE_TIME, LPGEN("New Away System")"\t(x)\t"LPGEN("Away since time in default format; ?nas_awaysince_time(x) in format x"), TRF_FIELD | TRF_FUNCTION }, + { VAR_AWAYSINCE_DATE, LPGEN("New Away System")"\t(x)\t"LPGEN("Away since date in default format; ?nas_awaysince_date(x) in format x"), TRF_FIELD | TRF_FUNCTION }, + { VAR_STATDESC, LPGEN("New Away System")"\t"LPGEN("Status description"), TRF_FIELD | TRF_FUNCTION }, + { VAR_MYNICK, LPGEN("New Away System")"\t"LPGEN("Your nick for current protocol"), TRF_FIELD | TRF_FUNCTION }, + { VAR_REQUESTCOUNT, LPGEN("New Away System")"\t"LPGEN("Number of status message requests from the contact"), TRF_FIELD | TRF_FUNCTION }, + { VAR_MESSAGENUM, LPGEN("New Away System")"\t"LPGEN("Number of messages from the contact"), TRF_FIELD | TRF_FUNCTION }, + { VAR_TIMEPASSED, LPGEN("New Away System")"\t"LPGEN("Time passed until request"), TRF_FIELD | TRF_FUNCTION }, + { VAR_PREDEFINEDMESSAGE, LPGEN("New Away System")"\t(x)\t"LPGEN("Returns one of your predefined messages by its title: ?nas_predefinedmessage(creepy)"), TRF_FUNCTION }, + { VAR_PROTOCOL, LPGEN("New Away System")"\t"LPGEN("Current protocol name"), TRF_FIELD | TRF_FUNCTION } +}; + INT_PTR srvVariablesHandler(WPARAM, LPARAM lParam) { ARGUMENTSINFO *ai = (ARGUMENTSINFO*)lParam; @@ -644,59 +655,7 @@ INT_PTR srvFreeVarMem(WPARAM, LPARAM lParam) return 0; } -static INT_PTR MyCallService(const char *name, WPARAM wParam, LPARAM lParam) -{ - // wParam conditions here are distinctive "features" of PS_SETSTATUS and PS_SETAWAYMSG services, - // so if wParam does not suit them, we'll pass the control to the old CallService function as soon as possible - if (name && wParam <= ID_STATUS_OUTTOLUNCH && wParam >= ID_STATUS_OFFLINE) { - const char *pProtoNameEnd = strrchr(name, '/'); - if (pProtoNameEnd) { - if (!lstrcmpA(pProtoNameEnd, PS_SETSTATUS)) { - // it's PS_SETSTATUS service; wParam = status; lParam = 0 - // returns 0 on success, nonzero on failure - CString Proto(""); - Proto.DiffCat(name, pProtoNameEnd); - if (wParam != g_ProtoStates[Proto].Status) { - g_ProtoStates[Proto].Status = wParam; - TCString Msg(CProtoSettings(Proto).GetMsgFormat(GMF_LASTORDEFAULT)); - LogMessage("Detected a PS_SETSTATUS call with Status different from the one known to NAS. szProto=%s, NewStatus=%d, NewMsg:\n%s", (char*)Proto, wParam, (Msg != NULL) ? _T2A(Msg) : "NULL"); - CProtoSettings(Proto).SetMsgFormat(SMF_TEMPORARY, Msg); - } - } - else if (!lstrcmpA(pProtoNameEnd, PS_SETAWAYMSG)) { - // PS_SETAWAYMSG service; wParam = status; lParam = (const char*)szMessage - // returns 0 on success, nonzero on failure - CString Proto(""); - Proto.DiffCat(name, pProtoNameEnd); - char *param = (char*)lParam; - LogMessage("Someone else than NAS called PS_SETAWAYMSG. szProto=%s, Status=%d, Msg:\n%s", (char*)Proto, wParam, param ? param : "NULL"); - CProtoSettings(Proto).SetMsgFormat(SMF_TEMPORARY, lParam ? ((ServiceExists(MS_VARS_FORMATSTRING) && !g_SetAwayMsgPage.GetDBValueCopy(IDS_SAWAYMSG_DISABLEVARIABLES)) ? VariablesEscape((TCHAR*)_A2T(param)) : (TCHAR*)_A2T(param)) : TCString(_T(""))); - ChangeProtoMessages(Proto, wParam, TCString()); - return 0; - } - } - } - return g_OldCallService(name, wParam, lParam); -} - -struct -{ - TCHAR *Name; - char *Descr; - int Flags; -} -static Variables[] = -{ - { VAR_AWAYSINCE_TIME, LPGEN("New Away System")"\t(x)\t"LPGEN("Away since time in default format; ?nas_awaysince_time(x) in format x"), TRF_FIELD | TRF_FUNCTION }, - { VAR_AWAYSINCE_DATE, LPGEN("New Away System")"\t(x)\t"LPGEN("Away since date in default format; ?nas_awaysince_date(x) in format x"), TRF_FIELD | TRF_FUNCTION }, - { VAR_STATDESC, LPGEN("New Away System")"\t"LPGEN("Status description"), TRF_FIELD | TRF_FUNCTION }, - { VAR_MYNICK, LPGEN("New Away System")"\t"LPGEN("Your nick for current protocol"), TRF_FIELD | TRF_FUNCTION }, - { VAR_REQUESTCOUNT, LPGEN("New Away System")"\t"LPGEN("Number of status message requests from the contact"), TRF_FIELD | TRF_FUNCTION }, - { VAR_MESSAGENUM, LPGEN("New Away System")"\t"LPGEN("Number of messages from the contact"), TRF_FIELD | TRF_FUNCTION }, - { VAR_TIMEPASSED, LPGEN("New Away System")"\t"LPGEN("Time passed until request"), TRF_FIELD | TRF_FUNCTION }, - { VAR_PREDEFINEDMESSAGE, LPGEN("New Away System")"\t(x)\t"LPGEN("Returns one of your predefined messages by its title: ?nas_predefinedmessage(creepy)"), TRF_FUNCTION }, - { VAR_PROTOCOL, LPGEN("New Away System")"\t"LPGEN("Current protocol name"), TRF_FIELD | TRF_FUNCTION } -}; +///////////////////////////////////////////////////////////////////////////////////////// int MirandaLoaded(WPARAM, LPARAM) { @@ -705,8 +664,6 @@ int MirandaLoaded(WPARAM, LPARAM) InitUpdateMsgs(); g_IconList.ReloadIcons(); - DuplicateHandle(GetCurrentProcess(), GetCurrentThread(), GetCurrentProcess(), &hMainThread, THREAD_SET_CONTEXT, false, 0); - int numAccs = 0; PROTOACCOUNT **accs; ProtoEnumAccounts(&numAccs, &accs); @@ -828,6 +785,8 @@ int MirandaLoaded(WPARAM, LPARAM) return 0; } +///////////////////////////////////////////////////////////////////////////////////////// + extern "C" int __declspec(dllexport) Load(void) { mir_getLP(&pluginInfo); @@ -858,9 +817,10 @@ extern "C" int __declspec(dllexport) Load(void) return 0; } +///////////////////////////////////////////////////////////////////////////////////////// + extern "C" int __declspec(dllexport) Unload() { WindowList_Destroy(g_hReadWndList); - CloseHandle(hMainThread); return 0; } diff --git a/plugins/NewAwaySysMod/src/Common.h b/plugins/NewAwaySysMod/src/Common.h index 4f26c8d451..95d3268684 100644 --- a/plugins/NewAwaySysMod/src/Common.h +++ b/plugins/NewAwaySysMod/src/Common.h @@ -277,7 +277,6 @@ extern COptPage g_MoreOptPage; extern COptPage g_SetAwayMsgPage; extern HINSTANCE g_hInstance; -extern HANDLE hMainThread; extern int g_Messages_RecentRootID, g_Messages_PredefinedRootID; extern VAR_PARSE_DATA VarParseData; extern bool g_fNoProcessing; @@ -301,6 +300,7 @@ extern HANDLE g_hReadWndList; INT_PTR GetContactStatMsg(WPARAM wParam, LPARAM lParam); // AwayOpt.cpp +int ModernOptInitialise(WPARAM wParam, LPARAM lParam); int OptsDlgInit(WPARAM wParam, LPARAM); // called on opening of the options dialog void InitOptions(); // called once when plugin is loaded diff --git a/plugins/NewAwaySysMod/src/version.h b/plugins/NewAwaySysMod/src/version.h index 9ce8911676..c6783a1bcc 100644 --- a/plugins/NewAwaySysMod/src/version.h +++ b/plugins/NewAwaySysMod/src/version.h @@ -1,7 +1,7 @@ #define __MAJOR_VERSION 0 #define __MINOR_VERSION 4 #define __RELEASE_NUM 0 -#define __BUILD_NUM 1 +#define __BUILD_NUM 2 #include diff --git a/plugins/StatusPlugins/StartupStatus/version.h b/plugins/StatusPlugins/StartupStatus/version.h index 53bc3fcd85..1ccf8a6209 100644 --- a/plugins/StatusPlugins/StartupStatus/version.h +++ b/plugins/StatusPlugins/StartupStatus/version.h @@ -8,7 +8,7 @@ #define __MAJOR_VERSION 0 #define __MINOR_VERSION 8 #define __RELEASE_NUM 0 -#define __BUILD_NUM 46 +#define __BUILD_NUM 47 // other stuff for Version resource #include diff --git a/plugins/StatusPlugins/commonstatus.cpp b/plugins/StatusPlugins/commonstatus.cpp index db53916620..fb78e81c39 100644 --- a/plugins/StatusPlugins/commonstatus.cpp +++ b/plugins/StatusPlugins/commonstatus.cpp @@ -240,7 +240,7 @@ INT_PTR SetStatusEx(WPARAM wParam, LPARAM lParam) // issue with setting global status; // things get messy because SRAway hooks ME_CLIST_STATUSMODECHANGE, so the status messages of SRAway and // commonstatus will clash - NotifyEventHooks(hCSStatusChangedExEvent, (WPARAM)&protoSettings, 0); + NotifyEventHooks(hCSStatusChangedExEvent, (WPARAM)&protoSettings, protoList->getCount()); // set all status messages first for (int i = 0; i < protoList->getCount(); i++) { @@ -286,7 +286,7 @@ INT_PTR SetStatusEx(WPARAM wParam, LPARAM lParam) SetStatusMsg(protoSettings[i], newstatus); // set the status - if (newstatus != oldstatus) { + if (newstatus != oldstatus && !(b_Caps1 && b_Caps3 && ServiceExists(MS_NAS_SETSTATE))) { log_debugA("CommonStatus sets status for %s to %d", szProto, newstatus); CallProtoService(szProto, PS_SETSTATUS, (WPARAM)newstatus, 0); } -- cgit v1.2.3