diff options
author | (no author) <(no author)@4f64403b-2f21-0410-a795-97e2b3489a10> | 2008-07-14 10:54:04 +0000 |
---|---|---|
committer | (no author) <(no author)@4f64403b-2f21-0410-a795-97e2b3489a10> | 2008-07-14 10:54:04 +0000 |
commit | 8128db96b8cb2078a82f49fd6026b618560d6d8f (patch) | |
tree | 2bafd319b2dc5a9068af4e54bd95b46e137e723c | |
parent | 1bc101d3173029b6852965bd46a105fcb6ce17d0 (diff) |
reorganised settings overrides
git-svn-id: https://server.scottellis.com.au/svn/mim_plugs@418 4f64403b-2f21-0410-a795-97e2b3489a10
-rw-r--r-- | meta2/common.h | 4 | ||||
-rw-r--r-- | meta2/meta2.cpp | 4 | ||||
-rw-r--r-- | meta2/meta2.sln | 4 | ||||
-rw-r--r-- | meta2/meta2.vcproj | 23 | ||||
-rw-r--r-- | meta2/proto.cpp | 6 | ||||
-rw-r--r-- | meta2/settings.cpp | 117 | ||||
-rw-r--r-- | meta2/settings.h | 2 | ||||
-rw-r--r-- | meta2/version.h | 2 |
8 files changed, 110 insertions, 52 deletions
diff --git a/meta2/common.h b/meta2/common.h index 582643c..c0c9110 100644 --- a/meta2/common.h +++ b/meta2/common.h @@ -30,9 +30,10 @@ #include <windows.h>
#include <commctrl.h>
-#define MIRANDA_VER 0x0700
+#define MIRANDA_VER 0x0800
#include <newpluginapi.h>
+#include <m_plugins.h>
#include <m_system.h>
#include <m_database.h>
#include <m_langpack.h>
@@ -74,6 +75,7 @@ extern MM_INTERFACE mmi; extern UTF8_INTERFACE utfi;
extern HANDLE metaMainThread;
extern DWORD next_meta_id;
+extern int codepage;
#ifndef MIID_META2
#define MIID_META2 { 0x4415A85D, 0xD6DA, 0x4551, { 0xB2, 0xB8, 0x9B, 0xDD, 0x82, 0xE2, 0x4B, 0x50 } }
diff --git a/meta2/meta2.cpp b/meta2/meta2.cpp index 3eff626..447f681 100644 --- a/meta2/meta2.cpp +++ b/meta2/meta2.cpp @@ -20,6 +20,7 @@ PLUGINLINK *pluginLink; MM_INTERFACE mmi;
UTF8_INTERFACE utfi;
HANDLE metaMainThread;
+int codepage;
PLUGININFOEX pluginInfo={
sizeof(PLUGININFOEX),
@@ -97,6 +98,7 @@ extern "C" __declspec (dllexport) int Load(PLUGINLINK *link) { mir_getMMI(&mmi);
mir_getUTFI(&utfi);
+ codepage = (int)CallService(MS_LANGPACK_GETCODEPAGE, 0, 0);
RedBlackTree<int> test;
test.add(1);
@@ -138,7 +140,7 @@ extern "C" __declspec (dllexport) int Load(PLUGINLINK *link) { DBWriteContactSettingByte(0, MODULE, "FirstRun", 0);
}
- InitSettings(link);
+ InitSettings();
// hook modules loaded
hModulesLoaded = HookEvent(ME_SYSTEM_MODULESLOADED, ModulesLoaded);
diff --git a/meta2/meta2.sln b/meta2/meta2.sln index 70e7972..422b130 100644 --- a/meta2/meta2.sln +++ b/meta2/meta2.sln @@ -1,6 +1,6 @@
-Microsoft Visual Studio Solution File, Format Version 9.00
-# Visual Studio 2005
+Microsoft Visual Studio Solution File, Format Version 10.00
+# Visual Studio 2008
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "meta2", "meta2.vcproj", "{C7542E4E-BCC9-4620-8C72-77DBD8119186}"
EndProject
Global
diff --git a/meta2/meta2.vcproj b/meta2/meta2.vcproj index c99ae3a..cc93abc 100644 --- a/meta2/meta2.vcproj +++ b/meta2/meta2.vcproj @@ -1,10 +1,11 @@ <?xml version="1.0" encoding="Windows-1252"?>
<VisualStudioProject
ProjectType="Visual C++"
- Version="8.00"
+ Version="9.00"
Name="meta2"
ProjectGUID="{C7542E4E-BCC9-4620-8C72-77DBD8119186}"
RootNamespace="meta2"
+ TargetFrameworkVersion="131072"
>
<Platforms>
<Platform
@@ -58,6 +59,8 @@ Name="VCLinkerTool"
AdditionalDependencies="comctl32.lib"
SubSystem="2"
+ RandomizedBaseAddress="1"
+ DataExecutionPrevention="0"
/>
<Tool
Name="VCALinkTool"
@@ -78,9 +81,6 @@ Name="VCAppVerifierTool"
/>
<Tool
- Name="VCWebDeploymentTool"
- />
- <Tool
Name="VCPostBuildEventTool"
/>
</Configuration>
@@ -127,6 +127,8 @@ Name="VCLinkerTool"
AdditionalDependencies="comctl32.lib"
SubSystem="2"
+ RandomizedBaseAddress="1"
+ DataExecutionPrevention="0"
/>
<Tool
Name="VCALinkTool"
@@ -147,9 +149,6 @@ Name="VCAppVerifierTool"
/>
<Tool
- Name="VCWebDeploymentTool"
- />
- <Tool
Name="VCPostBuildEventTool"
/>
</Configuration>
@@ -200,6 +199,8 @@ AdditionalDependencies="comctl32.lib"
GenerateDebugInformation="true"
SubSystem="2"
+ RandomizedBaseAddress="1"
+ DataExecutionPrevention="0"
/>
<Tool
Name="VCALinkTool"
@@ -220,9 +221,6 @@ Name="VCAppVerifierTool"
/>
<Tool
- Name="VCWebDeploymentTool"
- />
- <Tool
Name="VCPostBuildEventTool"
/>
</Configuration>
@@ -270,6 +268,8 @@ Name="VCLinkerTool"
AdditionalDependencies="comctl32.lib"
SubSystem="2"
+ RandomizedBaseAddress="1"
+ DataExecutionPrevention="0"
/>
<Tool
Name="VCALinkTool"
@@ -290,9 +290,6 @@ Name="VCAppVerifierTool"
/>
<Tool
- Name="VCWebDeploymentTool"
- />
- <Tool
Name="VCPostBuildEventTool"
/>
</Configuration>
diff --git a/meta2/proto.cpp b/meta2/proto.cpp index a147bc6..8cf504a 100644 --- a/meta2/proto.cpp +++ b/meta2/proto.cpp @@ -169,11 +169,11 @@ int ProtoSendMessage(WPARAM wParam, LPARAM lParam) { strncpy(szServiceName, PSS_MESSAGE "W", sizeof(szServiceName));
}
// subcontact does not support utf - convert to old ascii/wide format
- if((flags & PREF_UTF) && !(CallContactService(hSendTo, PS_GETCAPS, PFLAGNUM_4, 0) & PF4_IMSENDUTF)) {
+ if((flags & PREF_UTF) && (proto == 0 || !(CallProtoService(proto, PS_GETCAPS, PFLAGNUM_4, 0) & PF4_IMSENDUTF))) {
ccs->wParam &= ~PREF_UTF;
ccs->wParam |= PREF_UNICODE;
wchar_t *unicode = mir_utf8decodeW(message);
- char *ascii = mir_u2a(unicode);
+ char *ascii = mir_u2a_cp(unicode, codepage);
char *buff = new char[strlen(ascii) + 1 + (wcslen(unicode) + 1) * sizeof(wchar_t)];
strcpy(buff, ascii);
@@ -403,7 +403,7 @@ int WindowEvent(WPARAM wParam, LPARAM lParam) { void RegisterProto() {
PROTOCOLDESCRIPTOR pd = {0};
- pd.cbSize = sizeof(pd);
+ pd.cbSize = PROTOCOLDESCRIPTOR_V3_SIZE; //sizeof(pd);
pd.szName = MODULE;
pd.type = PROTOTYPE_PROTOCOL;
CallService(MS_PROTO_REGISTERMODULE,0,(LPARAM)&pd);
diff --git a/meta2/settings.cpp b/meta2/settings.cpp index cd5cf4c..20427be 100644 --- a/meta2/settings.cpp +++ b/meta2/settings.cpp @@ -2,11 +2,10 @@ #include "settings.h"
#include "core_functions.h"
-PLUGINLINK *core_link = 0;
-typedef int (*ServiceFunc)(const char *,WPARAM,LPARAM);
-ServiceFunc coreCallService, coreCallServiceSync;
+MIRANDASERVICE oldGetSetting, oldGetSettingStr, oldGetSettingStatic;
-int ServiceFuncRedirect(const char *service,WPARAM wParam, LPARAM lParam, ServiceFunc coreServiceFunc) {
+/*
+int ServiceFuncRedirect(const char *service,WPARAM wParam, LPARAM lParam) {
if(wParam ==0
|| strncmp(service, "DB/Contact/", 11) != 0
|| (strcmp(MS_DB_CONTACT_GETSETTING, service) != 0
@@ -18,7 +17,7 @@ int ServiceFuncRedirect(const char *service,WPARAM wParam, LPARAM lParam, Servic )
)
{
- return coreServiceFunc(service, wParam, lParam);
+ return coreCallService(service, wParam, lParam);
}
HANDLE hContact = (HANDLE)wParam;
@@ -26,9 +25,9 @@ int ServiceFuncRedirect(const char *service,WPARAM wParam, LPARAM lParam, Servic DBCONTACTENUMSETTINGS *ces = (DBCONTACTENUMSETTINGS *)lParam;
if(IsMetacontact(hContact) && strcmp(ces->szModule, MODULE) != 0) {
HANDLE hSub = Meta_GetActive(hContact);
- return coreServiceFunc(service, (WPARAM)hSub, lParam);
+ return coreCallService(service, (WPARAM)hSub, lParam);
} else
- return coreServiceFunc(service, wParam, lParam);
+ return coreCallService(service, wParam, lParam);
}
const char *szSetting = 0, *szModule = 0;
@@ -48,6 +47,7 @@ int ServiceFuncRedirect(const char *service,WPARAM wParam, LPARAM lParam, Servic if(szModule == 0 || szSetting == 0
|| strcmp(szModule, "Protocol") == 0
|| strcmp(szModule, "_Filter") == 0
+ || strcmp(szModule, "CList") == 0
|| (strcmp(szModule, MODULE) == 0
&& (strcmp(szSetting, META_ID) == 0
|| strcmp(szSetting, "IsSubcontact") == 0
@@ -62,58 +62,115 @@ int ServiceFuncRedirect(const char *service,WPARAM wParam, LPARAM lParam, Servic || strcmp(szSetting, "Status") == 0))
|| !IsMetacontact(hContact))
{
- return coreServiceFunc(service, wParam, lParam);
+ return coreCallService(service, wParam, lParam);
}
HANDLE hMeta = hContact;
HANDLE hSub = Meta_GetActive(hMeta);
char *subProto;
if(hSub == 0 || (subProto = ContactProto(hSub)) == 0) // no most online - fail
- return coreServiceFunc(service, wParam, lParam);
+ return coreCallService(service, wParam, lParam);
int ret = 1;
if(read) {
- if((ret = coreServiceFunc(service, (WPARAM)hMeta, lParam)) != 0) {
+ DBCONTACTGETSETTING *cgs = (DBCONTACTGETSETTING *)lParam;
+ DBCONTACTGETSETTING cgs_save = *cgs;
+ if((ret = coreCallService(service, (WPARAM)hMeta, lParam)) != 0) {
+ *cgs = cgs_save;
// if the setting does not exist in the metacontact, get it from the most online subcontact
- if((ret = coreServiceFunc(service, (WPARAM)hSub, lParam)) != 0) {
+ if((ret = coreCallService(service, (WPARAM)hSub, lParam)) != 0) {
// if it does not exist in the subcontact and we're using the meta proto module, try changing the module to the subcontact proto module
if(strcmp(szModule, MODULE) == 0) {
if(subProto) {
- DBCONTACTGETSETTING *cgs = (DBCONTACTGETSETTING *)lParam;
+ *cgs = cgs_save;
cgs->szModule = subProto;
- ret = coreServiceFunc(service, (WPARAM)hSub, lParam);
+ ret = coreCallService(service, (WPARAM)hSub, lParam);
}
}
}
}
} else {
- // write to the sub
- DBCONTACTWRITESETTING *cws = (DBCONTACTWRITESETTING *)lParam;
- if(strcmp(szModule, MODULE) == 0)
- cws->szModule = subProto;
- ret = coreServiceFunc(service, (WPARAM)hSub, lParam);
+ // write to the sub?
+
+ //DBCONTACTWRITESETTING *cws = (DBCONTACTWRITESETTING *)lParam;
+ //if(strcmp(szModule, MODULE) == 0)
+ // cws->szModule = subProto;
+ //ret = coreCallService(service, (WPARAM)hSub, lParam);
}
return ret;
}
+*/
+
+int MyOverride(WPARAM wParam, LPARAM lParam, MIRANDASERVICE oldService) {
+ HANDLE hMeta = (HANDLE)wParam;
+ DBCONTACTGETSETTING *cgs = (DBCONTACTGETSETTING *)lParam;
+ if(cgs->szModule == 0 || cgs->szSetting == 0
+ || strcmp(cgs->szModule, "Protocol") == 0
+ || strcmp(cgs->szModule, "_Filter") == 0
+ || strcmp(cgs->szModule, "CList") == 0
+ || (strcmp(cgs->szModule, MODULE) == 0
+ && (strcmp(cgs->szSetting, META_ID) == 0
+ || strcmp(cgs->szSetting, "IsSubcontact") == 0
+ || strcmp(cgs->szSetting, "Default") == 0
+ || strcmp(cgs->szSetting, "Handle") == 0
+ || strcmp(cgs->szSetting, "WindowOpen") == 0
+ || strcmp(cgs->szSetting, "ParentMetaID") == 0
+ || strcmp(cgs->szSetting, "Default") == 0
+ || strcmp(cgs->szSetting, "ForceDefault") == 0
+ || strcmp(cgs->szSetting, "ForceSend") == 0
+ || strcmp(cgs->szSetting, "TempDefault") == 0
+ || strcmp(cgs->szSetting, "Status") == 0))
+ || !IsMetacontact(hMeta))
+ {
+ return oldService(wParam, lParam);
+ }
+
+ HANDLE hSub = Meta_GetActive(hMeta);
+ char *subProto;
+ if(hSub == 0 || (subProto = ContactProto(hSub)) == 0) // no most online - fail
+ return oldService(wParam, lParam);
+
+ int ret;
+ DBCONTACTGETSETTING cgs_save = *cgs;
+ if((ret = oldService((WPARAM)hMeta, lParam)) != 0) {
+ *cgs = cgs_save;
+ // if the setting does not exist in the metacontact, get it from the most online subcontact
+ if((ret = oldService((WPARAM)hSub, lParam)) != 0) {
+ // if it does not exist in the subcontact and we're using the meta proto module, try changing the module to the subcontact proto module
+ if(strcmp(cgs->szModule, MODULE) == 0) {
+ if(subProto) {
+ *cgs = cgs_save;
+ cgs->szModule = subProto;
+ ret = oldService((WPARAM)hSub, lParam);
+ }
+ }
+ }
+ }
+
+ return ret;
+}
+
+int MyGetSetting(WPARAM wParam, LPARAM lParam) {
+ return MyOverride(wParam, lParam, oldGetSetting);
+}
-int CallServiceRedirect(const char *service,WPARAM wParam, LPARAM lParam) {
- return ServiceFuncRedirect(service, wParam, lParam, coreCallService);
+int MyGetSettingStr(WPARAM wParam, LPARAM lParam) {
+ return MyOverride(wParam, lParam, oldGetSettingStr);
}
-int CallServiceSyncRedirect(const char *service,WPARAM wParam, LPARAM lParam) {
- return ServiceFuncRedirect(service, wParam, lParam, coreCallServiceSync);
+int MyGetSettingStatic(WPARAM wParam, LPARAM lParam) {
+ return MyOverride(wParam, lParam, oldGetSettingStatic);
}
-void InitSettings(PLUGINLINK *link) {
- core_link = link;
- coreCallService = core_link->CallService;
- coreCallServiceSync = core_link->CallServiceSync;
- core_link->CallService = CallServiceRedirect;
- core_link->CallServiceSync = CallServiceSyncRedirect;
+void InitSettings() {
+ oldGetSetting = (MIRANDASERVICE)CallService(MS_PLUGINS_HOOKSERVICE, (WPARAM)MS_DB_CONTACT_GETSETTING, (LPARAM)MyGetSetting);
+ oldGetSettingStr = (MIRANDASERVICE)CallService(MS_PLUGINS_HOOKSERVICE, (WPARAM)MS_DB_CONTACT_GETSETTING_STR, (LPARAM)MyGetSettingStr);
+ oldGetSettingStatic = (MIRANDASERVICE)CallService(MS_PLUGINS_HOOKSERVICE, (WPARAM)MS_DB_CONTACT_GETSETTINGSTATIC, (LPARAM)MyGetSettingStatic);
}
void DeinitSettings() {
- core_link->CallService = coreCallService;
- core_link->CallServiceSync = coreCallServiceSync;
+ CallService(MS_PLUGINS_HOOKSERVICE, (WPARAM)MS_DB_CONTACT_GETSETTING, (LPARAM)oldGetSetting);
+ CallService(MS_PLUGINS_HOOKSERVICE, (WPARAM)MS_DB_CONTACT_GETSETTING_STR, (LPARAM)oldGetSettingStr);
+ CallService(MS_PLUGINS_HOOKSERVICE, (WPARAM)MS_DB_CONTACT_GETSETTINGSTATIC, (LPARAM)oldGetSettingStatic);
}
\ No newline at end of file diff --git a/meta2/settings.h b/meta2/settings.h index f8b0f31..2b862e0 100644 --- a/meta2/settings.h +++ b/meta2/settings.h @@ -1,4 +1,4 @@ #include <newpluginapi.h>
-void InitSettings(PLUGINLINK *link);
+void InitSettings();
void DeinitSettings();
\ No newline at end of file diff --git a/meta2/version.h b/meta2/version.h index f02f51c..8e73d84 100644 --- a/meta2/version.h +++ b/meta2/version.h @@ -5,7 +5,7 @@ #define __MAJOR_VERSION 0
#define __MINOR_VERSION 0
#define __RELEASE_NUM 0
-#define __BUILD_NUM 16
+#define __BUILD_NUM 17
#define __FILEVERSION_STRING __MAJOR_VERSION,__MINOR_VERSION,__RELEASE_NUM,__BUILD_NUM
#define __FILEVERSION_STRING_DOTS __MAJOR_VERSION.__MINOR_VERSION.__RELEASE_NUM.__BUILD_NUM
|