diff options
author | George Hazan <george.hazan@gmail.com> | 2014-07-08 18:03:05 +0000 |
---|---|---|
committer | George Hazan <george.hazan@gmail.com> | 2014-07-08 18:03:05 +0000 |
commit | 1a9ce756b4b7b00e9e11275890877328910a1c20 (patch) | |
tree | 997dab875b89ba994c6fa22ea9e47a9a895a8164 /plugins/SecureIM | |
parent | 263d0de0c55f0c3c74ca6ddd041927f9913a6434 (diff) |
- minor code reordering
git-svn-id: http://svn.miranda-ng.org/main/trunk@9734 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'plugins/SecureIM')
-rw-r--r-- | plugins/SecureIM/src/commonheaders.cpp | 14 | ||||
-rw-r--r-- | plugins/SecureIM/src/commonheaders.h | 5 | ||||
-rw-r--r-- | plugins/SecureIM/src/crypt_check.cpp | 2 | ||||
-rw-r--r-- | plugins/SecureIM/src/main.cpp | 213 |
4 files changed, 120 insertions, 114 deletions
diff --git a/plugins/SecureIM/src/commonheaders.cpp b/plugins/SecureIM/src/commonheaders.cpp index ce80378c5c..615ebb5b34 100644 --- a/plugins/SecureIM/src/commonheaders.cpp +++ b/plugins/SecureIM/src/commonheaders.cpp @@ -23,20 +23,6 @@ BYTE bPGP, bGPG; DWORD iCoreVersion = 0;
CRITICAL_SECTION localQueueMutex;
-PLUGININFOEX pluginInfoEx = {
- sizeof(PLUGININFOEX),
- __PLUGIN_NAME,
- PLUGIN_MAKE_VERSION(__MAJOR_VERSION, __MINOR_VERSION, __RELEASE_NUM, __BUILD_NUM),
- __DESCRIPTION,
- __AUTHOR,
- __AUTHOREMAIL,
- __COPYRIGHT,
- __AUTHORWEB,
- UNICODE_AWARE,
- // {1B2A39E5-E2F6-494D-958D-1808FD110DD5}
- { 0x1B2A39E5, 0xE2F6, 0x494D, { 0x95, 0x8D, 0x18, 0x08, 0xFD, 0x11, 0x0D, 0xD5 } }
-};
-
LPSTR myDBGetStringDecode(MCONTACT hContact, const char *szModule, const char *szSetting)
{
char *val = db_get_sa(hContact, szModule, szSetting);
diff --git a/plugins/SecureIM/src/commonheaders.h b/plugins/SecureIM/src/commonheaders.h index c8c9a1fcb3..6fc637373c 100644 --- a/plugins/SecureIM/src/commonheaders.h +++ b/plugins/SecureIM/src/commonheaders.h @@ -79,7 +79,6 @@ extern int TEMP_SIZE; // shared vars
extern HINSTANCE g_hInst, g_hIconInst;
-extern PLUGININFOEX pluginInfoEx;
#define PREF_METANODB 0x2000 //!< Flag to indicate message should not be added to db by filter when sending
#define PREF_SIMNOMETA 0x4000 //!< Flag to indicate message should not be inspected by filter on metacontact
@@ -98,10 +97,6 @@ extern BYTE bPGP, bGPG; extern DWORD iCoreVersion;
extern CRITICAL_SECTION localQueueMutex;
-int onModulesLoaded(WPARAM, LPARAM);
-int onShutdown(WPARAM, LPARAM);
-int ModuleLoad(WPARAM wParam, LPARAM lParam);
-
__forceinline int SendBroadcast(MCONTACT hContact, int type, int result, HANDLE hProcess, LPARAM lParam)
{
return ProtoBroadcastAck( GetContactProto(hContact), hContact, type, result, hProcess, lParam);
diff --git a/plugins/SecureIM/src/crypt_check.cpp b/plugins/SecureIM/src/crypt_check.cpp index e2d8ef27b9..ae19be8d5f 100644 --- a/plugins/SecureIM/src/crypt_check.cpp +++ b/plugins/SecureIM/src/crypt_check.cpp @@ -96,7 +96,7 @@ bool isProtoSmallPackets(MCONTACT hContact) bool isContactInvisible(MCONTACT hContact)
{
- if (db_get_b(hContact, "CList", "Hidden", 0))
+ if (!db_mc_isSub(hContact) && db_get_b(hContact, "CList", "Hidden", 0))
return true;
pUinKey p = findUinKey(hContact);
diff --git a/plugins/SecureIM/src/main.cpp b/plugins/SecureIM/src/main.cpp index 22d7d44e6a..ee1088ce09 100644 --- a/plugins/SecureIM/src/main.cpp +++ b/plugins/SecureIM/src/main.cpp @@ -2,6 +2,27 @@ int hLangpack = 0;
+PLUGININFOEX pluginInfoEx = {
+ sizeof(PLUGININFOEX),
+ __PLUGIN_NAME,
+ PLUGIN_MAKE_VERSION(__MAJOR_VERSION, __MINOR_VERSION, __RELEASE_NUM, __BUILD_NUM),
+ __DESCRIPTION,
+ __AUTHOR,
+ __AUTHOREMAIL,
+ __COPYRIGHT,
+ __AUTHORWEB,
+ UNICODE_AWARE,
+ // {1B2A39E5-E2F6-494D-958D-1808FD110DD5}
+ { 0x1B2A39E5, 0xE2F6, 0x494D, { 0x95, 0x8D, 0x18, 0x08, 0xFD, 0x11, 0x0D, 0xD5 } }
+};
+
+extern "C" __declspec(dllexport) PLUGININFOEX* MirandaPluginInfoEx(DWORD mirandaVersion)
+{
+ return &pluginInfoEx;
+}
+
+/////////////////////////////////////////////////////////////////////////////////////////
+
BOOL APIENTRY DllMain(HINSTANCE hInst, DWORD dwReason, LPVOID)
{
g_hInst = hInst;
@@ -12,12 +33,10 @@ BOOL APIENTRY DllMain(HINSTANCE hInst, DWORD dwReason, LPVOID) return TRUE;
}
-extern "C" __declspec(dllexport) PLUGININFOEX* MirandaPluginInfoEx(DWORD mirandaVersion)
-{
- return &pluginInfoEx;
-}
+/////////////////////////////////////////////////////////////////////////////////////////
+// basic events: onModuleLoad, onModulesLoad, onShutdown
-HGENMENU AddMenuItem(LPCSTR name, int pos, HICON hicon, LPCSTR service, int flags = 0, WPARAM wParam = 0)
+static HGENMENU AddMenuItem(LPCSTR name, int pos, HICON hicon, LPCSTR service, int flags = 0, WPARAM wParam = 0)
{
CLISTMENUITEM mi = { sizeof(mi) };
mi.flags = flags | CMIF_HIDDEN;
@@ -29,7 +48,7 @@ HGENMENU AddMenuItem(LPCSTR name, int pos, HICON hicon, LPCSTR service, int flag return Menu_AddContactMenuItem(&mi);
}
-HGENMENU AddSubItem(HANDLE rootid, LPCSTR name, int pos, int poppos, LPCSTR service, WPARAM wParam = 0)
+static HGENMENU AddSubItem(HANDLE rootid, LPCSTR name, int pos, int poppos, LPCSTR service, WPARAM wParam = 0)
{
CLISTMENUITEM mi = { sizeof(mi) };
mi.flags = CMIF_CHILDPOPUP | CMIF_HIDDEN;
@@ -41,97 +60,13 @@ HGENMENU AddSubItem(HANDLE rootid, LPCSTR name, int pos, int poppos, LPCSTR serv return Menu_AddContactMenuItem(&mi);
}
-extern "C" __declspec(dllexport) int __cdecl Load(void)
-{
- mir_getLP(&pluginInfoEx);
-
- DisableThreadLibraryCalls(g_hInst);
- InitializeCriticalSection(&localQueueMutex);
-
- char temp[MAX_PATH];
- GetTempPath(sizeof(temp), temp);
- GetLongPathName(temp, TEMP, sizeof(TEMP));
- TEMP_SIZE = (int)strlen(TEMP);
- if (TEMP[TEMP_SIZE - 1] == '\\') {
- TEMP_SIZE--;
- TEMP[TEMP_SIZE] = '\0';
- }
-
- // check for support TrueColor Icons
- BOOL bIsComCtl6 = FALSE;
- HMODULE hComCtlDll = LoadLibrary(_T("comctl32.dll"));
- if (hComCtlDll) {
- typedef HRESULT(CALLBACK *PFNDLLGETVERSION)(DLLVERSIONINFO*);
- PFNDLLGETVERSION pfnDllGetVersion = (PFNDLLGETVERSION)GetProcAddress(hComCtlDll, "DllGetVersion");
- if (pfnDllGetVersion) {
- DLLVERSIONINFO dvi;
- memset(&dvi, 0, sizeof(dvi));
- dvi.cbSize = sizeof(dvi);
- HRESULT hRes = (*pfnDllGetVersion)(&dvi);
- if (SUCCEEDED(hRes) && dvi.dwMajorVersion >= 6) {
- bIsComCtl6 = TRUE;
- }
- }
- FreeLibrary(hComCtlDll);
- }
- if (bIsComCtl6) iBmpDepth = ILC_COLOR32 | ILC_MASK; // 32-bit images are supported
- else iBmpDepth = ILC_COLOR24 | ILC_MASK;
-
- iCoreVersion = CallService(MS_SYSTEM_GETVERSION, 0, 0);
-
- // load crypo++ dll
- if (!loadlib()) {
- msgbox1(0, sim107, MODULENAME, MB_OK | MB_ICONSTOP);
- return 1;
- }
-
- load_rtfconv();
-
- // register plugin module
- PROTOCOLDESCRIPTOR pd = { sizeof(pd) };
- pd.szName = (char*)MODULENAME;
- pd.type = PROTOTYPE_ENCRYPTION;
- CallService(MS_PROTO_REGISTERMODULE, 0, (LPARAM)&pd);
-
- // hook events
- HookEvent(ME_SYSTEM_MODULESLOADED, onModulesLoaded);
- HookEvent(ME_SYSTEM_PRESHUTDOWN, onShutdown);
- HookEvent(ME_SYSTEM_MODULELOAD, ModuleLoad);
- HookEvent(ME_SYSTEM_MODULEUNLOAD, ModuleLoad);
-
- g_hEvent[0] = CreateHookableEvent(MODULENAME"/Disabled");
- g_hEvent[1] = CreateHookableEvent(MODULENAME"/Established");
-
- CreateServiceFunction(MODULENAME"/IsContactSecured", Service_IsContactSecured);
- CreateServiceFunction(MODULENAME"/SIM_EST", Service_CreateIM);
- CreateServiceFunction(MODULENAME"/SIM_DIS", Service_DisableIM);
- CreateServiceFunction(MODULENAME"/SIM_ST_DIS", Service_StatusDis);
- CreateServiceFunction(MODULENAME"/SIM_ST_ENA", Service_StatusEna);
- CreateServiceFunction(MODULENAME"/SIM_ST_TRY", Service_StatusTry);
- CreateServiceFunction(MODULENAME"/PGP_SET", Service_PGPsetKey);
- CreateServiceFunction(MODULENAME"/PGP_DEL", Service_PGPdelKey);
- CreateServiceFunction(MODULENAME"/GPG_SET", Service_GPGsetKey);
- CreateServiceFunction(MODULENAME"/GPG_DEL", Service_GPGdelKey);
- CreateServiceFunction(MODULENAME"/MODE_NAT", Service_ModeNative);
- CreateServiceFunction(MODULENAME"/MODE_PGP", Service_ModePGP);
- CreateServiceFunction(MODULENAME"/MODE_GPG", Service_ModeGPG);
- CreateServiceFunction(MODULENAME"/MODE_RSA", Service_ModeRSAAES);
- return 0;
-}
-
-extern "C" __declspec(dllexport) int __cdecl Unload()
-{
- DeleteCriticalSection(&localQueueMutex);
- return 0;
-}
-
-int ModuleLoad(WPARAM, LPARAM)
+static int onModuleLoad(WPARAM, LPARAM)
{
bPopupExists = ServiceExists(MS_POPUP_ADDPOPUPT);
return 0;
}
-int onModulesLoaded(WPARAM, LPARAM)
+static int onModulesLoaded(WPARAM, LPARAM)
{
InitNetlib();
@@ -139,7 +74,7 @@ int onModulesLoaded(WPARAM, LPARAM) InitIcons();
GetFlags();
- ModuleLoad(0, 0);
+ onModuleLoad(0, 0);
// RSA/AES
Sent_NetLog("rsa_init");
@@ -344,7 +279,7 @@ int onModulesLoaded(WPARAM, LPARAM) return 0;
}
-int onShutdown(WPARAM, LPARAM)
+static int onShutdown(WPARAM, LPARAM)
{
if (bSavePass) {
LPSTR tmp = gpg_get_passphrases();
@@ -366,3 +301,93 @@ int onShutdown(WPARAM, LPARAM) DeinitNetlib();
return 0;
}
+
+/////////////////////////////////////////////////////////////////////////////////////////
+// Load
+
+extern "C" __declspec(dllexport) int __cdecl Load(void)
+{
+ mir_getLP(&pluginInfoEx);
+
+ DisableThreadLibraryCalls(g_hInst);
+ InitializeCriticalSection(&localQueueMutex);
+
+ char temp[MAX_PATH];
+ GetTempPath(sizeof(temp), temp);
+ GetLongPathName(temp, TEMP, sizeof(TEMP));
+ TEMP_SIZE = (int)strlen(TEMP);
+ if (TEMP[TEMP_SIZE - 1] == '\\') {
+ TEMP_SIZE--;
+ TEMP[TEMP_SIZE] = '\0';
+ }
+
+ // check for support TrueColor Icons
+ BOOL bIsComCtl6 = FALSE;
+ HMODULE hComCtlDll = LoadLibrary(_T("comctl32.dll"));
+ if (hComCtlDll) {
+ typedef HRESULT(CALLBACK *PFNDLLGETVERSION)(DLLVERSIONINFO*);
+ PFNDLLGETVERSION pfnDllGetVersion = (PFNDLLGETVERSION)GetProcAddress(hComCtlDll, "DllGetVersion");
+ if (pfnDllGetVersion) {
+ DLLVERSIONINFO dvi;
+ memset(&dvi, 0, sizeof(dvi));
+ dvi.cbSize = sizeof(dvi);
+ HRESULT hRes = (*pfnDllGetVersion)(&dvi);
+ if (SUCCEEDED(hRes) && dvi.dwMajorVersion >= 6) {
+ bIsComCtl6 = TRUE;
+ }
+ }
+ FreeLibrary(hComCtlDll);
+ }
+ if (bIsComCtl6) iBmpDepth = ILC_COLOR32 | ILC_MASK; // 32-bit images are supported
+ else iBmpDepth = ILC_COLOR24 | ILC_MASK;
+
+ iCoreVersion = CallService(MS_SYSTEM_GETVERSION, 0, 0);
+
+ // load crypo++ dll
+ if (!loadlib()) {
+ msgbox1(0, sim107, MODULENAME, MB_OK | MB_ICONSTOP);
+ return 1;
+ }
+
+ load_rtfconv();
+
+ // register plugin module
+ PROTOCOLDESCRIPTOR pd = { sizeof(pd) };
+ pd.szName = (char*)MODULENAME;
+ pd.type = PROTOTYPE_ENCRYPTION;
+ CallService(MS_PROTO_REGISTERMODULE, 0, (LPARAM)&pd);
+
+ // hook events
+ HookEvent(ME_SYSTEM_MODULESLOADED, onModulesLoaded);
+ HookEvent(ME_SYSTEM_PRESHUTDOWN, onShutdown);
+ HookEvent(ME_SYSTEM_MODULELOAD, onModuleLoad);
+ HookEvent(ME_SYSTEM_MODULEUNLOAD, onModuleLoad);
+
+ g_hEvent[0] = CreateHookableEvent(MODULENAME"/Disabled");
+ g_hEvent[1] = CreateHookableEvent(MODULENAME"/Established");
+
+ CreateServiceFunction(MODULENAME"/IsContactSecured", Service_IsContactSecured);
+ CreateServiceFunction(MODULENAME"/SIM_EST", Service_CreateIM);
+ CreateServiceFunction(MODULENAME"/SIM_DIS", Service_DisableIM);
+ CreateServiceFunction(MODULENAME"/SIM_ST_DIS", Service_StatusDis);
+ CreateServiceFunction(MODULENAME"/SIM_ST_ENA", Service_StatusEna);
+ CreateServiceFunction(MODULENAME"/SIM_ST_TRY", Service_StatusTry);
+ CreateServiceFunction(MODULENAME"/PGP_SET", Service_PGPsetKey);
+ CreateServiceFunction(MODULENAME"/PGP_DEL", Service_PGPdelKey);
+ CreateServiceFunction(MODULENAME"/GPG_SET", Service_GPGsetKey);
+ CreateServiceFunction(MODULENAME"/GPG_DEL", Service_GPGdelKey);
+ CreateServiceFunction(MODULENAME"/MODE_NAT", Service_ModeNative);
+ CreateServiceFunction(MODULENAME"/MODE_PGP", Service_ModePGP);
+ CreateServiceFunction(MODULENAME"/MODE_GPG", Service_ModeGPG);
+ CreateServiceFunction(MODULENAME"/MODE_RSA", Service_ModeRSAAES);
+ return 0;
+}
+
+/////////////////////////////////////////////////////////////////////////////////////////
+// Unload
+
+extern "C" __declspec(dllexport) int __cdecl Unload()
+{
+ DeleteCriticalSection(&localQueueMutex);
+ return 0;
+}
|