From 78d71d2cad6f243c6ff31d41380b8c5b58407de5 Mon Sep 17 00:00:00 2001 From: Kirill Volinsky Date: Thu, 17 May 2012 17:37:22 +0000 Subject: added some plugins git-svn-id: http://svn.miranda-ng.org/main/trunk@20 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- plugins/Autorun/autorun.h | 14 ++ plugins/Autorun/autorun.rc | 83 ++++++++++++ plugins/Autorun/autorun.sln | 26 ++++ plugins/Autorun/autorun.txt | 50 +++++++ plugins/Autorun/autorun.vcxproj | 230 ++++++++++++++++++++++++++++++++ plugins/Autorun/autorun.vcxproj.filters | 40 ++++++ plugins/Autorun/main.c | 165 +++++++++++++++++++++++ plugins/Autorun/resource.h | 15 +++ 8 files changed, 623 insertions(+) create mode 100644 plugins/Autorun/autorun.h create mode 100644 plugins/Autorun/autorun.rc create mode 100644 plugins/Autorun/autorun.sln create mode 100644 plugins/Autorun/autorun.txt create mode 100644 plugins/Autorun/autorun.vcxproj create mode 100644 plugins/Autorun/autorun.vcxproj.filters create mode 100644 plugins/Autorun/main.c create mode 100644 plugins/Autorun/resource.h (limited to 'plugins/Autorun') diff --git a/plugins/Autorun/autorun.h b/plugins/Autorun/autorun.h new file mode 100644 index 0000000000..4452ef7a4a --- /dev/null +++ b/plugins/Autorun/autorun.h @@ -0,0 +1,14 @@ +#define IDD_OPT_AUTORUN 101 +#define IDC_AUTORUN 102 + +#define SUB_KEY "Software\\Microsoft\\Windows\\CurrentVersion\\Run" +#define ModuleName "Autorun" + +// Plugin UUID for New plugin loader +// req. 0.7.18+ core +// {EB0465E2-CEEE-11DB-83EF-C1BF55D89593} + +#define MIID_AUTORUN {0xeb0465e2, 0xceee, 0x11db, { 0x83, 0xef, 0xc1, 0xbf, 0x55, 0xd8, 0x95, 0x93}} + +HKEY ROOT_KEY = HKEY_CURRENT_USER; + diff --git a/plugins/Autorun/autorun.rc b/plugins/Autorun/autorun.rc new file mode 100644 index 0000000000..b643834124 --- /dev/null +++ b/plugins/Autorun/autorun.rc @@ -0,0 +1,83 @@ +//Microsoft Developer Studio generated resource script. +// +#include "resource.h" + +#define APSTUDIO_READONLY_SYMBOLS +///////////////////////////////////////////////////////////////////////////// +// +// Generated from the TEXTINCLUDE 2 resource. +// +#include "autorun.h" +#include "afxres.h" + +///////////////////////////////////////////////////////////////////////////// +#undef APSTUDIO_READONLY_SYMBOLS + +///////////////////////////////////////////////////////////////////////////// +// Russian resources + +#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_RUS) +#ifdef _WIN32 +LANGUAGE LANG_RUSSIAN, SUBLANG_DEFAULT +#pragma code_page(1251) +#endif //_WIN32 + +///////////////////////////////////////////////////////////////////////////// +// +// Dialog +// + +IDD_OPT_AUTORUN DIALOGEX 0, 0, 200, 90 +STYLE DS_3DLOOK | DS_FIXEDSYS | WS_CHILD | WS_VISIBLE +EXSTYLE WS_EX_CONTROLPARENT +FONT 8, "MS Shell Dlg" +BEGIN + GROUPBOX "Autorun",0,3,3,193,60 + CONTROL "Launch Miranda IM at system startup",IDC_AUTORUN,"Button", + BS_AUTOCHECKBOX | BS_FLAT | WS_TABSTOP,15,20,165,10 + LTEXT "Note: At startup Miranda IM will use current profile", + IDC_STATIC,15,35,165,20,NOT WS_GROUP +END + + +#ifdef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// TEXTINCLUDE +// + +1 TEXTINCLUDE DISCARDABLE +BEGIN + "resource.h\0" +END + +2 TEXTINCLUDE DISCARDABLE +BEGIN + "#include ""autorun.h""\r\n" + "#include ""afxres.h""\r\n" + "\0" +END + +3 TEXTINCLUDE DISCARDABLE +BEGIN + "\r\n" + "\0" +END + +#endif // APSTUDIO_INVOKED + +#endif // Russian resources +///////////////////////////////////////////////////////////////////////////// + + + +#ifndef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// Generated from the TEXTINCLUDE 3 resource. +// + + +///////////////////////////////////////////////////////////////////////////// +#endif // not APSTUDIO_INVOKED + diff --git a/plugins/Autorun/autorun.sln b/plugins/Autorun/autorun.sln new file mode 100644 index 0000000000..0c93ceee03 --- /dev/null +++ b/plugins/Autorun/autorun.sln @@ -0,0 +1,26 @@ + +Microsoft Visual Studio Solution File, Format Version 11.00 +# Visual Studio 2010 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "autorun", "autorun.vcxproj", "{CC905A6E-3CCF-DB35-B1BD-0E0D0E5635B9}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Win32 = Debug|Win32 + Debug|x64 = Debug|x64 + Release|Win32 = Release|Win32 + Release|x64 = Release|x64 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {CC905A6E-3CCF-DB35-B1BD-0E0D0E5635B9}.Debug|Win32.ActiveCfg = Debug|Win32 + {CC905A6E-3CCF-DB35-B1BD-0E0D0E5635B9}.Debug|Win32.Build.0 = Debug|Win32 + {CC905A6E-3CCF-DB35-B1BD-0E0D0E5635B9}.Debug|x64.ActiveCfg = Debug|x64 + {CC905A6E-3CCF-DB35-B1BD-0E0D0E5635B9}.Debug|x64.Build.0 = Debug|x64 + {CC905A6E-3CCF-DB35-B1BD-0E0D0E5635B9}.Release|Win32.ActiveCfg = Release|Win32 + {CC905A6E-3CCF-DB35-B1BD-0E0D0E5635B9}.Release|Win32.Build.0 = Release|Win32 + {CC905A6E-3CCF-DB35-B1BD-0E0D0E5635B9}.Release|x64.ActiveCfg = Release|x64 + {CC905A6E-3CCF-DB35-B1BD-0E0D0E5635B9}.Release|x64.Build.0 = Release|x64 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/plugins/Autorun/autorun.txt b/plugins/Autorun/autorun.txt new file mode 100644 index 0000000000..cec7052075 --- /dev/null +++ b/plugins/Autorun/autorun.txt @@ -0,0 +1,50 @@ +Autorun 0.1.0.0 + +Written by and copyright (c) Sergey V. Gershovich a.k.a. Jazzy$, March 2003 + e-mail: jazzy@arcticsu.ru + +This plugin is a simple way to enable/disable to launch Miranda IM +with system startup. + + +***** DISCLAIMER OF WARRANTY ***** + +This software and the accompanying files are presented "AS IS" and without +warranties whether expressed or implied. Use it at your own risk. + +********************************** + +Usage +------ +Goto: Options->Plugins->Autorun + + +Version history +---------------------- +0.1.0.0: - Preparation for 0.8.x.x plugin loader + MIID_AUTORUN {EB0465E2-CEEE-11DB-83EF-C1BF55D89593} +0.0.0.3: - Decrease size of plugin to 3 kb + - Change image base address to: 0x30040000 + - Miranda IM v0.3alpha build 040303 or higher is required! + - Language strings updated + +0.0.0.2: - Some bugfix with long path & DB-filename + +0.0.0.1: - Initial release + + +Translation +----------- +"Autorun" can be translated with the Miranda IM language files + + +;; == Autorun v0.0.0.3 == + +;Name of plugin +;[Autorun] + +;Options page string +;[Launch Miranda IM at system startup] + +;Options page string +;[Note: At startup Miranda IM will use current profile] \ No newline at end of file diff --git a/plugins/Autorun/autorun.vcxproj b/plugins/Autorun/autorun.vcxproj new file mode 100644 index 0000000000..4c24b4cfc4 --- /dev/null +++ b/plugins/Autorun/autorun.vcxproj @@ -0,0 +1,230 @@ + + + + + Debug + Win32 + + + Debug + x64 + + + Release + Win32 + + + Release + x64 + + + + + + + + + DynamicLibrary + MultiByte + true + + + DynamicLibrary + MultiByte + true + + + DynamicLibrary + MultiByte + + + DynamicLibrary + MultiByte + + + + + + + + + + + + + + + + + + + + + + + $(SolutionDir)$(Configuration)/Plugins\ + $(SolutionDir)$(Configuration)/Obj/$(ProjectName)\ + + + $(SolutionDir)$(Configuration)64/Plugins\ + $(SolutionDir)$(Configuration)64/Obj/$(ProjectName)\ + + + $(SolutionDir)$(Configuration)/Plugins\ + $(SolutionDir)$(Configuration)/Obj/$(ProjectName)\ + true + + + $(SolutionDir)$(Configuration)64/Plugins\ + $(SolutionDir)$(Configuration)64/Obj/$(ProjectName)\ + true + + + + MultiThreadedDebug + false + Disabled + Level3 + true + EditAndContinue + ../../include;../ExternalAPI;%(AdditionalIncludeDirectories) + WIN32;_DEBUG;_WINDOWS;_USRDLL;autorun_EXPORTS;%(PreprocessorDefinitions) + EnableFastChecks + + + true + _DEBUG;%(PreprocessorDefinitions) + .\Debug\autorun.tlb + true + Win32 + + + _DEBUG;%(PreprocessorDefinitions) + + + + true + true + Windows + 0x30040000 + odbc32.lib;odbccp32.lib;%(AdditionalDependencies) + $(IntDir)$(TargetName).lib + + + + + MultiThreadedDebug + false + Disabled + Level3 + ../../include;../ExternalAPI;%(AdditionalIncludeDirectories) + WIN64;_DEBUG;_WINDOWS;_USRDLL;autorun_EXPORTS;%(PreprocessorDefinitions) + EnableFastChecks + + + true + _DEBUG;%(PreprocessorDefinitions) + .\Debug\autorun.tlb + true + + + _DEBUG;%(PreprocessorDefinitions) + + + + true + true + Windows + 0x30040000 + odbc32.lib;odbccp32.lib;%(AdditionalDependencies) + $(IntDir)$(TargetName).lib + + + + + MultiThreadedDLL + OnlyExplicitInline + true + true + Full + Level3 + ../../include;../ExternalAPI;%(AdditionalIncludeDirectories) + WIN32;NDEBUG;_WINDOWS;_USRDLL;autorun_EXPORTS; _CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) + Size + true + + + true + NDEBUG;%(PreprocessorDefinitions) + .\Release\autorun.tlb + false + Win32 + + + NDEBUG;%(PreprocessorDefinitions) + + + + true + Windows + 0x30040000 + kernel32.lib;user32.lib;advapi32.lib;%(AdditionalDependencies) + /FILEALIGN:512 /SECTION:.text,ER /IGNORE:4078 /IGNORE:4078 + true + true + $(IntDir)$(TargetName).lib + UseLinkTimeCodeGeneration + + + + + MultiThreadedDLL + true + true + Full + Level3 + ../../include;../ExternalAPI;%(AdditionalIncludeDirectories) + WIN64;NDEBUG;_WINDOWS;_USRDLL;autorun_EXPORTS; _CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) + Size + true + OnlyExplicitInline + + + true + NDEBUG;%(PreprocessorDefinitions) + .\Release\autorun.tlb + false + + + NDEBUG;%(PreprocessorDefinitions) + + + + true + Windows + 0x30040000 + kernel32.lib;user32.lib;advapi32.lib;%(AdditionalDependencies) + /FILEALIGN:512 /SECTION:.text,ER /IGNORE:4078 /IGNORE:4078 + true + true + $(IntDir)$(TargetName).lib + UseLinkTimeCodeGeneration + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/plugins/Autorun/autorun.vcxproj.filters b/plugins/Autorun/autorun.vcxproj.filters new file mode 100644 index 0000000000..2977fdc693 --- /dev/null +++ b/plugins/Autorun/autorun.vcxproj.filters @@ -0,0 +1,40 @@ + + + + + {08a21636-368d-4feb-8d0d-0a27f237e1a2} + cpp;c;cxx;rc;def;r;odl;idl;hpj;bat + + + {9e6f20dc-3391-4299-9f74-e91d4f984ad3} + h;hpp;hxx;hm;inl + + + {18fd6180-ebb2-4558-b945-c4dac823f11b} + ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe + + + + + Header Files + + + Header Files + + + + + Resource Files + + + + + Resource Files + + + + + Source Files + + + \ No newline at end of file diff --git a/plugins/Autorun/main.c b/plugins/Autorun/main.c new file mode 100644 index 0000000000..c5a498afa1 --- /dev/null +++ b/plugins/Autorun/main.c @@ -0,0 +1,165 @@ +#include +#include "autorun.h" + +#include "newpluginapi.h" +#include "m_langpack.h" +#include "m_options.h" +#include "m_database.h" +#pragma hdrstop + + +HINSTANCE hInst; +PLUGINLINK *pluginLink; +HANDLE hHookOptionInit = NULL; + +PLUGININFOEX pluginInfoEx= +{ // about plugin + sizeof(PLUGININFOEX), + "Autorun", + PLUGIN_MAKE_VERSION(0,1,0,1), + "This plugin is a simple way to enable/disable to launch Miranda IM with system startup.", + "Sergey V. Gershovich a.k.a. Jazzy$ (fixed by Wolfram3D)", + "", + "Copyright © 2002-2007 Sergey V. Gershovich a.k.a. Jazzy$", + "http://miranda-im.org/download/index.php?action=viewfile&id=285", + 0, 0, + MIID_AUTORUN +}; + +BOOL WINAPI DllMain(HINSTANCE hinstDLL,DWORD fdwReason,LPVOID lpvReserved) +{ + // plugin entry point + if (fdwReason == DLL_PROCESS_ATTACH) + { + hInst = hinstDLL; + DisableThreadLibraryCalls(hinstDLL); + } + return TRUE; +} +void GetProfilePath(char *res) +{ + char dbname[MAX_PATH], dbpath[MAX_PATH], exename[MAX_PATH]; + CallService(MS_DB_GETPROFILENAME,sizeof(dbname),(LPARAM)(char*) dbname); + CallService(MS_DB_GETPROFILEPATH,sizeof(dbpath),(LPARAM)(char*) dbpath); + GetModuleFileName(NULL,exename,sizeof(exename)); + lstrcat(dbpath,"\\"); + lstrcpyn(dbpath+lstrlen(dbpath),dbname,lstrlen(dbname)-3); + strcat(dbpath, "\\"); + strcat(dbpath, dbname); // path + profile name + wsprintf(res,"\"%s\" \"%s\"",exename, dbpath); +} + +static void SetAutorun(BOOL autorun) +{ + HKEY hKey; + DWORD dw; + switch (autorun) + { + case TRUE: + if (RegCreateKeyEx(ROOT_KEY, SUB_KEY,0,NULL,0,KEY_CREATE_SUB_KEY|KEY_SET_VALUE,NULL,&hKey,&dw) == ERROR_SUCCESS) + { + char result[MAX_PATH]; + GetProfilePath (result); + RegSetValueEx(hKey,"MirandaIM",0,REG_SZ,result,lstrlen(result)+1); + RegCloseKey(hKey); + break; + } + case FALSE: + if (RegOpenKey(ROOT_KEY,SUB_KEY,&hKey) == ERROR_SUCCESS) + { + RegDeleteValue(hKey,"MirandaIM"); + RegCloseKey(hKey); + break; + } + } +} + + +static BOOL CmpCurrentAndRegistry() +{ + HKEY hKey; + DWORD dwBufLen = MAX_PATH; + char result[MAX_PATH], dbpath[MAX_PATH]; + GetProfilePath (result); + + if (RegOpenKeyEx(ROOT_KEY, SUB_KEY, 0, KEY_QUERY_VALUE, &hKey) == ERROR_SUCCESS) + { + if (RegQueryValueEx(hKey,"MirandaIM",NULL,NULL,(LPBYTE)dbpath,&dwBufLen) == ERROR_SUCCESS) + { + return (lstrcmpi(result,dbpath) == 0 ? TRUE : FALSE); + } + else + return FALSE; + } + else + return FALSE; +} + +static INT_PTR CALLBACK DlgProcAutorunOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) +{ + switch (msg) + { + case WM_INITDIALOG: + TranslateDialogDefault(hwndDlg); + CheckDlgButton(hwndDlg,IDC_AUTORUN,CmpCurrentAndRegistry()); // Check chekbox if Registry value exists + return TRUE; + case WM_COMMAND: + SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0); // Send message to activate "Apply" button + return TRUE; + break; + case WM_NOTIFY: + switch(((LPNMHDR)lParam)->idFrom) { + case 0: + switch (((LPNMHDR)lParam)->code) + { + case PSN_APPLY: // if "Apply" pressed then... + SetAutorun(IsDlgButtonChecked(hwndDlg,IDC_AUTORUN)); //Save changes to registry; + return TRUE; + } + break; + } + break; + } + return FALSE; +} + + +static int AutorunOptInitialise(WPARAM wParam,LPARAM lParam) +{ + OPTIONSDIALOGPAGE odp; + odp.cbSize=sizeof(odp); + odp.position=100100000; + odp.hInstance=hInst; + odp.pszTemplate=MAKEINTRESOURCE(IDD_OPT_AUTORUN); + odp.pszTitle=Translate(ModuleName); + odp.pszGroup=Translate("Plugins"); + odp.pfnDlgProc=DlgProcAutorunOpts; + odp.flags=ODPF_BOLDGROUPS; + CallService(MS_OPT_ADDPAGE,wParam,(LPARAM)&odp); + return 0; +} +//========================================================================== +__declspec(dllexport) PLUGININFOEX* MirandaPluginInfoEx(DWORD mirandaVersion) +{ + return &pluginInfoEx; +} + +static const MUUID interfaces[] = {MIID_AUTORUN, MIID_LAST}; +__declspec(dllexport) const MUUID* MirandaPluginInterfaces(void) +{ + return interfaces; +} + +int __declspec(dllexport) Load(PLUGINLINK *link) +{ + pluginLink = link; + hHookOptionInit = HookEvent(ME_OPT_INITIALISE,AutorunOptInitialise); + return 0; +} + +int __declspec(dllexport) Unload(void) +{ + if (hHookOptionInit) + UnhookEvent(hHookOptionInit); + return 0; +} \ No newline at end of file diff --git a/plugins/Autorun/resource.h b/plugins/Autorun/resource.h new file mode 100644 index 0000000000..c5b53f192c --- /dev/null +++ b/plugins/Autorun/resource.h @@ -0,0 +1,15 @@ +//{{NO_DEPENDENCIES}} +// Microsoft Developer Studio generated include file. +// Used by autorun.rc +// + +// Next default values for new objects +// +#ifdef APSTUDIO_INVOKED +#ifndef APSTUDIO_READONLY_SYMBOLS +#define _APS_NEXT_RESOURCE_VALUE 101 +#define _APS_NEXT_COMMAND_VALUE 40001 +#define _APS_NEXT_CONTROL_VALUE 1000 +#define _APS_NEXT_SYMED_VALUE 101 +#endif +#endif -- cgit v1.2.3