summaryrefslogtreecommitdiff
path: root/plugins/NewAwaySysMod
diff options
context:
space:
mode:
authorGeorge Hazan <george.hazan@gmail.com>2014-02-24 15:18:45 +0000
committerGeorge Hazan <george.hazan@gmail.com>2014-02-24 15:18:45 +0000
commit60066ee3ab1d80569d5c13fc9c14fe082aa28be4 (patch)
tree5bb81ca47d272144a3c5e8f6314fb6a30106ab2b /plugins/NewAwaySysMod
parentf8a58bee25b77af07a938cfdf71bdc00c0446b0a (diff)
restored compatibility between NAS & SS plugins
git-svn-id: http://svn.miranda-ng.org/main/trunk@8258 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'plugins/NewAwaySysMod')
-rw-r--r--plugins/NewAwaySysMod/src/AwaySys.cpp104
-rw-r--r--plugins/NewAwaySysMod/src/Common.h2
-rw-r--r--plugins/NewAwaySysMod/src/version.h2
3 files changed, 34 insertions, 74 deletions
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 <m_modernopt.h>
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 <stdver.h>