summaryrefslogtreecommitdiff
path: root/plugins/AutoShutdown
diff options
context:
space:
mode:
authorKirill Volinsky <mataes2007@gmail.com>2012-06-29 05:38:03 +0000
committerKirill Volinsky <mataes2007@gmail.com>2012-06-29 05:38:03 +0000
commitaf7e438cfe8ce85e1da234318ed1584e89d952cc (patch)
tree4cdb1379ef8d6c00389aa89cfb27a404ae2aba56 /plugins/AutoShutdown
parent230623d50baff4e8bf13a8572e0b895bad7b7ed4 (diff)
only add some plugins and protocols, not adapted
See please maybe not all need us git-svn-id: http://svn.miranda-ng.org/main/trunk@678 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'plugins/AutoShutdown')
-rw-r--r--plugins/AutoShutdown/common.h93
-rw-r--r--plugins/AutoShutdown/cpuusage.c257
-rw-r--r--plugins/AutoShutdown/cpuusage.h24
-rw-r--r--plugins/AutoShutdown/docs/Info_Src.txt31
-rw-r--r--plugins/AutoShutdown/docs/License_Appendix.txt64
-rw-r--r--plugins/AutoShutdown/docs/Shutdown-Developer.txt49
-rw-r--r--plugins/AutoShutdown/docs/Shutdown-License.txt278
-rw-r--r--plugins/AutoShutdown/docs/Shutdown-Readme.txt329
-rw-r--r--plugins/AutoShutdown/docs/Shutdown-Translation.txt240
-rw-r--r--plugins/AutoShutdown/docs/countdown.wavbin0 -> 654 bytes
-rw-r--r--plugins/AutoShutdown/frame.c644
-rw-r--r--plugins/AutoShutdown/frame.h28
-rw-r--r--plugins/AutoShutdown/m_shutdown.h196
-rw-r--r--plugins/AutoShutdown/main.c192
-rw-r--r--plugins/AutoShutdown/options.c189
-rw-r--r--plugins/AutoShutdown/options.h24
-rw-r--r--plugins/AutoShutdown/res/Thumbs.dbbin0 -> 6144 bytes
-rw-r--r--plugins/AutoShutdown/res/active.icobin0 -> 1406 bytes
-rw-r--r--plugins/AutoShutdown/res/header.icobin0 -> 2238 bytes
-rw-r--r--plugins/AutoShutdown/res/inactive.icobin0 -> 1406 bytes
-rw-r--r--plugins/AutoShutdown/resource.h58
-rw-r--r--plugins/AutoShutdown/resource.rc253
-rw-r--r--plugins/AutoShutdown/settingsdlg.c512
-rw-r--r--plugins/AutoShutdown/settingsdlg.h30
-rw-r--r--plugins/AutoShutdown/shutdown.def11
-rw-r--r--plugins/AutoShutdown/shutdown.dep394
-rw-r--r--plugins/AutoShutdown/shutdown.dsp451
-rw-r--r--plugins/AutoShutdown/shutdown.dsw29
-rw-r--r--plugins/AutoShutdown/shutdown.mak435
-rw-r--r--plugins/AutoShutdown/shutdownsvc.c624
-rw-r--r--plugins/AutoShutdown/shutdownsvc.h29
-rw-r--r--plugins/AutoShutdown/utils.c458
-rw-r--r--plugins/AutoShutdown/utils.h48
-rw-r--r--plugins/AutoShutdown/version.h40
-rw-r--r--plugins/AutoShutdown/version.rc51
-rw-r--r--plugins/AutoShutdown/watcher.c408
-rw-r--r--plugins/AutoShutdown/watcher.h29
37 files changed, 6498 insertions, 0 deletions
diff --git a/plugins/AutoShutdown/common.h b/plugins/AutoShutdown/common.h
new file mode 100644
index 0000000000..eec97b0873
--- /dev/null
+++ b/plugins/AutoShutdown/common.h
@@ -0,0 +1,93 @@
+/*
+
+'AutoShutdown'-Plugin for Miranda IM
+
+Copyright 2004-2007 H. Herkenrath
+
+This program is free software; you can redistribute it and/or
+modify it under the terms of the GNU General Public License
+as published by the Free Software Foundation; either version 2
+of the License, or (at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program (Shutdown-License.txt); if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+*/
+
+#include <stdio.h> /* for mir_sntprintf() */
+#include <time.h> /* for mktime(),time() */
+#include <wchar.h> /* for _itow() */
+#include <tchar.h>
+
+#define _WIN32_WINNT 0x0700
+#define __RPCASYNC_H__ /* VC6 shows warning there */
+#include <windows.h>
+#pragma warning(disable:4201) /* nonstandard extension used : nameless struct/union */
+#include <commctrl.h>
+#pragma warning(default:4201) /* nonstandard extension used : nameless struct/union */
+#include <win2k.h>
+
+/* WinXP+: shutdown reason codes */
+#if defined(EWX_RESTARTAPPS) /* new MS Platform SDK */
+ #include <reason.h>
+#else
+ #define SHTDN_REASON_MAJOR_OTHER 0x00000000
+ #define SHTDN_REASON_MINOR_OTHER 0x00000000
+ #define SHTDN_REASON_FLAG_PLANNED 0x80000000
+#endif
+
+/* RAS */
+#undef WINVER
+#define WINVER 0x400 /* prevent INVALID_BUFFER error */
+#include <ras.h> /* for RasEnumConnections(), RasHangUp() */
+#include <raserror.h> /* error codes for RAS */
+
+#define MIRANDA_VER 0x0702
+#include <newpluginapi.h>
+#include <m_utils.h>
+#include <m_database.h>
+#include <m_clist.h>
+#include <m_clui.h>
+#include <m_langpack.h>
+#include <m_system.h>
+#include <m_skin.h>
+#include <m_protosvc.h>
+#include <m_protocols.h>
+#include <m_plugins.h>
+#include <m_options.h>
+#include <m_message.h>
+#include <m_file.h>
+#include <m_idle.h>
+#include <m_weather.h>
+#include <m_hddinfo.h>
+#include <m_cluiframes.h>
+#include <m_clistint.h>
+#include <m_toptoolbar.h>
+#include <m_fontservice.h>
+#include <m_hotkey.h>
+#include <m_hotkeysplus.h>
+#include <m_hotkeysservice.h>
+#include <m_icolib.h>
+#include <m_clc.h>
+#include <m_genmenu.h>
+#include <m_trigger.h>
+#include <m_mwclc.h>
+#include <m_button.h>
+#include <m_autoreplacer.h>
+#include <m_magneticwindows.h>
+#include <m_snappingwindows.h>
+
+#include "m_shutdown.h"
+#include "cpuusage.h"
+#include "frame.h"
+#include "options.h"
+#include "settingsdlg.h"
+#include "shutdownsvc.h"
+#include "utils.h"
+#include "watcher.h"
+#include "resource.h"
diff --git a/plugins/AutoShutdown/cpuusage.c b/plugins/AutoShutdown/cpuusage.c
new file mode 100644
index 0000000000..1270fe02ec
--- /dev/null
+++ b/plugins/AutoShutdown/cpuusage.c
@@ -0,0 +1,257 @@
+/*
+
+'AutoShutdown'-Plugin for Miranda IM
+
+Copyright 2004-2007 H. Herkenrath
+
+This program is free software; you can redistribute it and/or
+modify it under the terms of the GNU General Public License
+as published by the Free Software Foundation; either version 2
+of the License, or (at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program (Shutdown-License.txt); if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+*/
+
+#include "common.h"
+
+/************************* Stat Switch ********************************/
+
+#define Li2Double(x) ((double)((x).HighPart)*4.294967296E9+(double)((x).LowPart))
+
+static BOOL WinNT_PerfStatsSwitch(TCHAR *pszServiceName,BOOL fDisable)
+{
+ HKEY hKeyServices,hKeyService,hKeyPerf;
+ DWORD dwData,dwDataSize;
+ BOOL fSwitched=FALSE;
+ /* Win2000+ */
+ if(!RegOpenKeyEx(HKEY_LOCAL_MACHINE,_T("System\\CurrentControlSet\\Services"),0,KEY_QUERY_VALUE|KEY_SET_VALUE,&hKeyServices)) {
+ if(!RegOpenKeyEx(hKeyServices,pszServiceName,0,KEY_QUERY_VALUE|KEY_SET_VALUE,&hKeyService)) {
+ if(!RegOpenKeyEx(hKeyService,_T("Performance"),0,KEY_QUERY_VALUE|KEY_SET_VALUE,&hKeyPerf)) {
+ dwDataSize=sizeof(DWORD);
+ if(!RegQueryValueEx(hKeyPerf,_T("Disable Performance Counters"),NULL,NULL,(BYTE*)&dwData,&dwDataSize))
+ if((dwData!=0)!=fDisable)
+ fSwitched=!RegSetValueEx(hKeyPerf,_T("Disable Performance Counters"),0,REG_DWORD,(BYTE*)&fDisable,dwDataSize);
+ RegCloseKey(hKeyPerf);
+ }
+ RegCloseKey(hKeyService);
+ }
+ RegCloseKey(hKeyServices);
+ }
+ return fSwitched;
+}
+
+#if !defined(_UNICODE)
+static void Win9x_PerfStatsSwitch(HKEY hKey,char *pszAction,char *pszName)
+{
+ DWORD dwData,dwSize;
+ dwSize=sizeof(dwData);
+ if(!RegOpenKeyExA(hKey,pszAction,0,KEY_QUERY_VALUE,&hKey)) {
+ /* a simple query does the trick (data and size must not be NULL!) */
+ RegQueryValueExA(hKey,pszName,NULL,NULL,(BYTE*)&dwData,&dwSize);
+ RegCloseKey(hKey);
+ }
+}
+#endif
+
+/************************* Poll Thread ********************************/
+
+struct CpuUsageThreadParams {
+ DWORD dwDelayMillis;
+ CPUUSAGEAVAILPROC pfnDataAvailProc;
+ LPARAM lParam;
+ HANDLE hFirstEvent;
+ DWORD *pidThread;
+};
+
+static BOOL CallBackAndWait(struct CpuUsageThreadParams *param,BYTE nCpuUsage)
+{
+ if(param->hFirstEvent!=NULL) {
+ /* return value for PollCpuUsage() */
+ *param->pidThread=GetCurrentThreadId();
+ SetEvent(param->hFirstEvent);
+ param->hFirstEvent=NULL;
+ /* lower priority after first call */
+ SetThreadPriority(GetCurrentThread(),THREAD_PRIORITY_IDLE);
+ }
+ if(!param->pfnDataAvailProc(nCpuUsage,param->lParam)) return FALSE;
+ SleepEx(param->dwDelayMillis,TRUE);
+ return !Miranda_Terminated();
+}
+
+#if !defined(_UNICODE)
+static void Win9x_PollThread(struct CpuUsageThreadParams *param)
+{
+ HKEY hKeyStats,hKeyData;
+ DWORD dwBufferSize,dwData;
+
+ if(!RegOpenKeyExA(HKEY_DYN_DATA,"PerfStats",0,KEY_QUERY_VALUE,&hKeyStats)) {
+ /* start query */
+ /* not needed for kernel
+ * Win9x_PerfStatsSwitch(hKeyStats,"StartSrv","KERNEL"); */
+ Win9x_PerfStatsSwitch(hKeyStats,"StartStat","KERNEL\\CPUUsage");
+ /* retrieve cpu usage */
+ if(!RegOpenKeyExA(hKeyStats,"StatData",0,KEY_QUERY_VALUE,&hKeyData)) {
+ dwBufferSize=sizeof(dwData);
+ while(!RegQueryValueExA(hKeyData,"KERNEL\\CPUUsage",NULL,NULL,(BYTE*)&dwData,&dwBufferSize)) {
+ dwBufferSize=sizeof(dwData);
+ if(!CallBackAndWait(param,(BYTE)dwData)) break;
+ }
+ RegCloseKey(hKeyData);
+ }
+ /* stop query */
+ Win9x_PerfStatsSwitch(hKeyStats,"StopStat","KERNEL\\CPUUsage");
+ /* not needed for kernel
+ * Win9x_PerfStatsSwitch(hKeyStats,"StopSrv","KERNEL"); */
+ RegCloseKey(hKeyStats);
+ }
+ /* return error for PollCpuUsage() if never succeeded */
+ if(param->hFirstEvent!=NULL) SetEvent(param->hFirstEvent);
+ mir_free(param);
+}
+#endif /* !_UNICODE */
+
+static void WinNT_PollThread(struct CpuUsageThreadParams *param)
+{
+ DWORD dwBufferSize=0,dwCount;
+ BYTE *pBuffer=NULL;
+ PERF_DATA_BLOCK *pPerfData=NULL;
+ LONG res,lCount;
+ PERF_OBJECT_TYPE *pPerfObj;
+ PERF_COUNTER_DEFINITION *pPerfCounter;
+ PERF_INSTANCE_DEFINITION *pPerfInstance;
+ PERF_COUNTER_BLOCK *pPerfCounterBlock;
+ DWORD dwObjectId,dwCounterId;
+ WCHAR wszValueName[11],*pwszInstanceName;
+ BYTE nCpuUsage;
+ BOOL fSwitched,fFound,fIsFirst=FALSE;
+ LARGE_INTEGER liPrevCounterValue={0},liCurrentCounterValue={0},liPrevPerfTime100nSec={0};
+
+ /* init */
+ if(IsWinVer2000Plus()) { /* Win2000+: */
+ dwObjectId=238; /*'Processor' object */
+ dwCounterId=6; /* '% processor time' counter */
+ pwszInstanceName=L"_Total"; /* '_Total' instance */
+ } else { /* WinNT4: */
+ dwObjectId=2; /* 'System' object */
+ dwCounterId=240; /* '% Total processor time' counter */
+ pwszInstanceName=NULL;
+ }
+ _itow(dwObjectId,wszValueName,10);
+ fSwitched=WinNT_PerfStatsSwitch(_T("PerfOS"),FALSE);
+
+ /* poll */
+ for(;;) {
+ /* retrieve data for given object */
+ res=RegQueryValueExW(HKEY_PERFORMANCE_DATA,wszValueName,NULL,NULL,(BYTE*)pPerfData,&dwBufferSize);
+ while(!pBuffer || res==ERROR_MORE_DATA) {
+ pBuffer=(BYTE*)mir_realloc(pPerfData,dwBufferSize+=256);
+ if(!pBuffer) break;
+ pPerfData=(PERF_DATA_BLOCK*)pBuffer;
+ res=RegQueryValueExW(HKEY_PERFORMANCE_DATA,wszValueName,NULL,NULL,pBuffer,&dwBufferSize);
+ }
+ if(res!=ERROR_SUCCESS) break;
+
+ /* find object in data */
+ fFound=FALSE;
+ /* first object */
+ pPerfObj=(PERF_OBJECT_TYPE*)((BYTE*)pPerfData+pPerfData->HeaderLength);
+ for(dwCount=0;dwCount<pPerfData->NumObjectTypes;++dwCount) {
+ if(pPerfObj->ObjectNameTitleIndex==dwObjectId) {
+ /* find counter in object data */
+ /* first counter */
+ pPerfCounter=(PERF_COUNTER_DEFINITION*)((BYTE*)pPerfObj+pPerfObj->HeaderLength);
+ for(dwCount=0;dwCount<(pPerfObj->NumCounters);++dwCount) {
+ if(pPerfCounter->CounterNameTitleIndex==dwCounterId) {
+ /* find instance in counter data */
+ if(pPerfObj->NumInstances==PERF_NO_INSTANCES) {
+ pPerfCounterBlock=(PERF_COUNTER_BLOCK*)((BYTE*)pPerfObj+pPerfObj->DefinitionLength);
+ liCurrentCounterValue=*(LARGE_INTEGER*)((BYTE*)pPerfCounterBlock+pPerfCounter->CounterOffset);
+ fFound=TRUE;
+ }
+ else {
+ /* first instance */
+ pPerfInstance=(PERF_INSTANCE_DEFINITION*)((BYTE*)pPerfObj+pPerfObj->DefinitionLength);
+ for(lCount=0;lCount<(pPerfObj->NumInstances);++lCount) {
+ pPerfCounterBlock=(PERF_COUNTER_BLOCK*)((BYTE*)pPerfInstance+pPerfInstance->ByteLength);
+ if(!lstrcmpiW(pwszInstanceName,(WCHAR*)((BYTE*)pPerfInstance+pPerfInstance->NameOffset)) || !pwszInstanceName) {
+ liCurrentCounterValue=*(LARGE_INTEGER*)((BYTE*)pPerfCounterBlock+pPerfCounter->CounterOffset);
+ fFound=TRUE;
+ break;
+ }
+ /* next instance */
+ pPerfInstance=(PPERF_INSTANCE_DEFINITION)((BYTE*)pPerfCounterBlock+pPerfCounterBlock->ByteLength);
+ }
+ }
+ break;
+ }
+ /* next counter */
+ pPerfCounter=(PERF_COUNTER_DEFINITION*)((BYTE*)pPerfCounter+pPerfCounter->ByteLength);
+ }
+ break;
+ }
+ /* next object */
+ pPerfObj=(PERF_OBJECT_TYPE*)((BYTE*)pPerfObj+pPerfObj->TotalByteLength);
+ }
+ if(!fFound) break;
+
+ /* calc val from data, we need two samplings
+ * counter type: PERF_100NSEC_TIMER_INV
+ * calc: time base=100Ns, value=100*(1-(data_diff)/(100NsTime_diff)) */
+ if(!fIsFirst) {
+ nCpuUsage=(BYTE)((1.0-(Li2Double(liCurrentCounterValue)-Li2Double(liPrevCounterValue))/(Li2Double(pPerfData->PerfTime100nSec)-Li2Double(liPrevPerfTime100nSec)))*100.0+0.5);
+ if(!CallBackAndWait(param,nCpuUsage)) break;
+ }
+ else fIsFirst=FALSE;
+ /* store current sampling for next */
+ CopyMemory(&liPrevCounterValue,&liCurrentCounterValue,sizeof(LARGE_INTEGER));
+ CopyMemory(&liPrevPerfTime100nSec,&pPerfData->PerfTime100nSec,sizeof(LARGE_INTEGER));
+ }
+
+ /* uninit */
+ if(pPerfData) mir_free(pPerfData);
+ if(fSwitched) WinNT_PerfStatsSwitch(_T("PerfOS"),TRUE);
+
+ /* return error for PollCpuUsage() if never succeeded */
+ if(param->hFirstEvent!=NULL) SetEvent(param->hFirstEvent);
+ mir_free(param);
+}
+
+/************************* Start Thread *******************************/
+
+// returns poll thread id on success
+DWORD PollCpuUsage(CPUUSAGEAVAILPROC pfnDataAvailProc,LPARAM lParam,DWORD dwDelayMillis)
+{
+ struct CpuUsageThreadParams *param;
+ DWORD idThread=0;
+ HANDLE hFirstEvent;
+
+ /* init params */
+ param=(struct CpuUsageThreadParams*)mir_alloc(sizeof(struct CpuUsageThreadParams));
+ if(param==NULL) return FALSE;
+ param->dwDelayMillis=dwDelayMillis;
+ param->pfnDataAvailProc=pfnDataAvailProc;
+ param->lParam=lParam;
+ param->pidThread=&idThread;
+ param->hFirstEvent=hFirstEvent=CreateEvent(NULL,FALSE,FALSE,NULL);
+ if(hFirstEvent==NULL) {
+ mir_free(param);
+ return 0;
+ }
+ /* start thread */
+#if defined(_UNICODE)
+ if(mir_forkthread(WinNT_PollThread,param)!=-1)
+#else
+ if(mir_forkthread(IsWinVerNT()?WinNT_PollThread:Win9x_PollThread,param)!=-1)
+#endif
+ WaitForSingleObject(hFirstEvent,INFINITE); /* wait for first success */
+ else mir_free(param); /* thread not started */
+ CloseHandle(hFirstEvent);
+ return idThread;
+}
diff --git a/plugins/AutoShutdown/cpuusage.h b/plugins/AutoShutdown/cpuusage.h
new file mode 100644
index 0000000000..681a2c8213
--- /dev/null
+++ b/plugins/AutoShutdown/cpuusage.h
@@ -0,0 +1,24 @@
+/*
+
+'AutoShutdown'-Plugin for Miranda IM
+
+Copyright 2004-2007 H. Herkenrath
+
+This program is free software; you can redistribute it and/or
+modify it under the terms of the GNU General Public License
+as published by the Free Software Foundation; either version 2
+of the License, or (at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program (Shutdown-License.txt); if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+*/
+
+/* Start Thread */
+typedef BOOL (CALLBACK* CPUUSAGEAVAILPROC)(BYTE nCpuUsage,LPARAM lParam);
+DWORD PollCpuUsage(CPUUSAGEAVAILPROC pfnDataAvailProc,LPARAM lParam,DWORD dwDelayMillis);
diff --git a/plugins/AutoShutdown/docs/Info_Src.txt b/plugins/AutoShutdown/docs/Info_Src.txt
new file mode 100644
index 0000000000..2b61a98f37
--- /dev/null
+++ b/plugins/AutoShutdown/docs/Info_Src.txt
@@ -0,0 +1,31 @@
+
+AutoShutdown 1.4.0.1 for Miranda IM 0.7+
+------------------------------------------------------------------------
+ Source Code
+
+Reminder:
+'AutoShutdown' is released under the terms of the GNU General Public License.
+See 'Shutdown-License.txt' for more details.
+'AutoShutdown' is copyright 2004-2007 by H. Herkenrath.
+
+Please notify me of any changes that improve
+'AutoShutdown' or add new features.
+If you have any questions on the code, feel free
+to contact me at my email address.
+
+ H. Herkenrath (hrathh at users.sourceforge.net)
+
+
+Notes
+------------------------------------------------------------------------
+The following files need to be changed to bump the version number:
+
+Info_Src.txt (1 place)
+version.h (4 places)
+m_shutdown.h (1 place)
+m_shutdown.inc (1 place)
+docs\Shutdown-Readme.txt (3 places)
+docs\Shutdown-Translation.txt (2 or 3 places)
+docs\Shutdown-Developer.txt (1 place)
+
+
diff --git a/plugins/AutoShutdown/docs/License_Appendix.txt b/plugins/AutoShutdown/docs/License_Appendix.txt
new file mode 100644
index 0000000000..c590c3f5fb
--- /dev/null
+++ b/plugins/AutoShutdown/docs/License_Appendix.txt
@@ -0,0 +1,64 @@
+
+Excecpt of GNU General Public License (Appendix):
+ Copyright (C) 1989, 1991 Free Software Foundation, Inc.
+ 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+
+ How to Apply These Terms to Your New Programs
+
+ If you develop a new program, and you want it to be of the greatest
+possible use to the public, the best way to achieve this is to make it
+free software which everyone can redistribute and change under these terms.
+
+ To do so, attach the following notices to the program. It is safest
+to attach them to the start of each source file to most effectively
+convey the exclusion of warranty; and each file should have at least
+the "copyright" line and a pointer to where the full notice is found.
+
+ <one line to give the program's name and a brief idea of what it does.>
+ Copyright (C) <year> <name of author>
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+
+
+Also add information on how to contact you by electronic and paper mail.
+
+If the program is interactive, make it output a short notice like this
+when it starts in an interactive mode:
+
+ Gnomovision version 69, Copyright (C) year name of author
+ Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
+ This is free software, and you are welcome to redistribute it
+ under certain conditions; type `show c' for details.
+
+The hypothetical commands `show w' and `show c' should show the appropriate
+parts of the General Public License. Of course, the commands you use may
+be called something other than `show w' and `show c'; they could even be
+mouse-clicks or menu items--whatever suits your program.
+
+You should also get your employer (if you work as a programmer) or your
+school, if any, to sign a "copyright disclaimer" for the program, if
+necessary. Here is a sample; alter the names:
+
+ Yoyodyne, Inc., hereby disclaims all copyright interest in the program
+ `Gnomovision' (which makes passes at compilers) written by James Hacker.
+
+ <signature of Ty Coon>, 1 April 1989
+ Ty Coon, President of Vice
+
+This General Public License does not permit incorporating your program into
+proprietary programs. If your program is a subroutine library, you may
+consider it more useful to permit linking proprietary applications with the
+library. If this is what you want to do, use the GNU Library General
+Public License instead of this License.
diff --git a/plugins/AutoShutdown/docs/Shutdown-Developer.txt b/plugins/AutoShutdown/docs/Shutdown-Developer.txt
new file mode 100644
index 0000000000..9b15e2b09b
--- /dev/null
+++ b/plugins/AutoShutdown/docs/Shutdown-Developer.txt
@@ -0,0 +1,49 @@
+
+AutoShutdown 1.4.0.2 for Miranda IM 0.7+
+------------------------------------------------------------------------
+ Developer Information
+
+ Contents: -------------------------------
+ | Translation, Services/Events,
+ | Debug Symbols, Coding Language, Rebase Info
+
+Translation
+-----------------
+ The translation string listing can be found in
+ 'Shutdown-Translation.txt'.
+
+Services/Events
+-----------------
+ For more information about which service functions are offered by
+ 'AutoShutdown' and about how they can be used by your plugin,
+ please refer to 'm_shutdown.h'.
+ If you would like to use Delphi/Pascal please refer to 'm_shutdown.inc'.
+
+ Feel free to redirect any questions or extension ideas to me via e-mail:
+ hrathh at users.sourceforge.net
+
+Debug Symbols
+-----------------
+ Debug symbols are also available for debugging purposes.
+ Copy the PDB-files in the SDK-zip into the same directory as the
+ corresponding DLL-files.
+
+ To debug crashes the supplied MAP-file file might be helpful.
+
+Coding Language
+-----------------
+ 'AutoShutdown' was written using Microsoft Visual C++ 6.0 SP6
+ and the Microsoft Platform SDK shipped along with it.
+
+Rebase Info
+-----------------
+ 'AutoShutdown' has set its base address to:
+ 0x11070000
+
+ Please avoid using this base address for your plugins because it will
+ slightly slow down startup of Miranda IM.
+
+ With Microsoft Visual C++ the Base Address can be configured at:
+ 'Project' -> 'Settings' -> 'Linker' -> 'Output' -> 'Base Address'
+
+H. Herkenrath (hrathh at users.sourceforge.net)
diff --git a/plugins/AutoShutdown/docs/Shutdown-License.txt b/plugins/AutoShutdown/docs/Shutdown-License.txt
new file mode 100644
index 0000000000..a726a52df1
--- /dev/null
+++ b/plugins/AutoShutdown/docs/Shutdown-License.txt
@@ -0,0 +1,278 @@
+ GNU GENERAL PUBLIC LICENSE
+ Version 2, June 1991
+
+ Copyright (C) 1989, 1991 Free Software Foundation, Inc.
+ 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ Everyone is permitted to copy and distribute verbatim copies
+ of this license document, but changing it is not allowed.
+
+ Preamble
+
+ The licenses for most software are designed to take away your
+freedom to share and change it. By contrast, the GNU General Public
+License is intended to guarantee your freedom to share and change free
+software--to make sure the software is free for all its users. This
+General Public License applies to most of the Free Software
+Foundation's software and to any other program whose authors commit to
+using it. (Some other Free Software Foundation software is covered by
+the GNU Library General Public License instead.) You can apply it to
+your programs, too.
+
+ When we speak of free software, we are referring to freedom, not
+price. Our General Public Licenses are designed to make sure that you
+have the freedom to distribute copies of free software (and charge for
+this service if you wish), that you receive source code or can get it
+if you want it, that you can change the software or use pieces of it
+in new free programs; and that you know you can do these things.
+
+ To protect your rights, we need to make restrictions that forbid
+anyone to deny you these rights or to ask you to surrender the rights.
+These restrictions translate to certain responsibilities for you if you
+distribute copies of the software, or if you modify it.
+
+ For example, if you distribute copies of such a program, whether
+gratis or for a fee, you must give the recipients all the rights that
+you have. You must make sure that they, too, receive or can get the
+source code. And you must show them these terms so they know their
+rights.
+
+ We protect your rights with two steps: (1) copyright the software, and
+(2) offer you this license which gives you legal permission to copy,
+distribute and/or modify the software.
+
+ Also, for each author's protection and ours, we want to make certain
+that everyone understands that there is no warranty for this free
+software. If the software is modified by someone else and passed on, we
+want its recipients to know that what they have is not the original, so
+that any problems introduced by others will not reflect on the original
+authors' reputations.
+
+ Finally, any free program is threatened constantly by software
+patents. We wish to avoid the danger that redistributors of a free
+program will individually obtain patent licenses, in effect making the
+program proprietary. To prevent this, we have made it clear that any
+patent must be licensed for everyone's free use or not licensed at all.
+
+ The precise terms and conditions for copying, distribution and
+modification follow.
+
+ GNU GENERAL PUBLIC LICENSE
+ TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
+
+ 0. This License applies to any program or other work which contains
+a notice placed by the copyright holder saying it may be distributed
+under the terms of this General Public License. The "Program", below,
+refers to any such program or work, and a "work based on the Program"
+means either the Program or any derivative work under copyright law:
+that is to say, a work containing the Program or a portion of it,
+either verbatim or with modifications and/or translated into another
+language. (Hereinafter, translation is included without limitation in
+the term "modification".) Each licensee is addressed as "you".
+
+Activities other than copying, distribution and modification are not
+covered by this License; they are outside its scope. The act of
+running the Program is not restricted, and the output from the Program
+is covered only if its contents constitute a work based on the
+Program (independent of having been made by running the Program).
+Whether that is true depends on what the Program does.
+
+ 1. You may copy and distribute verbatim copies of the Program's
+source code as you receive it, in any medium, provided that you
+conspicuously and appropriately publish on each copy an appropriate
+copyright notice and disclaimer of warranty; keep intact all the
+notices that refer to this License and to the absence of any warranty;
+and give any other recipients of the Program a copy of this License
+along with the Program.
+
+You may charge a fee for the physical act of transferring a copy, and
+you may at your option offer warranty protection in exchange for a fee.
+
+ 2. You may modify your copy or copies of the Program or any portion
+of it, thus forming a work based on the Program, and copy and
+distribute such modifications or work under the terms of Section 1
+above, provided that you also meet all of these conditions:
+
+ a) You must cause the modified files to carry prominent notices
+ stating that you changed the files and the date of any change.
+
+ b) You must cause any work that you distribute or publish, that in
+ whole or in part contains or is derived from the Program or any
+ part thereof, to be licensed as a whole at no charge to all third
+ parties under the terms of this License.
+
+ c) If the modified program normally reads commands interactively
+ when run, you must cause it, when started running for such
+ interactive use in the most ordinary way, to print or display an
+ announcement including an appropriate copyright notice and a
+ notice that there is no warranty (or else, saying that you provide
+ a warranty) and that users may redistribute the program under
+ these conditions, and telling the user how to view a copy of this
+ License. (Exception: if the Program itself is interactive but
+ does not normally print such an announcement, your work based on
+ the Program is not required to print an announcement.)
+
+These requirements apply to the modified work as a whole. If
+identifiable sections of that work are not derived from the Program,
+and can be reasonably considered independent and separate works in
+themselves, then this License, and its terms, do not apply to those
+sections when you distribute them as separate works. But when you
+distribute the same sections as part of a whole which is a work based
+on the Program, the distribution of the whole must be on the terms of
+this License, whose permissions for other licensees extend to the
+entire whole, and thus to each and every part regardless of who wrote it.
+
+Thus, it is not the intent of this section to claim rights or contest
+your rights to work written entirely by you; rather, the intent is to
+exercise the right to control the distribution of derivative or
+collective works based on the Program.
+
+In addition, mere aggregation of another work not based on the Program
+with the Program (or with a work based on the Program) on a volume of
+a storage or distribution medium does not bring the other work under
+the scope of this License.
+
+ 3. You may copy and distribute the Program (or a work based on it,
+under Section 2) in object code or executable form under the terms of
+Sections 1 and 2 above provided that you also do one of the following:
+
+ a) Accompany it with the complete corresponding machine-readable
+ source code, which must be distributed under the terms of Sections
+ 1 and 2 above on a medium customarily used for software interchange; or,
+
+ b) Accompany it with a written offer, valid for at least three
+ years, to give any third party, for a charge no more than your
+ cost of physically performing source distribution, a complete
+ machine-readable copy of the corresponding source code, to be
+ distributed under the terms of Sections 1 and 2 above on a medium
+ customarily used for software interchange; or,
+
+ c) Accompany it with the information you received as to the offer
+ to distribute corresponding source code. (This alternative is
+ allowed only for noncommercial distribution and only if you
+ received the program in object code or executable form with such
+ an offer, in accord with Subsection b above.)
+
+The source code for a work means the preferred form of the work for
+making modifications to it. For an executable work, complete source
+code means all the source code for all modules it contains, plus any
+associated interface definition files, plus the scripts used to
+control compilation and installation of the executable. However, as a
+special exception, the source code distributed need not include
+anything that is normally distributed (in either source or binary
+form) with the major components (compiler, kernel, and so on) of the
+operating system on which the executable runs, unless that component
+itself accompanies the executable.
+
+If distribution of executable or object code is made by offering
+access to copy from a designated place, then offering equivalent
+access to copy the source code from the same place counts as
+distribution of the source code, even though third parties are not
+compelled to copy the source along with the object code.
+
+ 4. You may not copy, modify, sublicense, or distribute the Program
+except as expressly provided under this License. Any attempt
+otherwise to copy, modify, sublicense or distribute the Program is
+void, and will automatically terminate your rights under this License.
+However, parties who have received copies, or rights, from you under
+this License will not have their licenses terminated so long as such
+parties remain in full compliance.
+
+ 5. You are not required to accept this License, since you have not
+signed it. However, nothing else grants you permission to modify or
+distribute the Program or its derivative works. These actions are
+prohibited by law if you do not accept this License. Therefore, by
+modifying or distributing the Program (or any work based on the
+Program), you indicate your acceptance of this License to do so, and
+all its terms and conditions for copying, distributing or modifying
+the Program or works based on it.
+
+ 6. Each time you redistribute the Program (or any work based on the
+Program), the recipient automatically receives a license from the
+original licensor to copy, distribute or modify the Program subject to
+these terms and conditions. You may not impose any further
+restrictions on the recipients' exercise of the rights granted herein.
+You are not responsible for enforcing compliance by third parties to
+this License.
+
+ 7. If, as a consequence of a court judgment or allegation of patent
+infringement or for any other reason (not limited to patent issues),
+conditions are imposed on you (whether by court order, agreement or
+otherwise) that contradict the conditions of this License, they do not
+excuse you from the conditions of this License. If you cannot
+distribute so as to satisfy simultaneously your obligations under this
+License and any other pertinent obligations, then as a consequence you
+may not distribute the Program at all. For example, if a patent
+license would not permit royalty-free redistribution of the Program by
+all those who receive copies directly or indirectly through you, then
+the only way you could satisfy both it and this License would be to
+refrain entirely from distribution of the Program.
+
+If any portion of this section is held invalid or unenforceable under
+any particular circumstance, the balance of the section is intended to
+apply and the section as a whole is intended to apply in other
+circumstances.
+
+It is not the purpose of this section to induce you to infringe any
+patents or other property right claims or to contest validity of any
+such claims; this section has the sole purpose of protecting the
+integrity of the free software distribution system, which is
+implemented by public license practices. Many people have made
+generous contributions to the wide range of software distributed
+through that system in reliance on consistent application of that
+system; it is up to the author/donor to decide if he or she is willing
+to distribute software through any other system and a licensee cannot
+impose that choice.
+
+This section is intended to make thoroughly clear what is believed to
+be a consequence of the rest of this License.
+
+ 8. If the distribution and/or use of the Program is restricted in
+certain countries either by patents or by copyrighted interfaces, the
+original copyright holder who places the Program under this License
+may add an explicit geographical distribution limitation excluding
+those countries, so that distribution is permitted only in or among
+countries not thus excluded. In such case, this License incorporates
+the limitation as if written in the body of this License.
+
+ 9. The Free Software Foundation may publish revised and/or new versions
+of the General Public License from time to time. Such new versions will
+be similar in spirit to the present version, but may differ in detail to
+address new problems or concerns.
+
+Each version is given a distinguishing version number. If the Program
+specifies a version number of this License which applies to it and "any
+later version", you have the option of following the terms and conditions
+either of that version or of any later version published by the Free
+Software Foundation. If the Program does not specify a version number of
+this License, you may choose any version ever published by the Free Software
+Foundation.
+
+ 10. If you wish to incorporate parts of the Program into other free
+programs whose distribution conditions are different, write to the author
+to ask for permission. For software which is copyrighted by the Free
+Software Foundation, write to the Free Software Foundation; we sometimes
+make exceptions for this. Our decision will be guided by the two goals
+of preserving the free status of all derivatives of our free software and
+of promoting the sharing and reuse of software generally.
+
+ NO WARRANTY
+
+ 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
+FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
+OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
+PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
+OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
+TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
+PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
+REPAIR OR CORRECTION.
+
+ 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
+WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
+REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
+INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
+OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
+TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
+YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
+PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
+POSSIBILITY OF SUCH DAMAGES.
diff --git a/plugins/AutoShutdown/docs/Shutdown-Readme.txt b/plugins/AutoShutdown/docs/Shutdown-Readme.txt
new file mode 100644
index 0000000000..59524f620f
--- /dev/null
+++ b/plugins/AutoShutdown/docs/Shutdown-Readme.txt
@@ -0,0 +1,329 @@
+
+AutoShutdown 1.4.0.2
+------------------------------------------------------------------------
+ Plugin for Miranda IM 0.7 and +
+
+ Plugin Info: ----------------------------
+ | Version: 1.4.0.2
+ | Filename: shutdown.dll
+ | Author: H. Herkenrath (hrathh at users.sourceforge.net)
+ | Description: Adds the possibility to shutdown Miranda IM
+ | or the computer after at a specified time.
+
+ Contents: -------------------------------
+ | Features, Requirements, Usage, Installation,
+ | Bugs and Wishes, To-Do List, Version History,
+ | Thanks, Translation, License and Copyright
+
+Features
+----------------------
+ + Shutdown Miranda IM or your computer after a specified time,
+ when receiving a special message or when all file transfers are completed
+ + Offers the following shutdown possibilities:
+ Logoff, Restart, Shutdown, Standby mode, Hibernate mode, Lock workstation,
+ Hang up dialup connections, Close Miranda IM, Set Miranda offine
+ + The available shutdown possibilities are only shown if they
+ are supported on your system
+ + The available shutdown events are only shown if you have
+ protocols or plugins installed that support the features
+ + Displays a confirmation dialog which is shown for 30 seconds
+ to cancel the process
+ + Plays a sound on confirmation dialog
+ + Displays the countdown in a special window below contact list
+ (this feature needs a MultiWindow enabled Contact List plugin)
+ + Plays a sound when the confirmation dialog is displayed
+ + No data gets lost on shutdown especially no unread messages
+ + Allows you to pause the shutdown countdown
+ + If Miranda is closed while automatic shutdown is running it will
+ show a dialog on next start of Miranda IM where it can be selected
+ to start automatic shutdown again
+ + Provides shutdown services for other plugins
+ + Full Unicode support
+ + Automatic installation of all files, just unzip into Plugins directory
+ + Supported plugins/tools:
+ MultiWindow Contact Lists (frames and hotkeys), Hotkey Plugins,
+ Magnetic Windows, Snapping Windows, TopToolBar, AutoReplacer,
+ Trigger Plugin (http://www.pboon.nl/projects.htm), HDD Info,
+ Weather Protocol
+
+Requirements
+----------------------
+ -> Miranda IM 0.7+:
+ Miranda IM is needed in version 0.7 or later.
+
+ -> Optional: Weather Protocol 0.3.3.17+:
+ If you would like to use the thunderstorm shutdown feature,
+ you need to have Weather Protocol installed, version 0.3.3.17 or later.
+
+ -> Optional: HDD Info 0.1.2.0+:
+ If you would like to use the harddrive overheat shutdown feature,
+ you need to have the HDD Info plugin installed, version 0.1.2.0 or later.
+
+ -> Optional: Trigger Plugin 0.2.0.69+:
+ If you would like to use the Trigger feature,
+ you need to have the Trigger plugin installed, version 0.2.0.69 or later.
+
+Usage
+----------------------
+ AutoShutdown can be activated via the main menu:
+ 'Main Menu' -> 'Automatic Shutdown'
+
+ The options to use 'Hibernate mode' and 'Lock workstation'
+ are only available if your system supports it.
+ All other options are only available if they are enabled on your system.
+
+ Enabling 'Hibernate mode' on Windows ME/2000 and later:
+ 'Control Panel' -> 'Power Options' -> 'Hibernate'
+ To enable the Hibernate feature go to the Control Panel,
+ double-click Power Options, and then click the Hibernate tab.
+ Click to select the Enable Hibernate Support check box.
+
+Installation
+----------------------
+ Find 'miranda32.exe' on your computer.
+
+ Just copy all the contents of the zip-file as they are into the 'Plugins'
+ subdirectory in the Miranda IM folder.
+ 'AutoShutdown' will detect the files and move them into the appropriate
+ directories on it's first run.
+
+ You can also do all the installation by hand, if you want to:
+
+ Main Plugin: Copy the file 'shutdown.dll' into the 'Plugins' subdirectory
+ in the Miranda IM folder.
+
+ The Unicode version of the plugin will only work on Windows NT/2000/XP,
+ Windows Server 2000, Windows Vista or later with an installed
+ Unicode version of Miranda IM.
+ To use it on Windows 95/98/Me, please download the ANSI version of the plugin.
+
+ Documentation: The txt-files should be moved along with the SDK-zip into the
+ 'Docs' directory in the Miranda IM folder.
+
+ Sounds: The wav-files should be moved into the 'Sounds'
+ directory. They will get recognized automatically and be added to the sounds list.
+
+ That's it!
+
+Bugs and Wishes
+----------------------
+ Feel free to mail me your wishes about 'AutoShutdown' and tell
+ me all the bugs you may find: hrathh at users.sourceforge.net
+
+To-Do List (random ideas)
+----------------------
+ ? Design some icons for the shutdown types (shutdown, reboot, etc.)...anyone?
+ ? Ddd possibility to shutdown on status change of specific users
+ ? Support Alarms Plugin API (m_alarms.h):
+ This would replace countdown frame, showing the shutdown countdown
+ on the Alarms frame instead (don't know if this is a good idea, not yet possible)
+ ? Show system tray icon when automatic shutdown is enabled (not needed, bad looking)
+ ? Add possibility to set Miranda to a specific status instead of offline
+ (really shutdown related?)
+ ? Start a specified application on event (really shutdown related?)
+
+Version History
+----------------------
+ 1.4.0.2 - minor fixes
+ 1.4.0.1 - ensure correct threshold values for cpuusage
+ - uses langpack locale for combobox sorting
+ - fixed: fontservice items were registered too early
+ - fixed: unicode problem with tray menu item
+ - fixed: settings dialog did not show up with parent
+ - added v0.8 support
+ - minor other improvements
+ 1.4.0.0 - Added possibility to shutdown when computer finishes
+ a busy task (high cpu usage)
+ - Support for AutoReplacer in message editbox
+ - Fixed minor issue with reactivating on miranda startup
+ - Really fixed shutdown on message in unicode build
+ - Updated new miranda headers, use of mir_forkthread
+ - Fixed automatic installation routine, now works again
+ - Bug-Fix: countdown hours (and higher) were converted wrongly
+ - Fixes for Win9x and WinNT4
+ - Adjustments for hung apps
+ - Tweak: support for ENDSESSION_CLOSEAPP in Windows Vista
+ - Code reorganization
+ - Minor Vista and robustness tweaks
+ - Improved FontService and IcoLib support (core built-in)
+ 1.3.1.1 - Tweaks for blind users
+ - Minor speed-up for frame drawing when resized
+ - Cleanups
+ - workaround for frames not drawing when previously hidden
+ 1.3.1.0 - Added FontService support
+ - Added HDD Info overheat shutdown
+ - Updated Trigger plugin support (0.2)
+ - Updated TopToolBar support to latest version (0.7.3)
+ - Fixed 'lock workstation' on WinNT4
+ - Marquee on progress
+ - Minor fixes and improvements
+ - Minor updates for new Miranda
+ 1.3.0.8 - Bug-Fix: Check for unicode core was wrong
+ - Some other minor changes
+ 1.3.0.7 - Improvements to OKTOEXIT handling
+ - Bug-Fix: Daylight saving time was ignored in time conversion
+ 1.3.0.6 - Reduced ANSI file size (corrected compiler settings)
+ - Minor internal tweaks
+ - Bug-Fix: Confirmation countdown in options was not displayed correctly
+ - Included debug symbols (PDB) into SDK package
+ - Adjusted db settings
+ 1.3.0.5 - Minor internal tweaks
+ - Fixed crash on start when Trigger plugin installed
+ 1.3.0.4 - Minor improvements and some internal changes to the countdown frame
+ - Finally fully fixed the dialup shutdown problem
+ - Added: Now also adds Close Miranda and Set Miranda offline as
+ actions for the trigger plugin (was requested)
+ 1.3.0.3 - Bug-Fix: Another try to fix the 'hangup dialup connections' freeze
+ 1.3.0.2 - Bug-Fix: 'hang up dialup connection' freezed Miranda sometimes
+ 1.3.0.1 - Fix: On some rare situations Miranda was not shutdown correctly
+ - Fix: Frame was not shown correctly on clist_modern
+ - Fixed mw_clist hotkey
+ - Some minor improvements
+ - Added shutdown event
+ - Fixed minor workstation locked issue
+ - Fixed 'sec' not shown correctly on frame (bug in WinAPI)
+ - Made 'hang up dialup connections' code more robust
+ - Bug-Fix: countdown values were not saved
+ - Fixed: shutdown dates in past were sometimes not recognized correctly
+ 1.3.0.0 - Make use of FORCEIFHUNG flag instead of FORCE whenever it is possible
+ - Shutdown at [hh:mm] and [yy-mm-dd] instead of Shutdown only at [hh:mm]
+ (also making use of calendar common control)
+ - New shutdown type: set status to offline
+ - Make use of ME_IDLE_CHANGED to shutdown on idle
+ - Added 'Thunder Shutdown' functionality
+ - Now making use of marquee mode of progressbar of time countdown is to
+ long to be displayed
+ - Added: Hotkey support for toggling automatic shutdown on/off
+ - Added: IcoLib support
+ - Updated: DBEditor++ support
+ - Added: Support for Trigger plugin (shutdown actions)
+ - Added: Unicode support
+ - Added: Functionality of Thunder Shutdown plugin (see option page)
+ - Removed: AgressiveOptimize.h to make it work on all systems
+ - Improved: New service functions
+ - Added: Shows countdown frame in normal window when frames are not available
+ - Added: Hotkey support for hotkey services (toggle)
+ - Improved: Now makes use of StrFromTimeInterval, BroadcastSystemMessage
+ - Improved: Made file transfer shutdown logic more robust
+ - Imroved dialogs look and feel
+ - Cleaned up and revisited code
+ 1.2.0.4 - Changed time control to use windows default control
+ - Fix: The icon on the countdown frame was sqeezed a bit
+ - Improved shutdown dialog layout
+ - Some small string improvements/changes (see Shutdown-Translation.txt')
+ - Some other minor code changes and improvements
+ 1.2.0.3 - 'Shutdown on file transfer' and 'Shutdown on message receival'
+ are now only enabled if plugins and protocols are installed that
+ support file transfer and/or instant messaging features
+ - Some other minor changes
+ 1.2.0.2 - Fix: Shutdown on message receival only worked when
+ message dialog was closed (Thanks to Hurricane and Foo)
+ - Fix: Sound option dialog sometimes crashed
+ when selecting a different countdown sound file (Thanks to Rex)
+ - Minor string improvements (see 'Shutdown-Translation.txt')
+ - Some small internal improvements
+ 1.2.0.1 - Fix: TopToolBar button showed wrong behaviour if
+ dialog was already opened
+ 1.2.0.0 - Add: New shutdown type 'Hang up dialup connections'
+ - Fix: Combo box did not remember last option correctly
+ - Some other small fixes/changes/improvents
+ 1.1.3.1 - Fix: Tabulator did not work correctly on settings dialog
+ - Fix: Some problems with the 'last exit remembering'
+ - Fix: 'Cancel' button was not default button on shutdown dialog
+ - Some other minor fixes/improvements
+ 1.1.3.0 - Improved: Sending of WM_ENDSESSION
+ - Add: If Miranda is closed and automatic shutdown is running
+ it will remember it and shows on next Miranda start a message box
+ where the user can select to start automatic shutdown again
+ - Add: When no option is selected it does no longer allow the
+ user to click on OK
+ - Fix: Time input control sometimes got hidden when editing hours
+ - Some other minor improvements/fixes
+ 1.1.2.0 - Fix: The shutdown on file transfer completion feature
+ did not always work correctly, especially with ICQ file transfers
+ - Fix: If the default sound file isn't installed it doesn't
+ anylonger give out the windows default sound by default
+ - Add: If Miranda is closed and automatic shutdown is running
+ it will remember it and start on next Miranda start again
+ 1.1.1.1 - Fix: Shutdown on specific time sometimes did not work correctly
+ and crashed Miranda on opening the 30s confirmation window
+ 1.1.1.0 - Fix: Default time was sometimes not detected correctly
+ - Improved: Shutdown/Restart is now faster due to improved
+ sending of WM_ENDSESSION
+ - Improved: When the countdown is paused it shows a blinking text
+ - Change: Context menu can now also be opened via left click
+ - Change: Shutdown on message receival now checks for
+ if the message contains the specified text instead of checking for
+ exactly the same content
+ - Change: 'Cancel Countdown' in context menu now only stops the countdown
+ instead of stopping all shutdown causes
+ - Change: When using shutdown at time feature the countdown display will
+ show the time instead of the countdown (Suggested by Rootgar)
+ - Change: The context menu now show a different text instead of being
+ checked when the countdown is paused
+ - Added/Changed some strings (see 'Shutdown-Translation.txt')
+ - Some other minor changes/improvements
+ 1.1.0.0 - Add: Possibility to shut down when all file transfers are finished
+ - Add: Possibility to shut down on message receival
+ - Add: WM_ENDSESSION now gets send to all applications manually on
+ shutdown/restart to prevent data loss
+ - Add: Now containing default sound file boundled with zip
+ - Add: Possibility to pause/unpause the countdown via right click on it
+ - Fix: Shutdown/Restart was not shown on Windows 2000/XP
+ - Fix: Updated link on plugin options page
+ - Fix: Countdown got updated one second after reactivating clist
+ - Change: Sound now gets played repeatedly on 30s shutdown dialog
+ - Change: Now 'Cancel' is the default button on 30s shutdown dialog
+ - Improved/Added some strings (please see 'Shutdown-Translation.txt')
+ - Some other minor improvements
+ 1.0.0.0 - Initial release
+
+Thanks
+----------------------
+ * To Corsario (Angelo Luiz Tartari) for the first idea of a shutdown plugin
+ * To Dennys for the first idea of rebooting via message ('dReboot' plugin)
+ * To noname for the thunderstorm shutdown feature
+ * To Marek 'tusz' Tusiewicz for the sound file and testing
+ * To Rootgar and Tigerix for their bug reports and suggestions
+
+Translation
+----------------------
+ Translation strings can be found in 'Shutdown-Translation.txt'.
+
+License and Copyright
+----------------------
+ 'AutoShutdown' is released under the terms of the GNU General Public License.
+ See 'Shutdown-License.txt' for more details.
+
+ Copyright (c) 2004-2007 by H. Herkenrath. All rights reserved.
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions
+ are met:
+
+ 1. Redistributions of source code must retain the copyright
+ notice, this list of conditions and the following disclaimer.
+ 2. The origin of this software must not be misrepresented; you must
+ not claim that you wrote the original software. If you use this
+ software in a product, an acknowledgment in the product
+ documentation would be appreciated but is not required.
+ 3. Altered source versions must be plainly marked as such, and must
+ not be misrepresented as being the original software.
+ 4. The name of the author may not be used to endorse or promote
+ products derived from this software without specific prior written
+ permission.
+
+ THIS SOFTWARE IS PROVIDED BY THE AUTHOR 'AS IS' AND ANY EXPRESS
+ OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+
+H. Herkenrath (hrathh at users.sourceforge.net)
diff --git a/plugins/AutoShutdown/docs/Shutdown-Translation.txt b/plugins/AutoShutdown/docs/Shutdown-Translation.txt
new file mode 100644
index 0000000000..3ff9b29186
--- /dev/null
+++ b/plugins/AutoShutdown/docs/Shutdown-Translation.txt
@@ -0,0 +1,240 @@
+
+AutoShutdown 1.4.0.2 for Miranda IM 0.7+
+------------------------------------------------------------------------
+ Translator Information
+
+ Contents: -------------------------------
+ | General Info, String Listing
+
+General Info
+-----------------------------
+ 'AutoShutdown' can be translated with the Miranda IM
+ language files.
+
+ Place the following strings listed in the following section in a
+ file called 'langpack_<language>.txt' in the Miranda IM directory.
+ Then you can translate them into your language.
+
+ If you need more info about Miranda IM language files visit:
+ http://miranda.svn.sourceforge.net/viewvc/*checkout*/miranda/trunk/miranda/i18n/readme.txt
+
+String Listing
+-----------------------------
+
+; --- Plugin: AutoShutdown 1.4.0.2 (German) ---
+
+; Translation by hrathh
+; Please report any mistakes or missing strings in here.
+
+[AutoShutdown]
+Automatisches Beenden
+[Adds the possibility to shutdown the computer when a specified event occurs.]
+Dieses Plugin ermöglicht es den Computer bei Eintreten festgelegter Ereignisse zu Beenden.
+[AutoShutdown Plugin]
+AutoShutdown-Plugin
+[The AutoShutdown plugin can not be loaded. It requires Miranda IM %hs or later.]
+Das AutoShutdown-Plugin kann nicht geladen werden. Es benötigt Miranda IM %hs oder neuer.
+
+; Menu Item
+[Automatic &shutdown...]
+Automatisches &Beenden...
+[Stop automatic &shutdown]
+Automatisches &Beenden abbrechen
+; TopToolBar Button
+[Start/Stop automatic shutdown]
+Automatisches Beenden de-/aktivieren
+[Start automatic shutdown]
+Automatisches Beenden aktivieren
+[Stop automatic shutdown]
+Automatisches Beenden deaktivieren
+
+; Sound
+;[Alerts]
+[Automatic Shutdown Countdown]
+Countdown beim Automatischen Beenden
+; Hotkey
+[Toggle Automatic Shutdown]
+Automatisches Beenden ein-/ausschalten
+
+; Icons
+[Active]
+Aktiviert
+[Inactive]
+Deaktiviert
+[Header]
+Illustration
+; Fonts and Colors
+[Countdown on Frame]
+Countdown im Rahmen
+[Background]
+Hintergrund
+[Progress Bar]
+Fortschrittsbalken
+
+; Settings Dialog
+[Automatic Shutdown]
+Automatisches Beenden
+[Select the automatic shutdown event]
+Ein Ereignis zum automatischen Beenden wählen
+[Shutdown at &specific time]
+Beenden zur festgelegten &Zeit
+[Shutdown a&t:]
+Durchführen u&m:
+[Shutdown i&n:]
+Durchführen i&n:
+[Second(s)]
+Sekunden(n)
+[Minute(s)]
+Minute(n)
+[Hour(s)]
+Stunde(n)
+[Day(s)]
+Tage(n)
+[Week(s)]
+Woche(n)
+[Month(s)]
+Monat(en)
+[Shutdown when a &message is received containing the following text:]
+Beenden, wenn eine &Nachricht eingeht, die den folgenden Text enthält:
+[Shutdown when all &file transfers are finished]
+Beenden, wenn alle &Dateiübertragungen abgeschlossen sind
+[Shutdown when &prozessor usage drops below:]
+Beenden, wenn die &Prozessorauslastung unter folgenden Wert fällt:
+[(current: %u%%)]
+(aktuell: %u%%)
+;[%]
+[Shutdown when Miranda IM becomes &idle]
+Beenden, wenn Miranda IM im &Idle-Modus ist
+[Configure]
+Konfigurieren
+[Shutdown when all contacts are &offline]
+Beenden, wenn alle Kontakte &offline sind
+[&Action:]
+&Vorgang:
+[Close Miranda IM]
+Miranda IM schließen
+[Sets all Miranda IM protocols to offline and closes Miranda IM.]
+Setzt alle Netzwerkprotokolle auf "Offline" und beendet Miranda IM.
+[Set Miranda IM offline]
+Miranda IM offline schalten
+[Sets all Miranda IM protocols to offline.]
+Setzt alle Protokolle von Miranda IM auf Offline.
+[Log off user]
+Benutzer abmelden
+[Logs the current Windows user off so that another user can log in.]
+Meldet den aktuellen Benutzer von Windows ab, sodass sich ein anderer Benutzer anmelden kann.
+[Restart computer]
+Computer neu starten
+[Shuts down Windows and then restarts Windows.]
+Beendet die Windows-Sitzung und Windows und startet dann Windows erneut.
+[Shutdown computer]
+Computer herunterfahren
+[Closes all running programs and shuts down Windows to a point at which it is safe to turn off the power.]
+Beendet die Windows-Sitzung und fährt den Computer herunter. Der Computer wird ausgeschaltet.
+[Standby mode]
+Standby-Modus
+[Saves the current Windows session in memory and sets the system to suspend mode.]
+Behält die Windows-Sitzung bei, speichert die Daten im Arbeitsspeicher und schaltet den Computer in den Energiesparmodus.
+[Hibernate mode]
+Ruhezustand
+[Saves the current Windows session on harddisc, so that the power can be turned off.]
+Speichert die Windows-Sitzung auf der Festplatte, sodass der Computer ausgeschaltet werden kann.
+[Lock workstation]
+Arbeitsplatz verriegeln
+[Locks the computer. To unlock the computer, you must log in.]
+Verriegelt den Computer gegen Zugriff. Um den Computer wieder zu entriegeln müssen Sie sich erneut anmelden.
+[Hang up dialup connections]
+DFÜ-Verbindungen trennen
+[Sets all protocols to offline and closes all RAS connections.]
+Setzt alle Netzwerkprotokolle auf "Offline" und trennt alle aktiven DFÜ-Netzwerkverbindungen.
+
+; Options
+[Shutdown]
+Beenden
+[&Show confirmation dialog before shutdown]
+&Bestätigungsfenster vor dem Beenden anzeigen
+[&Countdown starts at:]
+&Countdown beginnt bei:
+[seconds]
+Sekunden
+[Shutdown Events]
+Ereignisse
+[&Activate automatic shutdown with the same settings again if Miranda IM was closed with automatic shutdown enabled]
+&Automatisches Beenden mit den gleichen Einstellungen erneut aktivieren, wenn Miranda IM beendet wurde während es aktiviert war
+[&Ignore hidden or temporary contacts when watching for all contacts being offline]
+&Versteckte und temporäre Kontakte beim Prüfen auf Offline Status ignorieren
+[Critical Shutdown Events]
+Kritische Ereignisse
+[&Thunderstorm warning is issued (Weather)]
+Gewitterwarnung wird ausgegeben (Wetter)
+[&Harddrive overheats (HDD Info)]
+&Festplatte überhitzt (HDD Info)
+
+; Trigger Plugin
+[Shutdown: Close Miranda IM]
+Herunterfahren: Miranda IM schließen
+[Shutdown: Set Miranda IM offline]
+Herunterfahren: Miranda IM offline schalten
+[Shutdown: Log off user]
+Herunterfahren: Abmelden
+[Shutdown: Restart computer]
+Herunterfahren: Neustart
+[Shutdown: Shutdown computer]
+Herunterfahren: Computer ausschalten
+[Shutdown: Standby mode]
+Herunterfahren: Standby-Modus
+[Shutdown: Hibernate mode]
+Herunterfahren: Ruhezustand
+[Shutdown: Lock workstation]
+Herunterfahren: Arbeitsplatz verriegeln
+[Shutdown: Hang up dialup connections]
+Herunterfahren: DFÜ-verbindungen trennen
+
+; Shutdown Dialog
+;[Automatic Shutdown]
+[Miranda IM is going to be automatically closed in %i second(s).]
+Miranda IM wird in %i Sekunde(n) automatisch geschlossen.
+[You will be logged off automatically in %i second(s).]
+Der Benutzer wird in %i Sekunde(n) automatisch abgemeldet.
+[The computer will automatically be restarted in %i second(s).]
+Der Computer wird in %i Sekunde(n) automatisch neu gestartet.
+[The computer will automatically be set to standby mode in %i second(s).]
+Der Computer wird in %i Sekunde(n) automatisch in den Stanby-Modus geschaltet.
+[The computer will automatically be set to hibernate mode in %i second(s).]
+Der Computer wird in %i Sekunde(n) automatisch in den Ruhezustand geschaltet.
+[The workstation will automatically get locked in %i second(s).]
+Der Arbeitsplatz wird in %i Sekunde(n) automatisch verriegelt.
+[The computer will automatically be shut down in %i second(s).]
+Der Computer wird in %i Sekunde(n) automatisch heruntergefahren.
+[All dialup connections will be closed in %i second(s).]
+Alle aktiven DFÜ-Netzwerkverbindungen werden in %i Sekunde(n) automatisch getrennt.
+[Unsaved data in open applications except Miranda IM might get lost.]
+Ungespeicherte Daten in geöffneten Anwendungen außer Miranda IM könnten verloren gehen.
+[Please click "Cancel" if you would like to abort the process.]
+Bitte auf "Abbrechen" klicken, wenn der Vorgang nicht durchgeführt werden soll.
+[&Now!]
+&Sofort!
+
+; Countdown Frame
+[Time left:]
+Verbleibend:
+[Shutdown at:]
+Beenden um:
+[Paused]
+Pause
+[&Cancel Countdown]
+Countdown &abbrechen
+[&Pause Countdown]
+Countdown &pausieren
+[&Unpause Countdown]
+Countdown &fortsetzen
+
+; Error
+[Automatic Shutdown Error]
+Fehler beim Automatischen Beenden
+[The shutdown process failed!\nReason: %s]
+Der Beendevorgang konnte nicht gestartet werden!\nGrund: %s
+
+; ---
+
+H. Herkenrath (hrathh at users.sourceforge.net)
diff --git a/plugins/AutoShutdown/docs/countdown.wav b/plugins/AutoShutdown/docs/countdown.wav
new file mode 100644
index 0000000000..45baa854bb
--- /dev/null
+++ b/plugins/AutoShutdown/docs/countdown.wav
Binary files differ
diff --git a/plugins/AutoShutdown/frame.c b/plugins/AutoShutdown/frame.c
new file mode 100644
index 0000000000..f9266b1906
--- /dev/null
+++ b/plugins/AutoShutdown/frame.c
@@ -0,0 +1,644 @@
+/*
+
+'AutoShutdown'-Plugin for Miranda IM
+
+Copyright 2004-2007 H. Herkenrath
+
+This program is free software; you can redistribute it and/or
+modify it under the terms of the GNU General Public License
+as published by the Free Software Foundation; either version 2
+of the License, or (at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program (Shutdown-License.txt); if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+*/
+
+#include "common.h"
+
+/* Show Frame */
+extern HINSTANCE hInst;
+static HWND hwndCountdownFrame;
+static WORD hFrame;
+/* Misc */
+static HANDLE hHookModulesLoaded;
+
+/************************* Helpers ************************************/
+
+#define FRAMEELEMENT_BAR 1
+#define FRAMEELEMENT_BKGRND 2
+#define FRAMEELEMENT_TEXT 3
+static COLORREF GetDefaultColor(BYTE id)
+{
+ switch(id) {
+ case FRAMEELEMENT_BAR:
+ return RGB(250,0,0); /* same color as used on header icon */
+ case FRAMEELEMENT_BKGRND:
+ return (COLORREF)DBGetContactSettingDword(NULL,"CLC","BkColour",CLCDEFAULT_BKCOLOUR);
+ case FRAMEELEMENT_TEXT:
+ return GetSysColor(COLOR_WINDOWTEXT);
+ }
+ return 0; /* never happens */
+}
+
+static LOGFONT* GetDefaultFont(LOGFONT *lf)
+{
+ NONCLIENTMETRICS ncm;
+ ZeroMemory(&ncm,sizeof(ncm));
+ ncm.cbSize=sizeof(ncm);
+ if(SystemParametersInfo(SPI_GETNONCLIENTMETRICS,ncm.cbSize,&ncm,0)) {
+ *lf=ncm.lfStatusFont;
+ return lf;
+ }
+ return (LOGFONT*)NULL;
+}
+
+static HICON SetFrameTitleIcon(WORD hFrame,HICON hNewIcon)
+{
+ HICON hPrevIcon;
+ hPrevIcon=(HICON)CallService(MS_CLIST_FRAMES_GETFRAMEOPTIONS,MAKEWPARAM(FO_ICON,hFrame),0);
+ CallService(MS_CLIST_FRAMES_SETFRAMEOPTIONS,MAKEWPARAM(FO_ICON,hFrame),(LPARAM)hNewIcon);
+ if((int)hPrevIcon==-1) return (HICON)NULL;
+ return hPrevIcon;
+}
+
+static LRESULT CALLBACK ProgressBarSubclassProc(HWND hwndProgress,UINT msg,WPARAM wParam,LPARAM lParam)
+{
+ switch(msg) {
+ case WM_ERASEBKGND:
+ return TRUE;
+ case WM_LBUTTONDOWN:
+ case WM_LBUTTONDBLCLK:
+ return SendMessage(GetParent(hwndProgress),msg,wParam,lParam);
+ }
+ return CallWindowProc((WNDPROC)GetWindowLong(hwndProgress,GWL_USERDATA),hwndProgress,msg,wParam,lParam);
+}
+
+/************************* Window Class *******************************/
+
+#define COUNTDOWNFRAME_CLASS _T("AutoShutdownCountdown")
+
+/* Data */
+struct CountdownFrameWndData { /* sizeof=57, max cbClsExtra=40 on Win32 */
+ time_t countdown,settingLastTime;
+ HANDLE hHookColorsChanged,hHookFontsChanged,hHookIconsChanged;
+ HANDLE hwndIcon,hwndProgress,hwndDesc,hwndTime,hwndToolTip;
+ HBRUSH hbrBackground;
+ COLORREF clrBackground,clrText;
+ HFONT hFont;
+ WORD fTimeFlags;
+ BYTE flags;
+};
+
+/* Flags */
+#define FWPDF_PAUSED 0x01
+#define FWPDF_PAUSEDSHOWN 0x02
+#define FWPDF_COUNTDOWNINVALID 0x04
+#define FWPDF_TIMEISCLIPPED 0x08
+
+/* Menu Items */
+#define MENUITEM_STOPCOUNTDOWN 1
+#define MENUITEM_PAUSECOUNTDOWN 2
+
+/* Messages */
+#define M_REFRESH_COLORS (WM_USER+0)
+#define M_REFRESH_ICONS (WM_USER+1)
+#define M_REFRESH_FONTS (WM_USER+2)
+#define M_SET_COUNTDOWN (WM_USER+3)
+#define M_UPDATE_COUNTDOWN (WM_USER+4)
+#define M_CHECK_CLIPPED (WM_USER+5)
+#define M_CLOSE_COUNTDOWN (WM_USER+6)
+#define M_PAUSE_COUNTDOWN (WM_USER+7)
+
+static LRESULT CALLBACK FrameWndProc(HWND hwndFrame,UINT msg,WPARAM wParam,LPARAM lParam)
+{
+ struct CountdownFrameWndData *dat=(struct CountdownFrameWndData*)GetWindowLong(hwndFrame,GWL_USERDATA);
+
+ switch(msg) {
+ case WM_NCCREATE: /* init window data */
+ dat=(struct CountdownFrameWndData*)mir_calloc(sizeof(*dat));
+ SetWindowLong(hwndFrame,GWL_USERDATA,(LONG)dat);
+ if(dat==NULL) return FALSE; /* creation failed */
+ dat->fTimeFlags=*(WORD*)((CREATESTRUCT*)lParam)->lpCreateParams;
+ dat->flags=FWPDF_COUNTDOWNINVALID;
+ break;
+ case WM_CREATE: /* create childs */
+ { CREATESTRUCT *params=(CREATESTRUCT*)lParam;
+ dat->hwndIcon=CreateWindowEx(WS_EX_NOPARENTNOTIFY,
+ _T("Static"),
+ NULL,
+ WS_CHILD|WS_VISIBLE|SS_ICON|SS_CENTERIMAGE|SS_NOTIFY,
+ 3, 0,
+ GetSystemMetrics(SM_CXICON),
+ GetSystemMetrics(SM_CYICON),
+ hwndFrame,
+ NULL,
+ params->hInstance,
+ NULL);
+ dat->hwndProgress=CreateWindowEx(WS_EX_NOPARENTNOTIFY,
+ PROGRESS_CLASS,
+ (dat->fTimeFlags&SDWTF_ST_TIME)?TranslateT("Shutdown at:"):TranslateT("Time left:"),
+ WS_CHILD|WS_VISIBLE|PBS_SMOOTH,
+ GetSystemMetrics(SM_CXICON)+5,
+ 5, 90,
+ (GetSystemMetrics(SM_CXICON)/2)-5,
+ hwndFrame,
+ NULL,
+ params->hInstance,
+ NULL);
+ if(dat->hwndProgress==NULL) return -1; /* creation failed, calls WM_DESTROY */
+ SendMessage(dat->hwndProgress,PBM_SETSTEP,(WPARAM)1,0);
+ SetWindowLong(dat->hwndProgress,GWL_USERDATA,SetWindowLong(dat->hwndProgress,GWL_WNDPROC,(LONG)ProgressBarSubclassProc));
+ dat->hwndDesc=CreateWindowEx(WS_EX_NOPARENTNOTIFY,
+ _T("Static"),
+ (dat->fTimeFlags&SDWTF_ST_TIME)?TranslateT("Shutdown at:"):TranslateT("Time left:"),
+ WS_CHILD|WS_VISIBLE|SS_LEFTNOWORDWRAP|SS_NOTIFY,
+ GetSystemMetrics(SM_CXICON)+5,
+ (GetSystemMetrics(SM_CXICON)/2),
+ 75,
+ (GetSystemMetrics(SM_CXICON)/2),
+ hwndFrame,
+ NULL,
+ params->hInstance,
+ NULL);
+ dat->hwndTime=CreateWindowEx(WS_EX_NOPARENTNOTIFY,
+ _T("Static"),
+ NULL, /* hh:mm:ss */
+ WS_CHILD|WS_VISIBLE|SS_RIGHT|SS_NOTIFY|SS_ENDELLIPSIS,
+ (GetSystemMetrics(SM_CXICON)+80),
+ (GetSystemMetrics(SM_CXICON)/2),
+ 35,
+ (GetSystemMetrics(SM_CXICON)/2),
+ hwndFrame,
+ NULL,
+ params->hInstance,
+ NULL);
+ if(dat->hwndTime==NULL) return -1; /* creation failed, calls WM_DESTROY */
+ /* create tooltips */
+ if(IsWinVer98Plus() || IsWinVer2000Plus()) {
+ TTTOOLINFO ti;
+ dat->hwndToolTip=CreateWindowEx(WS_EX_TOPMOST,
+ TOOLTIPS_CLASS,
+ NULL,
+ WS_POPUP|TTS_ALWAYSTIP|TTS_NOPREFIX,
+ CW_USEDEFAULT, CW_USEDEFAULT,
+ CW_USEDEFAULT, CW_USEDEFAULT,
+ hwndFrame,
+ NULL,
+ params->hInstance,
+ NULL);
+ if(dat->hwndToolTip!=NULL) {
+ SetWindowPos(dat->hwndToolTip,HWND_TOPMOST,0,0,0,0,SWP_NOMOVE|SWP_NOSIZE|SWP_NOACTIVATE);
+ ZeroMemory(&ti,sizeof(ti));
+ ti.cbSize=sizeof(ti);
+ ti.hwnd=hwndFrame;
+ ti.uFlags=TTF_IDISHWND|TTF_SUBCLASS|TTF_TRANSPARENT;
+ ti.lpszText=LPSTR_TEXTCALLBACK; /* commctl 4.70+ */
+ ti.uId=(UINT)dat->hwndTime; /* in-place tooltip */
+ SendMessage(dat->hwndToolTip,TTM_ADDTOOL,0,(LPARAM)&ti);
+ ti.uFlags&=~TTF_TRANSPARENT;
+ ti.uId=(UINT)dat->hwndProgress;
+ SendMessage(dat->hwndToolTip,TTM_ADDTOOL,0,(LPARAM)&ti);
+ if(dat->hwndDesc!=NULL) {
+ ti.uId=(UINT)dat->hwndDesc;
+ SendMessage(dat->hwndToolTip,TTM_ADDTOOL,0,(LPARAM)&ti);
+ }
+ if(dat->hwndIcon!=NULL) {
+ ti.uId=(UINT)dat->hwndIcon;
+ SendMessage(dat->hwndToolTip,TTM_ADDTOOL,0,(LPARAM)&ti);
+ }
+ }
+ }
+ /* init layout */
+ dat->hHookColorsChanged=HookEventMessage(ME_COLOUR_RELOAD,hwndFrame,M_REFRESH_COLORS);
+ dat->hHookFontsChanged=HookEventMessage(ME_FONT_RELOAD,hwndFrame,M_REFRESH_FONTS);
+ dat->hHookIconsChanged=HookEventMessage(ME_SKIN2_ICONSCHANGED,hwndFrame,M_REFRESH_ICONS);
+ SendMessage(hwndFrame,M_REFRESH_COLORS,0,0);
+ SendMessage(hwndFrame,M_REFRESH_FONTS,0,0);
+ SendMessage(hwndFrame,M_REFRESH_ICONS,0,0);
+ SendMessage(hwndFrame,M_SET_COUNTDOWN,0,0);
+ SendMessage(hwndFrame,M_UPDATE_COUNTDOWN,0,0);
+ if(!SetTimer(hwndFrame,1,1000,NULL)) return -1; /* creation failed, calls WM_DESTROY */
+ return 0;
+ }
+ case WM_DESTROY:
+ { HICON hIcon;
+ if(dat==NULL) return 0;
+ UnhookEvent(dat->hHookColorsChanged);
+ UnhookEvent(dat->hHookFontsChanged);
+ UnhookEvent(dat->hHookIconsChanged);
+ /* other childs are destroyed automatically */
+ if(dat->hwndToolTip!=NULL) DestroyWindow(dat->hwndToolTip);
+ hIcon=(HICON)SendMessage(dat->hwndIcon,STM_SETIMAGE,IMAGE_ICON,(LPARAM)NULL);
+ IcoLib_ReleaseIcon(hIcon); /* does NULL check */
+ break;
+ }
+ case WM_NCDESTROY:
+ if(dat==NULL) return 0;
+ if(dat->hFont!=NULL) DeleteObject(dat->hFont);
+ if(dat->hbrBackground!=NULL) DeleteObject(dat->hbrBackground);
+ mir_free(dat);
+ SetWindowLong(hwndFrame,GWL_USERDATA,(LONG)NULL);
+ break;
+ case WM_SIZE:
+ { RECT rc;
+ LONG width,height;
+ HDWP hdwp;
+ UINT defflg=SWP_NOZORDER|SWP_NOOWNERZORDER|SWP_NOACTIVATE;
+ SetRect(&rc,0,0,LOWORD(lParam),HIWORD(lParam)); /* width,height */
+ /* workaround: reduce flickering of frame in clist */
+ InvalidateRect(hwndFrame,&rc,FALSE);
+ hdwp=BeginDeferWindowPos(3);
+ /* progress */
+ width=rc.right-GetSystemMetrics(SM_CXICON)-10;
+ height=rc.bottom-(GetSystemMetrics(SM_CYICON)/2)-5;
+ hdwp=DeferWindowPos(hdwp,dat->hwndProgress,NULL,0,0,width,height,SWP_NOMOVE|defflg);
+ /* desc */
+ if(dat->hwndDesc!=NULL) hdwp=DeferWindowPos(hdwp,dat->hwndDesc,NULL,GetSystemMetrics(SM_CXICON)+5,5+height,0,0,SWP_NOSIZE|defflg);
+ /* time */
+ hdwp=DeferWindowPos(hdwp,dat->hwndTime,NULL,GetSystemMetrics(SM_CXICON)+85,5+height,width-80,(GetSystemMetrics(SM_CXICON)/2),defflg);
+ EndDeferWindowPos(hdwp);
+ PostMessage(hwndFrame,M_CHECK_CLIPPED,0,0);
+ return 0;
+ }
+ case M_REFRESH_COLORS:
+ { COLORREF clrBar;
+ if(FontService_GetColor(TranslateT("Automatic Shutdown"),TranslateT("Progress Bar"),&clrBar))
+ clrBar=GetDefaultColor(FRAMEELEMENT_BAR);
+ if(FontService_GetColor(TranslateT("Automatic Shutdown"),TranslateT("Background"),&dat->clrBackground))
+ dat->clrBackground=GetDefaultColor(FRAMEELEMENT_BKGRND);
+ if(dat->hbrBackground!=NULL) DeleteObject(dat->hbrBackground);
+ dat->hbrBackground=CreateSolidBrush(dat->clrBackground);
+ SendMessage(dat->hwndProgress,PBM_SETBARCOLOR,0,(LPARAM)clrBar);
+ SendMessage(dat->hwndProgress,PBM_SETBKCOLOR,0,(LPARAM)dat->clrBackground);
+ InvalidateRect(hwndFrame,NULL,TRUE);
+ return 0;
+ }
+ case M_REFRESH_ICONS:
+ if(dat->hwndIcon!=NULL)
+ IcoLib_ReleaseIcon((HICON)SendMessage(dat->hwndIcon,STM_SETIMAGE,IMAGE_ICON,(LPARAM)IcoLib_GetIcon("AutoShutdown_Header")));
+ if(hFrame) /* refresh frame title icon */
+ IcoLib_ReleaseIcon(SetFrameTitleIcon(hFrame,IcoLib_GetIcon("AutoShutdown_Active")));
+ return 0;
+ case M_REFRESH_FONTS:
+ { LOGFONT lf;
+ if(!FontService_GetFont(TranslateT("Automatic Shutdown"),TranslateT("Countdown on Frame"),&dat->clrText,&lf)) {
+ if(dat->hFont!=NULL) DeleteObject(dat->hFont);
+ dat->hFont=CreateFontIndirect(&lf);
+ }
+ else {
+ dat->clrText=GetDefaultColor(FRAMEELEMENT_TEXT);
+ if(GetDefaultFont(&lf)!=NULL) {
+ if(dat->hFont!=NULL) DeleteObject(dat->hFont);
+ dat->hFont=CreateFontIndirect(&lf);
+ }
+ }
+ if(dat->hwndDesc!=NULL)
+ SendMessage(dat->hwndDesc,WM_SETFONT,(WPARAM)dat->hFont,FALSE);
+ SendMessage(dat->hwndTime,WM_SETFONT,(WPARAM)dat->hFont,FALSE);
+ InvalidateRect(hwndFrame,NULL,FALSE);
+ return 0;
+ }
+ case WM_SYSCOLORCHANGE:
+ SendMessage(hwndFrame,M_REFRESH_COLORS,0,0);
+ break;
+ case WM_SETTINGCHANGE: /* colors depend on windows settings */
+ SendMessage(hwndFrame,M_REFRESH_COLORS,0,0);
+ SendMessage(hwndFrame,M_REFRESH_FONTS,0,0);
+ SendMessage(hwndFrame,M_UPDATE_COUNTDOWN,0,0);
+ RedrawWindow(hwndFrame,NULL,NULL,RDW_INVALIDATE|RDW_ALLCHILDREN|RDW_ERASE);
+ break;
+ case WM_TIMECHANGE: /* windows system clock changed */
+ SendMessage(hwndFrame,M_SET_COUNTDOWN,0,0);
+ PostMessage(hwndFrame,M_UPDATE_COUNTDOWN,0,0);
+ break;
+ case WM_CTLCOLORDLG:
+ case WM_CTLCOLORSTATIC:
+ SetTextColor((HDC)wParam,dat->clrText);
+ SetBkColor((HDC)wParam,dat->clrBackground);
+ return (BOOL)dat->hbrBackground;
+ case WM_ERASEBKGND:
+ { RECT rc;
+ if(dat->hbrBackground!=NULL && GetClientRect(hwndFrame,&rc)) {
+ FillRect((HDC)wParam,&rc,dat->hbrBackground);
+ return TRUE;
+ }
+ return FALSE;
+ }
+ case M_SET_COUNTDOWN:
+ if(dat->fTimeFlags&SDWTF_ST_TIME) {
+ dat->settingLastTime=(time_t)DBGetContactSettingDword(NULL,"AutoShutdown","TimeStamp",SETTING_TIMESTAMP_DEFAULT);
+ dat->countdown=time(NULL);
+ if(dat->settingLastTime>dat->countdown) dat->countdown=dat->settingLastTime-dat->countdown;
+ else dat->countdown=0;
+ }
+ else if(dat->flags&FWPDF_COUNTDOWNINVALID) {
+ dat->countdown=(time_t)DBGetContactSettingDword(NULL,"AutoShutdown","Countdown",SETTING_COUNTDOWN_DEFAULT);
+ dat->countdown*=(time_t)DBGetContactSettingDword(NULL,"AutoShutdown","CountdownUnit",SETTING_COUNTDOWNUNIT_DEFAULT);
+ }
+ dat->flags&=~FWPDF_COUNTDOWNINVALID;
+ /* commctl 4.70+, Win95: 1-100 will work fine (wrap around) */
+ SendMessage(dat->hwndProgress,PBM_SETRANGE32,(WPARAM)0,(LPARAM)dat->countdown);
+ return 0;
+ case WM_TIMER:
+ if(dat==NULL) return 0;
+ if(dat->countdown!=0 && !(dat->flags&FWPDF_COUNTDOWNINVALID) && !(dat->flags&FWPDF_PAUSED)) {
+ dat->countdown--;
+ PostMessage(dat->hwndProgress,PBM_STEPIT,0,0);
+ }
+ if(IsWindowVisible(hwndFrame)) PostMessage(hwndFrame,M_UPDATE_COUNTDOWN,0,0);
+ if(dat->countdown==0) {
+ SendMessage(hwndFrame,M_CLOSE_COUNTDOWN,0,0);
+ ServiceShutdown(0,TRUE);
+ ServiceStopWatcher(0,0);
+ }
+ return 0;
+ case WM_SHOWWINDOW:
+ /* the text is kept unchanged while hidden */
+ if((BOOL)wParam) SendMessage(hwndFrame,M_UPDATE_COUNTDOWN,0,0);
+ break;
+ case M_UPDATE_COUNTDOWN:
+ if(dat->flags&FWPDF_PAUSED && !(dat->flags&FWPDF_PAUSEDSHOWN)) {
+ SetWindowText(dat->hwndTime,TranslateT("Paused"));
+ dat->flags|=FWPDF_PAUSEDSHOWN;
+ }
+ else {
+ TCHAR szOutput[256];
+ if(dat->fTimeFlags&SDWTF_ST_TIME)
+ GetFormatedDateTime(szOutput,SIZEOF(szOutput),dat->settingLastTime,TRUE);
+ else GetFormatedCountdown(szOutput,SIZEOF(szOutput),dat->countdown);
+ SetWindowText(dat->hwndTime,szOutput);
+ PostMessage(hwndFrame,M_CHECK_CLIPPED,0,0);
+ /* update tooltip text (if shown) */
+ if(dat->hwndToolTip!=NULL && !(dat->flags&FWPDF_PAUSED)) {
+ TTTOOLINFO ti;
+ ti.cbSize=sizeof(ti);
+ if(SendMessage(dat->hwndToolTip,TTM_GETCURRENTTOOL,0,(LPARAM)&ti) && (HWND)ti.uId!=dat->hwndIcon)
+ SendMessage(dat->hwndToolTip,TTM_UPDATE,0,0);
+ } else dat->flags&=~FWPDF_PAUSEDSHOWN;
+ }
+ return 0;
+ case M_CLOSE_COUNTDOWN:
+ KillTimer(hwndFrame,1);
+ dat->countdown=0;
+ dat->flags&=~FWPDF_PAUSED;
+ SendMessage(hwndFrame,M_UPDATE_COUNTDOWN,0,0);
+ dat->flags|=FWPDF_COUNTDOWNINVALID;
+ /* step up to upper range */
+ SendMessage(dat->hwndProgress,PBM_SETPOS,SendMessage(dat->hwndProgress,PBM_GETRANGE,FALSE,0),0);
+ SetWindowLong(dat->hwndProgress,GWL_STYLE,GetWindowLong(dat->hwndProgress,GWL_STYLE)|PBM_SETMARQUEE);
+ SendMessage(dat->hwndProgress,PBM_SETMARQUEE,TRUE,10); /* marquee for rest of time */
+ return 0;
+ case M_PAUSE_COUNTDOWN:
+ if(dat->flags&FWPDF_PAUSED) {
+ /* unpause */
+ dat->flags&=~(FWPDF_PAUSED|FWPDF_PAUSEDSHOWN);
+ SendMessage(hwndFrame,M_SET_COUNTDOWN,0,0);
+ SendMessage(dat->hwndProgress,PBM_SETSTATE,PBST_NORMAL,0); /* WinVista+ */
+ }
+ else {
+ /* pause */
+ dat->flags|=FWPDF_PAUSED;
+ SendMessage(dat->hwndProgress,PBM_SETSTATE,PBST_PAUSED,0); /* WinVista+ */
+ }
+ SendMessage(hwndFrame,M_UPDATE_COUNTDOWN,0,0);
+ return 0;
+ case WM_CONTEXTMENU:
+ { HMENU hContextMenu;
+ POINT pt;
+ if(dat->flags&FWPDF_COUNTDOWNINVALID) return 0;
+ POINTSTOPOINT(pt,MAKEPOINTS(lParam));
+ if(pt.x==-1 && pt.y==-1) { /* invoked by keyboard */
+ RECT rc;
+ /* position in middle above rect */
+ if(!GetWindowRect(hwndFrame, &rc)) return 0;
+ pt.x=rc.left+((int)(rc.right-rc.left)/2);
+ pt.y=rc.top+((int)(rc.bottom-rc.top)/2);
+ }
+ hContextMenu=CreatePopupMenu();
+ if(hContextMenu!=NULL) {
+ AppendMenu(hContextMenu,MF_STRING,MENUITEM_PAUSECOUNTDOWN,(dat->flags&FWPDF_PAUSED)?TranslateT("&Unpause Countdown"):TranslateT("&Pause Countdown"));
+ SetMenuDefaultItem(hContextMenu,MENUITEM_PAUSECOUNTDOWN,FALSE);
+ AppendMenu(hContextMenu,MF_STRING,MENUITEM_STOPCOUNTDOWN,TranslateT("&Cancel Countdown"));
+ TrackPopupMenuEx(hContextMenu,TPM_LEFTALIGN|TPM_TOPALIGN|TPM_HORPOSANIMATION|TPM_VERPOSANIMATION|TPM_RIGHTBUTTON,pt.x,pt.y,hwndFrame,NULL);
+ DestroyMenu(hContextMenu);
+ }
+ return 0;
+ }
+ case WM_LBUTTONDBLCLK:
+ if(!(dat->flags&FWPDF_COUNTDOWNINVALID))
+ SendMessage(hwndFrame,M_PAUSE_COUNTDOWN,0,0);
+ return 0;
+ case WM_COMMAND:
+ switch(LOWORD(wParam)) {
+ case MENUITEM_STOPCOUNTDOWN:
+ /* close only countdown window when other watcher types running */
+ if(dat->fTimeFlags&~(SDWTF_SPECIFICTIME|SDWTF_ST_MASK))
+ CloseCountdownFrame(); /* something else is running */
+ else ServiceStopWatcher(0,0); /* calls CloseCountdownFrame() */
+ return 0;
+ case MENUITEM_PAUSECOUNTDOWN:
+ SendMessage(hwndFrame,M_PAUSE_COUNTDOWN,0,0);
+ return 0;
+ }
+ break;
+ case M_CHECK_CLIPPED: /* for in-place tooltip on dat->hwndTime */
+ { RECT rc;
+ HDC hdc;
+ SIZE size;
+ HFONT hFontPrev=NULL;
+ TCHAR szOutput[256];
+ dat->flags&=~FWPDF_TIMEISCLIPPED;
+ if(GetWindowText(dat->hwndTime,szOutput,SIZEOF(szOutput)-1))
+ if(GetClientRect(dat->hwndTime,&rc)) {
+ hdc=GetDC(dat->hwndTime);
+ if(hdc!=NULL) {
+ if(dat->hFont!=NULL)
+ hFontPrev=SelectObject(hdc,dat->hFont);
+ if(GetTextExtentPoint32(hdc,szOutput,lstrlen(szOutput),&size))
+ if(size.cx>=(rc.right-rc.left))
+ dat->flags&=FWPDF_TIMEISCLIPPED;
+ if(dat->hFont!=NULL)
+ SelectObject(hdc,hFontPrev);
+ ReleaseDC(dat->hwndTime,hdc);
+ }
+ }
+ return 0;
+ }
+ case WM_NOTIFY:
+ if(((NMHDR*)lParam)->hwndFrom==dat->hwndToolTip)
+ switch(((NMHDR*)lParam)->code) {
+ case TTN_SHOW: /* 'in-place' tooltip on dat->hwndTime */
+ if(dat->flags&FWPDF_TIMEISCLIPPED && (HWND)wParam==dat->hwndTime && IsWinVer2000Plus()) {
+ RECT rc;
+ if(GetWindowRect(dat->hwndTime,&rc)) {
+ SetWindowLong(dat->hwndToolTip,GWL_STYLE,GetWindowLong(dat->hwndToolTip,GWL_STYLE)|TTS_NOANIMATE);
+ SetWindowLong(dat->hwndToolTip,GWL_EXSTYLE,GetWindowLong(dat->hwndToolTip,GWL_EXSTYLE)|WS_EX_TRANSPARENT);
+ SendMessage(dat->hwndToolTip,TTM_ADJUSTRECT,TRUE,(LPARAM)&rc);
+ SetWindowPos(dat->hwndToolTip,NULL,rc.left,rc.top,0,0,SWP_NOSIZE|SWP_NOZORDER|SWP_NOACTIVATE);
+ return TRUE; /* self-defined position */
+ }
+ }
+ SetWindowLong(dat->hwndToolTip,GWL_STYLE,GetWindowLong(dat->hwndToolTip,GWL_STYLE)&(~TTS_NOANIMATE));
+ SetWindowLong(dat->hwndToolTip,GWL_EXSTYLE,GetWindowLong(dat->hwndToolTip,GWL_EXSTYLE)&(~WS_EX_TRANSPARENT));
+ return 0;
+ case TTN_POP:
+ /* workaround #5: frame does not get redrawn after
+ * in-place tooltip hidden on dat->hwndTime */
+ RedrawWindow(hwndCountdownFrame,NULL,NULL,RDW_INVALIDATE|RDW_ALLCHILDREN|RDW_ERASE);
+ return 0;
+ case TTN_NEEDTEXT:
+ { NMTTDISPINFO *ttdi=(NMTTDISPINFO*)lParam;
+ if(dat->flags&FWPDF_TIMEISCLIPPED && (HWND)wParam==dat->hwndTime) {
+ if(GetWindowText(dat->hwndTime,ttdi->szText,SIZEOF(ttdi->szText)-1))
+ ttdi->lpszText=ttdi->szText;
+ }
+ else if((HWND)wParam==dat->hwndIcon)
+ ttdi->lpszText=TranslateT("Automatic Shutdown");
+ else {
+ TCHAR szTime[SIZEOF(ttdi->szText)];
+ if(dat->fTimeFlags&SDWTF_ST_TIME)
+ GetFormatedDateTime(szTime,SIZEOF(szTime),dat->settingLastTime,FALSE);
+ else GetFormatedCountdown(szTime,SIZEOF(szTime),dat->countdown);
+ mir_sntprintf(ttdi->szText,SIZEOF(ttdi->szText),_T("%s %s"),(dat->fTimeFlags&SDWTF_ST_TIME)?TranslateT("Shutdown at:"):TranslateT("Time left:"),szTime);
+ ttdi->lpszText=ttdi->szText;
+ }
+ return 0;
+ }
+ }
+ break;
+ }
+ return DefWindowProc(hwndFrame,msg,wParam,lParam);
+}
+
+/************************* Show Frame *********************************/
+
+void ShowCountdownFrame(WORD fTimeFlags)
+{
+ hwndCountdownFrame=CreateWindowEx(WS_EX_CONTROLPARENT|WS_EX_NOPARENTNOTIFY|WS_EX_TRANSPARENT,
+ COUNTDOWNFRAME_CLASS,
+ NULL,
+ WS_CHILD|WS_TABSTOP,
+ 0, 0,
+ GetSystemMetrics(SM_CXICON)+103,
+ GetSystemMetrics(SM_CYICON)+2,
+ (HWND)CallService(MS_CLUI_GETHWND,0,0),
+ NULL,
+ hInst,
+ &fTimeFlags);
+ if(hwndCountdownFrame==NULL) return;
+
+ if(ServiceExists(MS_CLIST_FRAMES_ADDFRAME)) {
+ CLISTFrame clf;
+ ZeroMemory(&clf,sizeof(clf));
+ clf.cbSize=sizeof(clf);
+ clf.hIcon=IcoLib_GetIcon("AutoShutdown_Active"); /* CListFrames does not make a copy */
+ clf.align=alBottom;
+ clf.height=GetSystemMetrics(SM_CYICON);
+ clf.Flags=F_VISIBLE|F_SHOWTBTIP|F_NOBORDER|F_SKINNED;
+ clf.name=Translate("AutoShutdown");
+ clf.TBname=Translate("Automatic Shutdown");
+ clf.hWnd=hwndCountdownFrame;
+ hFrame=(WORD)CallService(MS_CLIST_FRAMES_ADDFRAME,(WPARAM)&clf,0);
+ if(hFrame) {
+ ShowWindow(hwndCountdownFrame,SW_SHOW);
+ CallService(MS_CLIST_FRAMES_SETFRAMEOPTIONS,MAKEWPARAM(FO_TBTIPNAME,hFrame),(LPARAM)clf.name);
+ /* HACKS TO FIX CLUI FRAMES:
+ * *** why is CLUIFrames is horribly buggy??! *** date: sept 2005, nothing changed until sept 2006
+ * workaround #1: MS_CLIST_FRAMES_REMOVEFRAME does not finish with destroy cycle (clist_modern, clist_nicer crashes) */
+ SendMessage((HWND)CallService(MS_CLUI_GETHWND,0,0),WM_SIZE,0,0);
+ /* workaround #2: drawing glitch after adding a frame (frame positioned wrongly when hidden) */
+ CallService(MS_CLIST_FRAMES_UPDATEFRAME,hFrame,FU_FMPOS|FU_FMREDRAW);
+ /* workaround #3: MS_CLIST_FRAMES_SETFRAMEOPTIONS does cause redrawing problems */
+ if(!(CallService(MS_CLIST_FRAMES_GETFRAMEOPTIONS,MAKEWPARAM(FO_FLAGS,hFrame),0)&F_VISIBLE))
+ CallService(MS_CLIST_FRAMES_SHFRAME,hFrame,0);
+ /* workaround #4: MS_CLIST_FRAMES_SHFRAME does cause redrawing problems when frame was hidden */
+ RedrawWindow(hwndCountdownFrame,NULL,NULL,RDW_INVALIDATE|RDW_ALLCHILDREN|RDW_ERASE);
+ /* workaround #5: for in-place tooltip TTN_POP
+ * workaround #6 and #7: see CloseCountdownFrame() */
+ }
+ }
+}
+
+void CloseCountdownFrame(void)
+{
+ if(hwndCountdownFrame!=NULL) {
+ SendMessage(hwndCountdownFrame,M_CLOSE_COUNTDOWN,0,0);
+ if(hFrame) {
+ IcoLib_ReleaseIcon(SetFrameTitleIcon(hFrame,NULL));
+ /* HACKS TO FIX CLUIFrames:
+ * workaround #6: MS_CLIST_FRAMES_REMOVEFRAME does not finish with
+ * destroy cycle (clist_modern, clist_nicer crashes) */
+ CallService(MS_CLIST_FRAMES_SETFRAMEOPTIONS,MAKEWPARAM(FO_FLAGS,hFrame),(LPARAM)CallService(MS_CLIST_FRAMES_GETFRAMEOPTIONS,MAKEWPARAM(FO_FLAGS,hFrame),0)&(~F_VISIBLE));
+ #if !defined(_DEBUG)
+ /* workaround #7: MS_CLIST_FRAMES_REMOVEFRAME crashes after two calls
+ * clist_nicer crashes after some calls (bug in it) */
+ CallService(MS_CLIST_FRAMES_REMOVEFRAME,hFrame,0);
+ #endif
+ }
+ else DestroyWindow(hwndCountdownFrame);
+ hwndCountdownFrame=NULL;
+ hFrame=0;
+ }
+
+}
+
+/************************* Misc ***************************************/
+
+static int FrameModulesLoaded(WPARAM wParam,LPARAM lParam)
+{
+ UNREFERENCED_PARAMETER(wParam);
+ UNREFERENCED_PARAMETER(lParam);
+ if(ServiceExists(MS_CLIST_FRAMES_ADDFRAME)) {
+ LOGFONT lf;
+ COLORREF clr;
+ HMODULE hUxThemeDLL;
+ BOOL (WINAPI *pfnIsThemeActive)(VOID);
+ /* built-in font module is not available before this hook */
+ clr=GetDefaultColor(FRAMEELEMENT_TEXT);
+ FontService_RegisterFont("AutoShutdown","CountdownFont",TranslateT("Automatic Shutdown"),TranslateT("Countdown on Frame"),0,FALSE,GetDefaultFont(&lf),clr);
+ clr=GetDefaultColor(FRAMEELEMENT_BKGRND);
+ FontService_RegisterColor("AutoShutdown","BkgColor",TranslateT("Automatic Shutdown"),TranslateT("Background"),clr);
+ /* progressbar color can only be changed in windows classic theme */
+ /* FIXME: should be registered/unregistered on WM_THEMECHANGED/ME_OPT_INITIALISE msg,
+ * currently not possible as no such font service exists */
+ hUxThemeDLL=LoadLibraryA("UXTHEME"); /* all ascii */
+ *(PROC*)&pfnIsThemeActive=(hUxThemeDLL!=NULL)?GetProcAddress(hUxThemeDLL,"IsThemeActive"):NULL;
+ if(pfnIsThemeActive==NULL || !pfnIsThemeActive()) {
+ /* progressbar color can only be changed with classic theme */
+ clr=GetDefaultColor(FRAMEELEMENT_BAR);
+ FontService_RegisterColor("AutoShutdown","ProgressColor",TranslateT("Automatic Shutdown"),TranslateT("Progress Bar"),clr);
+ }
+ if(hUxThemeDLL!=NULL) FreeLibrary(hUxThemeDLL);
+ }
+ return 0;
+}
+
+int InitFrame(void)
+{
+ WNDCLASSEX wcx;
+ ZeroMemory(&wcx,sizeof(wcx));
+ wcx.cbSize =sizeof(wcx);
+ wcx.style =CS_DBLCLKS|CS_PARENTDC;
+ wcx.lpfnWndProc =FrameWndProc;
+ wcx.hInstance =hInst;
+ wcx.hCursor =(HCURSOR)LoadImage(NULL,IDC_ARROW,IMAGE_CURSOR,0,0,LR_SHARED);
+ wcx.lpszClassName =COUNTDOWNFRAME_CLASS;
+ if(!RegisterClassEx(&wcx)) return 1;
+
+ hwndCountdownFrame=NULL;
+ hHookModulesLoaded=HookEvent(ME_SYSTEM_MODULESLOADED,FrameModulesLoaded);
+ return 0;
+}
+
+void UninitFrame(void)
+{
+ /* frame closed by UninitWatcher() */
+ UnregisterClass(COUNTDOWNFRAME_CLASS,hInst); /* fails if window still exists */
+ UnhookEvent(hHookModulesLoaded);
+}
diff --git a/plugins/AutoShutdown/frame.h b/plugins/AutoShutdown/frame.h
new file mode 100644
index 0000000000..1b0bffdafd
--- /dev/null
+++ b/plugins/AutoShutdown/frame.h
@@ -0,0 +1,28 @@
+/*
+
+'AutoShutdown'-Plugin for Miranda IM
+
+Copyright 2004-2007 H. Herkenrath
+
+This program is free software; you can redistribute it and/or
+modify it under the terms of the GNU General Public License
+as published by the Free Software Foundation; either version 2
+of the License, or (at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program (Shutdown-License.txt); if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+*/
+
+/* Show Frame */
+void ShowCountdownFrame(WORD fTimeFlags);
+void CloseCountdownFrame(void);
+
+/* Misc */
+int InitFrame(void);
+void UninitFrame(void); \ No newline at end of file
diff --git a/plugins/AutoShutdown/m_shutdown.h b/plugins/AutoShutdown/m_shutdown.h
new file mode 100644
index 0000000000..87e25e8851
--- /dev/null
+++ b/plugins/AutoShutdown/m_shutdown.h
@@ -0,0 +1,196 @@
+/*
+
+'AutoShutdown'-Plugin for
+Miranda IM: the free IM client for Microsoft* Windows*
+
+Copyright (C) 2004-2007 H. Herkenrath
+
+This program is free software; you can redistribute it and/or
+modify it under the terms of the GNU General Public License
+as published by the Free Software Foundation; either version 2
+of the License, or (at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program (Shutdown-License.txt); if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+*/
+
+#ifndef M_SHUTDOWN_H__
+#define M_SHUTDOWN_H__
+
+#if defined (_MSC_VER) && (_MSC_VER >= 1020)
+ #pragma once
+#endif
+
+/*
+ AutoShutdown v1.4.0.2
+*/
+
+/* interface id */
+#if !defined(MIID_SHUTDOWN)
+ #define MIID_SHUTDOWN {0x142982a8,0x88cf,0x4c65,{0x87,0x21,0x6d,0xe2,0x7d,0x5c,0xe7,0xb5}}
+#endif
+
+/******************************************************************/
+/************************* SERVICES *******************************/
+/******************************************************************/
+
+/* Show settings dialog v1.3.0.0+
+Shows the dialog by which the shutdown watcher can be started.
+If the dialog is already opened this brings it to foreground.
+ wParam=lParam=0
+Returns 0 on success, nonzero otherwise.
+*/
+#define MS_AUTOSHUTDOWN_SHOWSETTINGSDIALOG "AutoShutdown/ShowSettingsDialog"
+
+/* Initiate shutdown process v1.3.0.0+
+Initiates the shutdown process for a given shutdown type.
+If another shutdown process is already pending it will return error.
+Associated events: ME_AUTOSHUTDOWN_OKTOSHUTDOWN, ME_AUTOSHUTDOWN_SHUTDOWN
+ wParam=shutdownType
+ lParam=(LPARAM)(BOOL)fShowConfirmDlg (whether to show the warning dialog or not)
+Returns 0 on success, nonzero otherwise.
+*/
+#define MS_AUTOSHUTDOWN_SHUTDOWN "AutoShutdown/Shutdown"
+
+/* shutdown types */
+#define SDSDT_CLOSEMIRANDA 1 // close miranda process
+#define SDSDT_SETMIRANDAOFFLINE 2 // set all protocols to offline
+#define SDSDT_LOGOFF 3 // logoff from Windows
+#define SDSDT_REBOOT 4 // reboot computer
+#define SDSDT_SHUTDOWN 5 // shutdown Windows and power off
+#define SDSDT_STANDBY 6 // standby mode
+#define SDSDT_HIBERNATE 7 // hibernate mode
+#define SDSDT_LOCKWORKSTATION 8 // lock the workstation
+#define SDSDT_CLOSERASCONNECTIONS 9 // close all dialup connections
+#define SDSDT_MAX 9
+
+/* Get shutdown type description v1.4.0.0+
+Gets a textual description of the given shutdown type.
+ wParam=shutdownType
+ lParam=flags (see GSTDF_* below)
+Returns a static buffer of the description of the given shutdown type.
+It does not need to be freed in any way.
+The returned text is already translated.
+Returns a pointer to a string on success, NULL on error.
+*/
+#define MS_AUTOSHUTDOWN_GETTYPEDESCRIPTION "AutoShutdown/GetTypeDescription"
+
+#define GSTDF_LONGDESC 0x0001 // returns a long description
+#define GSTDF_UNICODE 0x0002 // returns a Unicode string
+#define GSTDF_UNTRANSLATED 0x0004 // returns an untranslated string
+#if defined(_UNICODE)
+ #define GSTDF_TCHAR GSTDF_UNICODE // will return WCHAR*
+#else
+ #define GSTDF_TCHAR 0 // will return char*, as usual
+#endif
+
+/* Check if shutdown type is enabled v1.4.0.0+
+Tests if a specific shutdown type is activated and its use is possible
+on the system. For example hibernate and stand-by modes are not available on
+older versions of Windows (needs Windows ME/2000+).
+Shutdown might also be prohibited by security restrictions.
+This services checks it all.
+However, there is no need to call this before calling MS_AUTOSHUTDOWN_SHUTDOWN.
+MS_AUTOSHUTDOWN_SHUTDOWN will fail if the given shutdown type is not enabled.
+ wParam=shutdownType
+ lParam=0
+Returns TRUE if the given shutdown type is enabled, FALSE otherwise.
+*/
+#define MS_AUTOSHUTDOWN_ISTYPEENABLED "AutoShutdown/IsTypeEnabled"
+
+/* Start shutdown watcher v1.4.0.0+
+Starts the watcher using the last settings specified on the dialog
+shown by MS_AUTOSHUTDOWN_SHOWSETTINGSDIALOG.
+Call MS_AUTOSHUTDOWN_SHOWSETTINGSDIALOG instead to offer
+options about what watcher to use.
+Associated event: ME_AUTOSHUTDOWN_WATCHERCHANGED
+ wParam=lParam=0
+Returns 0 on success, nonzero otherwise.
+*/
+#define MS_AUTOSHUTDOWN_STARTWATCHER "AutoShutdown/StartWatcher"
+
+/* Stop shutdown watcher v1.4.0.0+
+Stops the currently running watcher.
+If the watcher is not running, it returns error.
+Associated event: ME_AUTOSHUTDOWN_WATCHERCHANGED
+ wParam=lParam=0
+Returns 0 on success, nonzero otherwise.
+*/
+#define MS_AUTOSHUTDOWN_STOPWATCHER "AutoShutdown/StopWatcher"
+
+/* Check if watcher is running v1.4.0.0+
+Checks if the watcher is currently active or not.
+ wParam=lParam=0
+Returns TRUE if the watcher is enabled, FALSE otherwise.
+*/
+#define MS_AUTOSHUTDOWN_ISWATCHERENABLED "AutoShutdown/IsWatcherEnabled"
+
+/******************************************************************/
+/************************** EVENTS ********************************/
+/******************************************************************/
+
+/* Disallow shutdown process (event) v1.3.0.0+
+Gets fired when MS_AUTOSHUTDOWN_SHUTDOWN is called.
+Parmeters are the same as specified at the call to MS_AUTOSHUTDOWN_SHUTDOWN.
+ wParam=shutdownType
+ lParam=(LPARAM)(BOOL)fShowConfirmDlg
+Return 0 to allow shutdown, 1 to disallow.
+*/
+#define ME_AUTOSHUTDOWN_OKTOSHUTDOWN "AutoShutdown/OkToShutdown"
+
+/* Shutdown process started (event) v1.3.0.1+
+Gets fired when ME_AUTOSHUTDOWN_OKTOSHUTDOWN was confirmed.
+Parmeters are the same as specified at the call
+to MS_AUTOSHUTDOWN_SHUTDOWN.
+ wParam=shutdownType
+ lParam=(LPARAM)(BOOL)fShowConfirmDlg
+Unused, return always 0 here.
+*/
+#define ME_AUTOSHUTDOWN_SHUTDOWN "AutoShutdown/ShutdownEvent"
+
+/* Watcher changed (event) v1.3.0.0+
+Fired when MS_AUTOSHUTDOWN_STARTWATCHER or MS_AUTOSHUTDOWN_STOPWATCHER
+is called.
+ wParam=(WPARAM)(BOOL)fIsStarted (whether whe watcher is running now)
+ lParam=0
+Unused, return always 0 here.
+*/
+#define ME_AUTOSHUTDOWN_WATCHERCHANGED "AutoShutdown/Watcher/Changed"
+
+
+#ifndef SHUTDOWN_NOSETTINGS
+#define SETTING_REMEMBERONRESTART_DEFAULT 0 // SDROR_RUNNING
+#define SETTING_SHOWCONFIRMDLG_DEFAULT 1
+#define SETTING_CONFIRMDLGCOUNTDOWN_DEFAULT 30 // seconds
+#define SETTING_WEATHERSHUTDOWN_DEFAULT 0
+#define SETTING_HDDOVERHEATSHUTDOWN_DEFAULT 1
+#define SETTING_SMARTOFFLINECHECK_DEFAULT 1
+
+#define SETTING_SHUTDOWNTYPE_DEFAULT SDSDT_SHUTDOWN
+#define SETTING_WATCHERFLAGS_DEFAULT (SDWTF_SPECIFICTIME|SDWTF_ST_COUNTDOWN)
+#define SETTING_COUNTDOWN_DEFAULT 30
+#define SETTING_COUNTDOWNUNIT_DEFAULT 60 // x times countdown seconds
+#define SETTING_TIMESTAMP_DEFAULT (DWORD)(time(NULL)+(SETTING_COUNTDOWN_DEFAULT*SETTING_COUNTDOWNUNIT_DEFAULT))
+#define SETTING_CPUUSAGETHRESHOLD_DEFAULT 90 // percent
+
+#define SDWTF_SPECIFICTIME 0x0001
+#define SDWTF_ST_TIME 0x0002
+#define SDWTF_ST_COUNTDOWN 0x0004
+#define SDWTF_ST_MASK 0x0006 /* bitmask for SDWTF_ST_* bits */
+#define SDWTF_MESSAGE 0x0008
+#define SDWTF_FILETRANSFER 0x0010
+#define SDWTF_IDLE 0x0020
+#define SDWTF_STATUS 0x0040
+#define SDWTF_CPUUSAGE 0x0080
+#define SDWTF_MASK 0x00FF /* bitmask for all SDWTF_* bits */
+
+#define SDROR_RUNNING 3
+#endif
+
+#endif // M_SHUTDOWN_H
diff --git a/plugins/AutoShutdown/main.c b/plugins/AutoShutdown/main.c
new file mode 100644
index 0000000000..d4f9a63480
--- /dev/null
+++ b/plugins/AutoShutdown/main.c
@@ -0,0 +1,192 @@
+/*
+
+'AutoShutdown'-Plugin for Miranda IM
+
+Copyright 2004-2007 H. Herkenrath
+
+This program is free software; you can redistribute it and/or
+modify it under the terms of the GNU General Public License
+as published by the Free Software Foundation; either version 2
+of the License, or (at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program (Shutdown-License.txt); if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+*/
+
+#include "common.h"
+#include "version.h"
+
+HINSTANCE hInst;
+PLUGINLINK *pluginLink;
+struct MM_INTERFACE mmi;
+static HANDLE hHookModulesLoaded;
+HANDLE hActiveIcon,hInactiveIcon;
+
+PLUGININFOEX pluginInfo={
+ sizeof(PLUGININFOEX),
+ "AutoShutdown",
+ PLUGIN_VERSION,
+#if defined(_DEBUG)
+ "Development build not intended for release. ("__DATE__")",
+#else
+ "Adds the possibility to shutdown the computer when a specified event occurs.", /* autotranslated */
+#endif
+ "H. Herkenrath",
+ PLUGIN_EMAIL, /* @ will be set later */
+ "© 2004-2007 H. Herkenrath",
+ PLUGIN_WEBSITE,
+ UNICODE_AWARE,
+ 0,
+#if defined(_UNICODE)
+ // {9DE24579-5C5C-49aa-80E8-4D38E4344E63}
+ {0x9de24579,0x5c5c,0x49aa,{0x80,0xe8,0x4d,0x38,0xe4,0x34,0x4e,0x63}},
+#else
+ // {7C0DD208-94D8-4283-879A-E6F86135B826}
+ {0x7c0dd208,0x94d8,0x4283,{0x87,0x9a,0xe6,0xf8,0x61,0x35,0xb8,0x26}}
+#endif
+};
+static const MUUID interfaces[]={MIID_SHUTDOWN,MIID_LAST};
+
+BOOL WINAPI DllMain(HINSTANCE hinstDLL,DWORD fdwReason,void *pReserved)
+{
+ UNREFERENCED_PARAMETER(pReserved);
+ if(fdwReason==DLL_PROCESS_ATTACH)
+ /* Do not call this function from a DLL that is linked to the static C run-time library (CRT).
+ * The static CRT requires DLL_THREAD_ATTACH and DLL_THREAD_DETATCH notifications to function properly. */
+ DisableThreadLibraryCalls(hInst=hinstDLL);
+ return TRUE;
+}
+
+static void InstallFile(const TCHAR *pszFileName,const TCHAR *pszDestSubDir)
+{
+ TCHAR szFileFrom[MAX_PATH+1],szFileTo[MAX_PATH+1],*p;
+ HANDLE hFile;
+
+ if(!GetModuleFileName(hInst,szFileFrom,SIZEOF(szFileFrom)-lstrlen(pszFileName)))
+ return;
+ p=_tcsrchr(szFileFrom,_T('\\'));
+ if(p!=NULL) *(++p)=0;
+ lstrcat(szFileFrom,pszFileName); /* buffer safe */
+
+ hFile=CreateFile(szFileFrom,0,FILE_SHARE_READ,0,OPEN_EXISTING,0,0);
+ if(hFile==INVALID_HANDLE_VALUE) return;
+ CloseHandle(hFile);
+
+ if(!GetModuleFileName(NULL,szFileTo,SIZEOF(szFileTo)-lstrlen(pszDestSubDir)-lstrlen(pszFileName)))
+ return;
+ p=_tcsrchr(szFileTo,_T('\\'));
+ if(p!=NULL) *(++p)=0;
+ lstrcat(szFileTo,pszDestSubDir); /* buffer safe */
+ CreateDirectory(szFileTo,NULL);
+ lstrcat(szFileTo,pszFileName); /* buffer safe */
+
+ if(!MoveFile(szFileFrom,szFileTo) && GetLastError()==ERROR_ALREADY_EXISTS) {
+ DeleteFile(szFileTo);
+ MoveFile(szFileFrom,szFileTo);
+ }
+}
+
+static int ShutdownModulesLoaded(WPARAM wParam,LPARAM lParam)
+{
+ UNREFERENCED_PARAMETER(wParam);
+ UNREFERENCED_PARAMETER(lParam);
+ if(ServiceExists("DBEditorpp/RegisterSingleModule"))
+ CallService("DBEditorpp/RegisterSingleModule",(WPARAM)"AutoShutdown",0);
+ /* merged thundershutdown plugin */
+ if(GetModuleHandleA("tshutdown.dll")) {
+ DBWriteContactSettingByte(NULL,"PluginDisable","tshutdown.dll",1);
+ DBWriteContactSettingByte(NULL,"AutoShutdown","WeatherShutdown",1);
+ }
+ return 0;
+}
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+__declspec(dllexport) const PLUGININFO* MirandaPluginInfo(DWORD mirandaVersion)
+{
+ if(mirandaVersion<PLUGIN_MAKE_VERSION(0,1,0,1)) return NULL;
+ pluginInfo.cbSize=sizeof(PLUGININFO); /* needed as v0.6 does equality check */
+ /* email obfuscated, made .rdata writable */
+ pluginInfo.authorEmail[PLUGIN_EMAIL_ATT_POS-1]='@';
+ return (PLUGININFO*)&pluginInfo; /* header is the same */
+}
+
+__declspec(dllexport) const PLUGININFOEX* MirandaPluginInfoEx(DWORD mirandaVersion)
+{
+ UNREFERENCED_PARAMETER(mirandaVersion);
+ pluginInfo.cbSize=sizeof(PLUGININFOEX);
+ /* email obfuscated, made .rdata writable */
+ pluginInfo.authorEmail[PLUGIN_EMAIL_ATT_POS-1]='@';
+ return &pluginInfo;
+}
+
+__declspec(dllexport) const MUUID* MirandaPluginInterfaces(void)
+{
+ return interfaces;
+}
+
+__declspec(dllexport) int Load(PLUGINLINK *link)
+{
+ INITCOMMONCONTROLSEX icc;
+ pluginLink=link;
+
+ /* existance of MS_SYSTEM_GETVERSION and MS_LANGPACK_TRANSLATESTRING
+ * is checked in MirandaPluginInfo().
+ * Not placed in MirandaPluginInfo() to avoid MessageBoxes on plugin options.
+ * Using ANSI as LANG_UNICODE might not be supported. */
+ if(CallService(MS_SYSTEM_GETVERSION,0,0)<NEEDED_MIRANDA_VERSION) {
+ char szText[256];
+ mir_snprintf(szText,sizeof(szText),Translate("The AutoShutdown plugin can not be loaded. It requires Miranda IM %hs or later."),NEEDED_MIRANDA_VERSION_STR);
+ MessageBoxA(NULL,szText,Translate("AutoShutdown Plugin"),MB_OK|MB_ICONERROR|MB_SETFOREGROUND|MB_TOPMOST|MB_TASKMODAL);
+ return 1;
+ }
+ if(!ServiceExists(MS_DB_CONTACT_GETSETTING_STR)) return 1; /* dbx3x v0.5.1.0 */
+ if(mir_getMMI(&mmi)) return 1;
+ icc.dwSize=sizeof(icc);
+ icc.dwICC=ICC_DATE_CLASSES|ICC_UPDOWN_CLASS|ICC_PROGRESS_CLASS;
+ if(!InitCommonControlsEx(&icc)) return 1;
+
+ if(InitFrame()) return 1; /* before icons */
+
+ /* shared */
+ IcoLib_AddIconRes("AutoShutdown_Header",TranslateT("Automatic Shutdown"),TranslateT("Header"),hInst,IDI_HEADER,TRUE);
+ hActiveIcon=IcoLib_AddIconRes("AutoShutdown_Active",TranslateT("Automatic Shutdown"),TranslateT("Active"),hInst,IDI_ACTIVE,FALSE);
+ hInactiveIcon=IcoLib_AddIconRes("AutoShutdown_Inactive",TranslateT("Automatic Shutdown"),TranslateT("Inactive"),hInst,IDI_INACTIVE,FALSE);
+
+ InitShutdownSvc();
+ InitWatcher(); /* before InitSettingsDlg() */
+ InitSettingsDlg();
+ InitOptions();
+
+ /* installation */
+ InstallFile(_T("Shutdown-Readme.txt"),_T("Docs\\"));
+ InstallFile(_T("Shutdown-License.txt"),_T("Docs\\"));
+ InstallFile(_T("Shutdown-SDK.zip"),_T("Docs\\"));
+ InstallFile(_T("countdown.wav"),_T("Sounds\\"));
+ hHookModulesLoaded=HookEvent(ME_SYSTEM_MODULESLOADED,ShutdownModulesLoaded);
+ return 0;
+}
+
+__declspec(dllexport) int Unload(void)
+{
+ UnhookEvent(hHookModulesLoaded);
+
+ UninitOptions();
+ UninitSettingsDlg(); /* before UninitWatcher() */
+ UninitWatcher(); /* before UninitFrame() */
+ UninitFrame();
+ UninitShutdownSvc();
+ return 0;
+}
+
+#ifdef __cplusplus
+}
+#endif
diff --git a/plugins/AutoShutdown/options.c b/plugins/AutoShutdown/options.c
new file mode 100644
index 0000000000..2026038859
--- /dev/null
+++ b/plugins/AutoShutdown/options.c
@@ -0,0 +1,189 @@
+/*
+
+'AutoShutdown'-Plugin for Miranda IM
+
+Copyright 2004-2007 H. Herkenrath
+
+This program is free software; you can redistribute it and/or
+modify it under the terms of the GNU General Public License
+as published by the Free Software Foundation; either version 2
+of the License, or (at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program (Shutdown-License.txt); if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+*/
+
+#include "common.h"
+
+/* Option Page */
+static HANDLE hHookOptInit;
+extern HINSTANCE hInst;
+/* Trigger */
+static HANDLE hHookModulesLoaded;
+
+/************************* Option Page ********************************/
+
+#define M_ENABLE_SUBCTLS (WM_APP+111)
+
+static int CALLBACK ShutdownOptDlgProc(HWND hwndDlg,UINT msg,WPARAM wParam,LPARAM lParam)
+{
+ switch(msg) {
+ case WM_INITDIALOG:
+ TranslateDialogDefault(hwndDlg);
+ { WORD setting=DBGetContactSettingWord(NULL,"AutoShutdown","ConfirmDlgCountdown",SETTING_CONFIRMDLGCOUNTDOWN_DEFAULT);
+ if(setting<3) setting=SETTING_CONFIRMDLGCOUNTDOWN_DEFAULT;
+ SendDlgItemMessage(hwndDlg,IDC_SPIN_CONFIRMDLGCOUNTDOWN,UDM_SETRANGE,0,MAKELPARAM(999,3));
+ SendDlgItemMessage(hwndDlg,IDC_EDIT_CONFIRMDLGCOUNTDOWN,EM_SETLIMITTEXT,3,0);
+ SendDlgItemMessage(hwndDlg,IDC_SPIN_CONFIRMDLGCOUNTDOWN,UDM_SETPOS,0,MAKELPARAM(setting,0));
+ SetDlgItemInt(hwndDlg,IDC_EDIT_CONFIRMDLGCOUNTDOWN,setting,FALSE);
+ }
+ CheckDlgButton(hwndDlg,IDC_CHECK_SMARTOFFLINECHECK,DBGetContactSettingByte(NULL,"AutoShutdown","SmartOfflineCheck",SETTING_SMARTOFFLINECHECK_DEFAULT)!=0);
+ CheckDlgButton(hwndDlg,IDC_CHECK_REMEMBERONRESTART,DBGetContactSettingByte(NULL,"AutoShutdown","RememberOnRestart",SETTING_REMEMBERONRESTART_DEFAULT)!=0);
+ CheckDlgButton(hwndDlg,IDC_CHECK_SHOWCONFIRMDLG,DBGetContactSettingByte(NULL,"AutoShutdown","ShowConfirmDlg",SETTING_SHOWCONFIRMDLG_DEFAULT)!=0);
+ { BOOL enabled=ServiceIsTypeEnabled(SDSDT_SHUTDOWN,0);
+ if(enabled) {
+ if(ServiceExists(MS_SYSINFO_HDDTEMP)) {
+ EnableWindow(GetDlgItem(hwndDlg,IDC_CHECK_HDDOVERHEAT),TRUE);
+ CheckDlgButton(hwndDlg,IDC_CHECK_HDDOVERHEAT,DBGetContactSettingByte(NULL,"AutoShutdown","HddOverheatShutdown",SETTING_HDDOVERHEATSHUTDOWN_DEFAULT)!=0);
+ }
+ if(ServiceExists(MS_WEATHER_UPDATE)) {
+ EnableWindow(GetDlgItem(hwndDlg,IDC_CHECK_WEATHER),TRUE);
+ CheckDlgButton(hwndDlg,IDC_CHECK_WEATHER,DBGetContactSettingByte(NULL,"AutoShutdown","WeatherShutdown",SETTING_WEATHERSHUTDOWN_DEFAULT)!=0);
+ }
+ }
+ }
+ SendMessage(hwndDlg,M_ENABLE_SUBCTLS,0,0);
+ return TRUE; /* default focus */
+ case M_ENABLE_SUBCTLS:
+ { BOOL checked=IsDlgButtonChecked(hwndDlg,IDC_CHECK_SHOWCONFIRMDLG)!=0;
+ if(checked!=IsWindowEnabled(GetDlgItem(hwndDlg,IDC_EDIT_CONFIRMDLGCOUNTDOWN))) {
+ EnableWindow(GetDlgItem(hwndDlg,IDC_EDIT_CONFIRMDLGCOUNTDOWN),checked);
+ EnableWindow(GetDlgItem(hwndDlg,IDC_SPIN_CONFIRMDLGCOUNTDOWN),checked);
+ EnableWindow(GetDlgItem(hwndDlg,IDC_TEXT_COUNTDOWNSTARTS),checked);
+ EnableWindow(GetDlgItem(hwndDlg,IDC_TEXT_SECONDS),checked);
+ }
+ return TRUE;
+ }
+ case WM_COMMAND:
+ switch(LOWORD(wParam)) {
+ case IDC_EDIT_CONFIRMDLGCOUNTDOWN:
+ if(HIWORD(wParam)==EN_KILLFOCUS)
+ if((int)GetDlgItemInt(hwndDlg,IDC_EDIT_CONFIRMDLGCOUNTDOWN,NULL,TRUE)<3) {
+ SendDlgItemMessage(hwndDlg,IDC_SPIN_CONFIRMDLGCOUNTDOWN,UDM_SETPOS,0,MAKELPARAM(3,0));
+ SetDlgItemInt(hwndDlg,IDC_EDIT_CONFIRMDLGCOUNTDOWN,3,FALSE);
+ }
+ if(HIWORD(wParam)!=EN_CHANGE || (HWND)lParam!=GetFocus())
+ return TRUE; /* no apply */
+ break;
+ }
+ PostMessage(hwndDlg,M_ENABLE_SUBCTLS,0,0);
+ PostMessage(GetParent(hwndDlg),PSM_CHANGED,0,0); /* enable apply */
+ return FALSE;
+ case WM_NOTIFY:
+ switch(((NMHDR*)lParam)->code) {
+ case PSN_APPLY:
+ DBWriteContactSettingByte(NULL,"AutoShutdown","ShowConfirmDlg",(BYTE)(IsDlgButtonChecked(hwndDlg,IDC_CHECK_SHOWCONFIRMDLG)!=0));
+ DBWriteContactSettingWord(NULL,"AutoShutdown","ConfirmDlgCountdown",(WORD)GetDlgItemInt(hwndDlg,IDC_EDIT_CONFIRMDLGCOUNTDOWN,NULL,FALSE));
+ DBWriteContactSettingByte(NULL,"AutoShutdown","RememberOnRestart",(BYTE)(IsDlgButtonChecked(hwndDlg,IDC_CHECK_REMEMBERONRESTART)!=0));
+ DBWriteContactSettingByte(NULL,"AutoShutdown","SmartOfflineCheck",(BYTE)(IsDlgButtonChecked(hwndDlg,IDC_CHECK_SMARTOFFLINECHECK)!=0));
+ if(IsWindowEnabled(GetDlgItem(hwndDlg,IDC_CHECK_WEATHER)))
+ DBWriteContactSettingByte(NULL,"AutoShutdown","WeatherShutdown",(BYTE)(IsDlgButtonChecked(hwndDlg,IDC_CHECK_WEATHER)!=0));
+ if(IsWindowEnabled(GetDlgItem(hwndDlg,IDC_CHECK_HDDOVERHEAT)))
+ DBWriteContactSettingByte(NULL,"AutoShutdown","HddOverheatShutdown",(BYTE)(IsDlgButtonChecked(hwndDlg,IDC_CHECK_HDDOVERHEAT)!=0));
+ return TRUE;
+ }
+ break;
+ }
+ return FALSE;
+}
+
+static int ShutdownOptInit(WPARAM wParam,LPARAM lParam)
+{
+ OPTIONSDIALOGPAGE odp;
+ UNREFERENCED_PARAMETER(lParam);
+ ZeroMemory(&odp,sizeof(odp));
+ odp.cbSize=sizeof(odp);
+ odp.hInstance=hInst;
+ odp.pszTemplate=MAKEINTRESOURCEA(IDD_OPT_SHUTDOWN);
+ odp.position=900000002;
+ odp.ptszGroup=_T("Events"); /* autotranslated */
+ odp.ptszTitle=_T("Automatic Shutdown"); /* autotranslated */
+ odp.ptszTab=_T("Automatic Shutdown"); /* autotranslated, can be made a tab */
+ odp.flags=ODPF_BOLDGROUPS|ODPF_EXPERTONLY|ODPF_TCHAR;
+ odp.pfnDlgProc=ShutdownOptDlgProc;
+ CallService(MS_OPT_ADDPAGE,wParam,(LPARAM)&odp);
+ return 0;
+}
+
+/************************* Trigger ************************************/
+
+static int __stdcall ActionProc(DWORD idAction,REPORTINFO *ri,int shutdownType)
+{
+ UNREFERENCED_PARAMETER(ri);
+ if(idAction&ACT_PERFORM) ServiceShutdown(shutdownType,TRUE);
+ return 0;
+}
+#define ActionProcJmp(shutdownType) { return ActionProc(id,ri,shutdownType); }
+
+static int CloseActionProc(DWORD id,REPORTINFO *ri) ActionProcJmp(SDSDT_CLOSEMIRANDA)
+static int SetOfflineActionProc(DWORD id,REPORTINFO *ri) ActionProcJmp(SDSDT_SETMIRANDAOFFLINE)
+static int LogoffActionProc(DWORD id,REPORTINFO *ri) ActionProcJmp(SDSDT_LOGOFF)
+static int RebootActionProc(DWORD id,REPORTINFO *ri) ActionProcJmp(SDSDT_REBOOT)
+static int ShutdownActionProc(DWORD id,REPORTINFO *ri) ActionProcJmp(SDSDT_SHUTDOWN)
+static int StandbyActionProc(DWORD id,REPORTINFO *ri) ActionProcJmp(SDSDT_STANDBY)
+static int HibernateActionProc(DWORD id,REPORTINFO *ri) ActionProcJmp(SDSDT_HIBERNATE)
+static int LockActionProc(DWORD id,REPORTINFO *ri) ActionProcJmp(SDSDT_LOCKWORKSTATION)
+static int HangupActionProc(DWORD id,REPORTINFO *ri) ActionProcJmp(SDSDT_CLOSERASCONNECTIONS)
+
+static int TriggerRegisterActions(WPARAM wParam,LPARAM lParam)
+{
+ UNREFERENCED_PARAMETER(wParam);
+ UNREFERENCED_PARAMETER(lParam);
+ /* new trigger API (0.2.0.69+) */
+ if(ServiceExists(MS_TRIGGER_REGISTERCONDITION)) {
+ ACTIONREGISTER ar;
+ BYTE shutdownType;
+ char *pszDesc,szName[138];
+ ACTIONFUNCTION actionFunctions[SDSDT_MAX]={CloseActionProc,SetOfflineActionProc,LogoffActionProc,
+ RebootActionProc,ShutdownActionProc,StandbyActionProc,
+ HibernateActionProc,LockActionProc,HangupActionProc};
+ ZeroMemory(&ar,sizeof(ar));
+ ar.cbSize=sizeof(ar);
+ ar.flags=ARF_TCHAR|ARF_FUNCTION;
+ ar.pszName=szName;
+ for(shutdownType=1;shutdownType<=SDSDT_MAX;++shutdownType)
+ if(ServiceIsTypeEnabled(shutdownType,0)) {
+ pszDesc=(char*)ServiceGetTypeDescription(shutdownType,GSTDF_UNTRANSLATED);
+ if(pszDesc!=NULL) {
+ mir_snprintf(szName,sizeof(szName),"Shutdown: %s",pszDesc); /* autotranslated */
+ ar.actionFunction=actionFunctions[shutdownType-1];
+ CallService(MS_TRIGGER_REGISTERACTION,0,(LPARAM)&ar);
+ }
+ }
+ }
+ return 0;
+}
+
+/************************* Misc ***************************************/
+
+void InitOptions(void)
+{
+ /* Option Page */
+ hHookOptInit=HookEvent(ME_OPT_INITIALISE,ShutdownOptInit);
+ /* Trigger */
+ hHookModulesLoaded=HookEvent(ME_SYSTEM_MODULESLOADED,TriggerRegisterActions);
+}
+
+void UninitOptions(void)
+{
+ /* Option Page */
+ UnhookEvent(hHookOptInit);
+ /* Trigger */
+ UnhookEvent(hHookModulesLoaded);
+}
diff --git a/plugins/AutoShutdown/options.h b/plugins/AutoShutdown/options.h
new file mode 100644
index 0000000000..8b8e63f04f
--- /dev/null
+++ b/plugins/AutoShutdown/options.h
@@ -0,0 +1,24 @@
+/*
+
+'AutoShutdown'-Plugin for Miranda IM
+
+Copyright 2004-2007 H. Herkenrath
+
+This program is free software; you can redistribute it and/or
+modify it under the terms of the GNU General Public License
+as published by the Free Software Foundation; either version 2
+of the License, or (at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program (Shutdown-License.txt); if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+*/
+
+/* Misc */
+void InitOptions(void);
+void UninitOptions(void);
diff --git a/plugins/AutoShutdown/res/Thumbs.db b/plugins/AutoShutdown/res/Thumbs.db
new file mode 100644
index 0000000000..28fd3e08f0
--- /dev/null
+++ b/plugins/AutoShutdown/res/Thumbs.db
Binary files differ
diff --git a/plugins/AutoShutdown/res/active.ico b/plugins/AutoShutdown/res/active.ico
new file mode 100644
index 0000000000..83d1be2388
--- /dev/null
+++ b/plugins/AutoShutdown/res/active.ico
Binary files differ
diff --git a/plugins/AutoShutdown/res/header.ico b/plugins/AutoShutdown/res/header.ico
new file mode 100644
index 0000000000..4a31e98104
--- /dev/null
+++ b/plugins/AutoShutdown/res/header.ico
Binary files differ
diff --git a/plugins/AutoShutdown/res/inactive.ico b/plugins/AutoShutdown/res/inactive.ico
new file mode 100644
index 0000000000..6c69a4d40a
--- /dev/null
+++ b/plugins/AutoShutdown/res/inactive.ico
Binary files differ
diff --git a/plugins/AutoShutdown/resource.h b/plugins/AutoShutdown/resource.h
new file mode 100644
index 0000000000..4d8370f00a
--- /dev/null
+++ b/plugins/AutoShutdown/resource.h
@@ -0,0 +1,58 @@
+//{{NO_DEPENDENCIES}}
+// Microsoft Developer Studio generated include file.
+// Used by resource.rc
+//
+#define IDI_ACTIVE 101
+#define IDI_INACTIVE 102
+#define IDI_HEADER 103
+#define IDD_SETTINGS 104
+#define IDD_SHUTDOWNNOW 105
+#define IDD_OPT_SHUTDOWN 106
+#define IDC_ICON_HEADER 1001
+#define IDC_TEXT_HEADER 1002
+#define IDC_TEXT_HEADERDESC 1003
+#define IDC_RECT_HEADER 1004
+#define IDC_RADIO_STTIME 1005
+#define IDC_RADIO_STCOUNTDOWN 1006
+#define IDC_CHECK_SPECIFICTIME 1007
+#define IDC_TIME_TIMESTAMP 1008
+#define IDC_DATE_TIMESTAMP 1009
+#define IDC_EDIT_COUNTDOWN 1010
+#define IDC_SPIN_COUNTDOWN 1011
+#define IDC_COMBO_COUNTDOWNUNIT 1012
+#define IDC_COMBO_SHUTDOWNTYPE 1013
+#define IDC_TEXT_SHUTDOWNTYPE 1014
+#define IDC_TEXT_SECONDS 1015
+#define IDC_CHECK_FILETRANSFER 1016
+#define IDC_CHECK_IDLE 1017
+#define IDC_URL_IDLE 1018
+#define IDC_CHECK_MESSAGE 1019
+#define IDC_EDIT_MESSAGE 1020
+#define IDC_CHECK_STATUS 1021
+#define IDC_CHECK_CPUUSAGE 1022
+#define IDC_TEXT_CURRENTCPU 1023
+#define IDC_EDIT_CPUUSAGE 1024
+#define IDC_SPIN_CPUUSAGE 1025
+#define IDC_TEXT_PERCENT 1026
+#define IDC_BUTTON_SHUTDOWNNOW 1027
+#define IDC_TEXT_UNSAVEDWARNING 1028
+#define IDC_CHECK_SHOWCONFIRMDLG 1029
+#define IDC_TEXT_COUNTDOWNSTARTS 1030
+#define IDC_EDIT_CONFIRMDLGCOUNTDOWN 1031
+#define IDC_SPIN_CONFIRMDLGCOUNTDOWN 1032
+#define IDC_CHECK_REMEMBERONRESTART 1033
+#define IDC_CHECK_SMARTOFFLINECHECK 1034
+#define IDC_CHECK_WEATHER 1035
+#define IDC_CHECK_HDDOVERHEAT 1036
+
+// Next default values for new objects
+//
+#ifdef APSTUDIO_INVOKED
+#ifndef APSTUDIO_READONLY_SYMBOLS
+#define _APS_NO_MFC 1
+#define _APS_NEXT_RESOURCE_VALUE 107
+#define _APS_NEXT_COMMAND_VALUE 40001
+#define _APS_NEXT_CONTROL_VALUE 1037
+#define _APS_NEXT_SYMED_VALUE 2001
+#endif
+#endif
diff --git a/plugins/AutoShutdown/resource.rc b/plugins/AutoShutdown/resource.rc
new file mode 100644
index 0000000000..a9bac86713
--- /dev/null
+++ b/plugins/AutoShutdown/resource.rc
@@ -0,0 +1,253 @@
+//Microsoft Developer Studio generated resource script.
+//
+#include "resource.h"
+
+#define APSTUDIO_READONLY_SYMBOLS
+/////////////////////////////////////////////////////////////////////////////
+//
+// Generated from the TEXTINCLUDE 2 resource.
+//
+#include <winres.h>
+#include <m_utils.h>
+
+/////////////////////////////////////////////////////////////////////////////
+#undef APSTUDIO_READONLY_SYMBOLS
+
+/////////////////////////////////////////////////////////////////////////////
+// Englisch (GB) resources
+
+#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENG)
+#ifdef _WIN32
+LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_UK
+#pragma code_page(1252)
+#endif //_WIN32
+
+#ifdef APSTUDIO_INVOKED
+/////////////////////////////////////////////////////////////////////////////
+//
+// TEXTINCLUDE
+//
+
+1 TEXTINCLUDE MOVEABLE PURE
+BEGIN
+ "resource.h\0"
+END
+
+2 TEXTINCLUDE MOVEABLE PURE
+BEGIN
+ "#include <winres.h>\r\n"
+ "#include <m_utils.h>\r\n"
+ "\0"
+END
+
+3 TEXTINCLUDE MOVEABLE PURE
+BEGIN
+ "#include ""version.rc""\r\n"
+ "\0"
+END
+
+#endif // APSTUDIO_INVOKED
+
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// Dialog
+//
+
+IDD_OPT_SHUTDOWN DIALOGEX 0, 0, 201, 190
+STYLE DS_FIXEDSYS | WS_CHILD
+EXSTYLE WS_EX_CONTROLPARENT
+FONT 8, "MS Shell Dlg"
+BEGIN
+ GROUPBOX "Shutdown",IDC_STATIC,3,1,196,45
+ CONTROL "&Show confirmation dialog before shutdown",
+ IDC_CHECK_SHOWCONFIRMDLG,"Button",BS_AUTOCHECKBOX |
+ WS_GROUP | WS_TABSTOP,12,14,182,10
+ LTEXT "&Countdown starts at:",IDC_TEXT_COUNTDOWNSTARTS,24,29,
+ 79,8
+ EDITTEXT IDC_EDIT_CONFIRMDLGCOUNTDOWN,109,27,32,12,ES_AUTOHSCROLL |
+ ES_NUMBER
+ CONTROL "",IDC_SPIN_CONFIRMDLGCOUNTDOWN,"msctls_updown32",
+ UDS_SETBUDDYINT | UDS_ALIGNRIGHT | UDS_AUTOBUDDY |
+ UDS_ARROWKEYS | UDS_NOTHOUSANDS | UDS_HOTTRACK |
+ WS_TABSTOP,137,27,9,11
+ LTEXT "seconds",IDC_TEXT_SECONDS,146,29,48,8,NOT WS_GROUP
+ GROUPBOX "Shutdown Events",IDC_STATIC,3,51,196,66,WS_GROUP
+ CONTROL "&Activate automatic shutdown with the same settings again if Miranda IM was closed with automatic shutdown enabled",
+ IDC_CHECK_REMEMBERONRESTART,"Button",BS_AUTOCHECKBOX |
+ BS_TOP | BS_MULTILINE | WS_TABSTOP,12,64,182,27
+ CONTROL "&Ignore hidden or temporary contacts when watching for all contacts being offline",
+ IDC_CHECK_SMARTOFFLINECHECK,"Button",BS_AUTOCHECKBOX |
+ BS_TOP | BS_MULTILINE | WS_TABSTOP,12,93,182,20
+ GROUPBOX "Critical Shutdown Events",IDC_STATIC,3,123,196,66
+ LTEXT "Automatically shutdown the computer and turn the power off when one of the following occurs:",
+ IDC_STATIC,12,135,182,18,SS_NOPREFIX
+ CONTROL "&Thunderstorm warning is issued (Weather)",
+ IDC_CHECK_WEATHER,"Button",BS_AUTOCHECKBOX | BS_TOP |
+ WS_DISABLED | WS_TABSTOP,12,157,182,11
+ CONTROL "&Harddrive overheats (HDD Info)",IDC_CHECK_HDDOVERHEAT,
+ "Button",BS_AUTOCHECKBOX | WS_DISABLED | WS_TABSTOP,12,
+ 172,182,10
+END
+
+IDD_SETTINGS DIALOGEX 0, 0, 239, 286
+STYLE DS_MODALFRAME | DS_SETFOREGROUND | DS_FIXEDSYS | DS_CENTER |
+ WS_VISIBLE | WS_CAPTION | WS_SYSMENU
+CAPTION "Automatic Shutdown"
+FONT 8, "MS Shell Dlg"
+BEGIN
+ LTEXT "",IDC_RECT_HEADER,0,0,243,25,NOT WS_GROUP
+ ICON "",IDC_ICON_HEADER,7,3,20,20,SS_CENTERIMAGE | WS_GROUP,
+ WS_EX_TRANSPARENT
+ LTEXT "Automatic Shutdown",IDC_TEXT_HEADER,34,4,201,8,
+ SS_NOPREFIX,WS_EX_TRANSPARENT
+ LTEXT "Select the automatic shutdown event",
+ IDC_TEXT_HEADERDESC,43,12,192,8,SS_NOPREFIX,
+ WS_EX_TRANSPARENT
+ CONTROL "",IDC_STATIC,"Static",SS_ETCHEDHORZ,0,25,243,1
+ CONTROL "Shutdown at &specific time",IDC_CHECK_SPECIFICTIME,
+ "Button",BS_AUTOCHECKBOX | WS_GROUP | WS_TABSTOP,13,35,
+ 212,10
+ CONTROL "Shutdown a&t:",IDC_RADIO_STTIME,"Button",
+ BS_AUTORADIOBUTTON | WS_TABSTOP,25,49,68,8
+ CONTROL "",IDC_TIME_TIMESTAMP,"SysDateTimePick32",DTS_UPDOWN |
+ WS_TABSTOP | 0x8,95,47,62,13
+ CONTROL "",IDC_DATE_TIMESTAMP,"SysDateTimePick32",WS_TABSTOP,159,
+ 47,66,13
+ CONTROL "Shutdown i&n:",IDC_RADIO_STCOUNTDOWN,"Button",
+ BS_AUTORADIOBUTTON | WS_TABSTOP,25,64,68,8
+ EDITTEXT IDC_EDIT_COUNTDOWN,95,62,62,13,ES_AUTOHSCROLL |
+ ES_NUMBER
+ CONTROL "",IDC_SPIN_COUNTDOWN,"msctls_updown32",UDS_WRAP |
+ UDS_SETBUDDYINT | UDS_ALIGNRIGHT | UDS_AUTOBUDDY |
+ UDS_ARROWKEYS | UDS_NOTHOUSANDS | UDS_HOTTRACK,146,62,12,
+ 14
+ COMBOBOX IDC_COMBO_COUNTDOWNUNIT,159,62,66,114,CBS_DROPDOWNLIST |
+ WS_VSCROLL | WS_TABSTOP
+ CONTROL "Shutdown when a &message is received containing the following text:",
+ IDC_CHECK_MESSAGE,"Button",BS_AUTOCHECKBOX | BS_TOP |
+ BS_MULTILINE | WS_GROUP | WS_TABSTOP,13,78,211,18
+ EDITTEXT IDC_EDIT_MESSAGE,25,96,199,21,ES_MULTILINE |
+ ES_AUTOVSCROLL | ES_WANTRETURN | WS_VSCROLL
+ CONTROL "Shutdown when Miranda IM becomes &idle",IDC_CHECK_IDLE,
+ "Button",BS_AUTOCHECKBOX | BS_TOP | BS_MULTILINE |
+ WS_GROUP | WS_TABSTOP,13,123,164,9
+ CONTROL "Configure",IDC_URL_IDLE,"Hyperlink",WS_TABSTOP,179,124,
+ 46,9
+ CONTROL "Shutdown when &prozessor usage drops below:",
+ IDC_CHECK_CPUUSAGE,"Button",BS_AUTOCHECKBOX | BS_TOP |
+ BS_MULTILINE | WS_GROUP | WS_TABSTOP,13,139,159,22
+ EDITTEXT IDC_EDIT_CPUUSAGE,179,140,32,13,ES_AUTOHSCROLL |
+ ES_NUMBER
+ CONTROL "",IDC_SPIN_CPUUSAGE,"msctls_updown32",UDS_SETBUDDYINT |
+ UDS_ALIGNRIGHT | UDS_AUTOBUDDY | UDS_ARROWKEYS |
+ UDS_NOTHOUSANDS | UDS_HOTTRACK,205,140,11,14
+ LTEXT "%",IDC_TEXT_PERCENT,215,140,15,13,SS_NOPREFIX |
+ SS_CENTERIMAGE | NOT WS_GROUP
+ LTEXT "(current: 0%)",IDC_TEXT_CURRENTCPU,179,154,60,8,
+ SS_NOPREFIX | NOT WS_GROUP
+ CONTROL "Shutdown when all contacts are &offline",
+ IDC_CHECK_STATUS,"Button",BS_AUTOCHECKBOX | BS_TOP |
+ WS_GROUP | WS_TABSTOP,13,162,211,9
+ CONTROL "Shutdown when all &file transfers are finished",
+ IDC_CHECK_FILETRANSFER,"Button",BS_AUTOCHECKBOX | BS_TOP |
+ WS_GROUP | WS_TABSTOP,13,177,211,10
+ LTEXT "&Action:",IDC_STATIC,15,199,209,8
+ COMBOBOX IDC_COMBO_SHUTDOWNTYPE,14,209,210,103,CBS_DROPDOWNLIST |
+ WS_VSCROLL | WS_TABSTOP
+ LTEXT "",IDC_TEXT_SHUTDOWNTYPE,15,225,208,25,NOT WS_GROUP
+ CONTROL "",IDC_STATIC,"Static",SS_ETCHEDHORZ,0,258,245,1
+ DEFPUSHBUTTON "OK",IDOK,123,266,50,14,WS_GROUP
+ PUSHBUTTON "Cancel",IDCANCEL,179,266,50,14
+END
+
+IDD_SHUTDOWNNOW DIALOGEX 0, 0, 204, 98
+STYLE DS_MODALFRAME | DS_NOIDLEMSG | DS_SETFOREGROUND | DS_FIXEDSYS |
+ DS_NOFAILCREATE | DS_CENTER | WS_POPUP | WS_VISIBLE | WS_CAPTION |
+ WS_SYSMENU
+EXSTYLE WS_EX_TOPMOST
+CAPTION "Automatic Shutdown"
+FONT 8, "MS Shell Dlg"
+BEGIN
+ ICON "",IDC_ICON_HEADER,6,7,20,20,SS_CENTERIMAGE | WS_GROUP,
+ WS_EX_TRANSPARENT
+ LTEXT "",IDC_TEXT_HEADER,34,8,162,18,SS_NOPREFIX | NOT
+ WS_GROUP
+ LTEXT "Unsaved data in open applications except Miranda IM might get lost.",
+ IDC_TEXT_UNSAVEDWARNING,33,31,161,17,SS_NOPREFIX | NOT
+ WS_VISIBLE
+ LTEXT "Please click ""Cancel"" if you would like to abort the process.",
+ IDC_STATIC,33,49,161,17,SS_NOPREFIX
+ PUSHBUTTON "&Now!",IDC_BUTTON_SHUTDOWNNOW,32,75,67,14,WS_GROUP
+ DEFPUSHBUTTON "Cancel",IDCANCEL,103,75,68,14
+END
+
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// DESIGNINFO
+//
+
+#ifdef APSTUDIO_INVOKED
+GUIDELINES DESIGNINFO DISCARDABLE
+BEGIN
+ IDD_OPT_SHUTDOWN, DIALOG
+ BEGIN
+ VERTGUIDE, 3
+ VERTGUIDE, 12
+ VERTGUIDE, 194
+ VERTGUIDE, 199
+ HORZGUIDE, 27
+ HORZGUIDE, 39
+ END
+
+ IDD_SETTINGS, DIALOG
+ BEGIN
+ VERTGUIDE, 13
+ VERTGUIDE, 25
+ VERTGUIDE, 95
+ VERTGUIDE, 159
+ VERTGUIDE, 179
+ VERTGUIDE, 224
+ HORZGUIDE, 266
+ HORZGUIDE, 280
+ END
+
+ IDD_SHUTDOWNNOW, DIALOG
+ BEGIN
+ VERTGUIDE, 34
+ VERTGUIDE, 196
+ HORZGUIDE, 8
+ HORZGUIDE, 31
+ HORZGUIDE, 75
+ HORZGUIDE, 89
+ END
+END
+#endif // APSTUDIO_INVOKED
+
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// Icon
+//
+
+// Icon with lowest ID value placed first to ensure application icon
+// remains consistent on all systems.
+IDI_ACTIVE ICON DISCARDABLE "res/active.ico"
+IDI_HEADER ICON DISCARDABLE "res/header.ico"
+IDI_INACTIVE ICON DISCARDABLE "res/inactive.ico"
+#endif // Englisch (GB) resources
+/////////////////////////////////////////////////////////////////////////////
+
+
+
+#ifndef APSTUDIO_INVOKED
+/////////////////////////////////////////////////////////////////////////////
+//
+// Generated from the TEXTINCLUDE 3 resource.
+//
+#include "version.rc"
+
+/////////////////////////////////////////////////////////////////////////////
+#endif // not APSTUDIO_INVOKED
+
diff --git a/plugins/AutoShutdown/settingsdlg.c b/plugins/AutoShutdown/settingsdlg.c
new file mode 100644
index 0000000000..03f514d61b
--- /dev/null
+++ b/plugins/AutoShutdown/settingsdlg.c
@@ -0,0 +1,512 @@
+/*
+
+'AutoShutdown'-Plugin for Miranda IM
+
+Copyright 2004-2007 H. Herkenrath
+
+This program is free software; you can redistribute it and/or
+modify it under the terms of the GNU General Public License
+as published by the Free Software Foundation; either version 2
+of the License, or (at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program (Shutdown-License.txt); if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+*/
+
+#include "common.h"
+
+/* Menu Item */
+static HANDLE hServiceMenuCommand;
+/* Toolbar Button */
+static HANDLE hHookToolbarLoaded;
+/* Services */
+static HANDLE hServiceShowDlg;
+static HWND hwndSettingsDlg;
+extern HINSTANCE hInst;
+
+/************************* Dialog *************************************/
+
+static void EnableDlgItem(HWND hwndDlg,int idCtrl,BOOL fEnable)
+{
+ hwndDlg=GetDlgItem(hwndDlg,idCtrl);
+ if(hwndDlg!=NULL && IsWindowEnabled(hwndDlg)!=fEnable)
+ EnableWindow(hwndDlg,fEnable);
+}
+
+static BOOL CALLBACK DisplayCpuUsageProc(BYTE nCpuUsage,LPARAM lParam)
+{
+ TCHAR str[64];
+ /* dialog closed? */
+ if(!IsWindow((HWND)lParam)) return FALSE; /* stop poll thread */
+ mir_sntprintf(str,SIZEOF(str),TranslateT("(current: %u%%)"),nCpuUsage);
+ SetWindowText((HWND)lParam,str);
+ return TRUE;
+}
+
+static BOOL AnyProtoHasCaps(DWORD caps1)
+{
+ int nProtoCount,i;
+ PROTOCOLDESCRIPTOR **protos;
+ if(!CallService(MS_PROTO_ENUMPROTOCOLS,(WPARAM)&nProtoCount,(LPARAM)&protos))
+ for(i=0;i<nProtoCount;++i)
+ if(protos[i]->type==PROTOTYPE_PROTOCOL)
+ if(CallProtoService(protos[i]->szName,PS_GETCAPS,(WPARAM)PFLAGNUM_1,0)&caps1)
+ return TRUE; /* CALLSERVICE_NOTFOUND also handled gracefully */
+ return FALSE;
+}
+
+#define M_ENABLE_SUBCTLS (WM_APP+111)
+#define M_UPDATE_SHUTDOWNDESC (WM_APP+112)
+#define M_CHECK_DATETIME (WM_APP+113)
+static BOOL CALLBACK SettingsDlgProc(HWND hwndDlg,UINT msg,WPARAM wParam,LPARAM lParam)
+{
+ switch(msg) {
+ case WM_INITDIALOG:
+ { LCID locale;
+ hwndSettingsDlg=hwndDlg;
+ TranslateDialogDefault(hwndDlg);
+ locale=CallService(MS_LANGPACK_GETLOCALE,0,0);
+ SendDlgItemMessage(hwndDlg,IDC_ICON_HEADER,STM_SETIMAGE,IMAGE_ICON,(LPARAM)IcoLib_GetIcon("AutoShutdown_Header"));
+ { HFONT hBoldFont;
+ LOGFONT lf;
+ if(GetObject((HFONT)SendDlgItemMessage(hwndDlg,IDC_TEXT_HEADER,WM_GETFONT,0,0),sizeof(lf),&lf)) {
+ lf.lfWeight=FW_BOLD;
+ hBoldFont=CreateFontIndirect(&lf);
+ } else hBoldFont=NULL;
+ SendDlgItemMessage(hwndDlg,IDC_TEXT_HEADER,WM_SETFONT,(WPARAM)hBoldFont,FALSE);
+ }
+ /* read-in watcher flags */
+ { WORD watcherType;
+ watcherType=DBGetContactSettingWord(NULL,"AutoShutdown","WatcherFlags",SETTING_WATCHERFLAGS_DEFAULT);
+ CheckRadioButton(hwndDlg,IDC_RADIO_STTIME,IDC_RADIO_STCOUNTDOWN,(watcherType&SDWTF_ST_TIME)?IDC_RADIO_STTIME:IDC_RADIO_STCOUNTDOWN);
+ CheckDlgButton(hwndDlg,IDC_CHECK_SPECIFICTIME,(watcherType&SDWTF_SPECIFICTIME)!=0);
+ CheckDlgButton(hwndDlg,IDC_CHECK_MESSAGE,(watcherType&SDWTF_MESSAGE)!=0);
+ CheckDlgButton(hwndDlg,IDC_CHECK_FILETRANSFER,(watcherType&SDWTF_FILETRANSFER)!=0);
+ CheckDlgButton(hwndDlg,IDC_CHECK_IDLE,(watcherType&SDWTF_IDLE)!=0);
+ CheckDlgButton(hwndDlg,IDC_CHECK_STATUS,(watcherType&SDWTF_STATUS)!=0);
+ CheckDlgButton(hwndDlg,IDC_CHECK_CPUUSAGE,(watcherType&SDWTF_CPUUSAGE)!=0);
+ }
+ /* read-in countdown val */
+ { SYSTEMTIME st;
+ if(!TimeStampToSystemTime((time_t)DBGetContactSettingDword(NULL,"AutoShutdown","TimeStamp",SETTING_TIMESTAMP_DEFAULT),&st))
+ GetLocalTime(&st);
+ DateTime_SetSystemtime(GetDlgItem(hwndDlg,IDC_TIME_TIMESTAMP),GDT_VALID,&st);
+ DateTime_SetSystemtime(GetDlgItem(hwndDlg,IDC_DATE_TIMESTAMP),GDT_VALID,&st);
+ SendMessage(hwndDlg,M_CHECK_DATETIME,0,0);
+ }
+ { DWORD setting;
+ setting=DBGetContactSettingDword(NULL,"AutoShutdown","Countdown",SETTING_COUNTDOWN_DEFAULT);
+ if(setting<1) setting=SETTING_COUNTDOWN_DEFAULT;
+ SendDlgItemMessage(hwndDlg,IDC_SPIN_COUNTDOWN,UDM_SETRANGE,0,MAKELPARAM(UD_MAXVAL,1));
+ SendDlgItemMessage(hwndDlg,IDC_EDIT_COUNTDOWN,EM_SETLIMITTEXT,(WPARAM)10,0);
+ SendDlgItemMessage(hwndDlg,IDC_SPIN_COUNTDOWN,UDM_SETPOS,0,MAKELPARAM(setting,0));
+ SetDlgItemInt(hwndDlg,IDC_EDIT_COUNTDOWN,setting,FALSE);
+ }
+ { HWND hwndCombo;
+ DWORD lastUnit;
+ int i,index;
+ const DWORD unitValues[]={1,60,60*60,60*60*24,60*60*24*7,60*60*24*31};
+ const TCHAR *unitNames[]={_T("Second(s)"),_T("Minute(s)"),_T("Hour(s)"),
+ _T("Day(s)"),_T("Week(s)"),_T("Month(s)")};
+ hwndCombo=GetDlgItem(hwndDlg,IDC_COMBO_COUNTDOWNUNIT);
+ lastUnit=DBGetContactSettingDword(NULL,"AutoShutdown","CountdownUnit",SETTING_COUNTDOWNUNIT_DEFAULT);
+ SendMessage(hwndCombo,CB_SETLOCALE,(WPARAM)locale,0); /* sort order */
+ SendMessage(hwndCombo,CB_INITSTORAGE,SIZEOF(unitNames),SIZEOF(unitNames)*16); /* approx. */
+ for(i=0;i<SIZEOF(unitNames);++i) {
+ index=SendMessage(hwndCombo,CB_ADDSTRING,0,(LPARAM)TranslateTS(unitNames[i]));
+ if(index!=LB_ERR) {
+ SendMessage(hwndCombo,CB_SETITEMDATA,index,(LPARAM)unitValues[i]);
+ if(i==0 || unitValues[i]==lastUnit) SendMessage(hwndCombo,CB_SETCURSEL,index,0);
+ }
+ }
+ }
+ { DBVARIANT dbv;
+ if(!DBGetContactSettingTString(NULL,"AutoShutdown","Message",&dbv)) {
+ SetDlgItemText(hwndDlg,IDC_EDIT_MESSAGE,dbv.ptszVal);
+ mir_free(dbv.ptszVal);
+ }
+ if(ServiceExists(MS_AUTOREPLACER_ADDWINHANDLE))
+ CallService(MS_AUTOREPLACER_ADDWINHANDLE,0,(LPARAM)GetDlgItem(hwndDlg,IDC_EDIT_MESSAGE));
+ }
+ /* cpuusage threshold */
+ { BYTE setting;
+ setting=DBGetContactSettingRangedByte(NULL,"AutoShutdown","CpuUsageThreshold",SETTING_CPUUSAGETHRESHOLD_DEFAULT,1,100);
+ SendDlgItemMessage(hwndDlg,IDC_SPIN_CPUUSAGE,UDM_SETRANGE,0,MAKELPARAM(100,1));
+ SendDlgItemMessage(hwndDlg,IDC_EDIT_CPUUSAGE,EM_SETLIMITTEXT,(WPARAM)3,0);
+ SendDlgItemMessage(hwndDlg,IDC_SPIN_CPUUSAGE,UDM_SETPOS,0,MAKELPARAM(setting,0));
+ SetDlgItemInt(hwndDlg,IDC_EDIT_CPUUSAGE,setting,FALSE);
+ }
+ /* shutdown types */
+ { HWND hwndCombo;
+ BYTE lastShutdownType;
+ BYTE shutdownType;
+ int index;
+ TCHAR *pszText;
+ hwndCombo=GetDlgItem(hwndDlg,IDC_COMBO_SHUTDOWNTYPE);
+ lastShutdownType=DBGetContactSettingByte(NULL,"AutoShutdown","ShutdownType",SETTING_SHUTDOWNTYPE_DEFAULT);
+ SendMessage(hwndCombo,CB_SETLOCALE,(WPARAM)locale,0); /* sort order */
+ SendMessage(hwndCombo,CB_SETEXTENDEDUI,TRUE,0);
+ SendMessage(hwndCombo,CB_INITSTORAGE,SDSDT_MAX,SDSDT_MAX*32);
+ for(shutdownType=1;shutdownType<=SDSDT_MAX;++shutdownType)
+ if(ServiceIsTypeEnabled(shutdownType,0)) {
+ pszText=(TCHAR*)ServiceGetTypeDescription(shutdownType,GSTDF_TCHAR); /* never fails */
+ index=SendMessage(hwndCombo,CB_ADDSTRING,0,(LPARAM)pszText);
+ if(index!=LB_ERR) {
+ SendMessage(hwndCombo,CB_SETITEMDATA,index,(LPARAM)shutdownType);
+ if(shutdownType==1 || shutdownType==lastShutdownType) SendMessage(hwndCombo,CB_SETCURSEL,(WPARAM)index,0);
+ }
+ }
+ SendMessage(hwndDlg,M_UPDATE_SHUTDOWNDESC,0,(LPARAM)hwndCombo);
+ }
+ /* check if proto is installed that supports instant messages and check if a message dialog plugin is installed */
+ if(!AnyProtoHasCaps(PF1_IMRECV) || !ServiceExists(MS_MSG_SENDMESSAGE)) { /* no srmessage present? */
+ CheckDlgButton(hwndDlg,IDC_CHECK_MESSAGE,FALSE);
+ EnableWindow(GetDlgItem(hwndDlg,IDC_CHECK_MESSAGE),FALSE);
+ EnableWindow(GetDlgItem(hwndDlg,IDC_EDIT_MESSAGE),FALSE);
+ }
+ /* check if proto is installed that supports file transfers and check if a file transfer dialog is available */
+ if((!AnyProtoHasCaps(PF1_FILESEND) && !AnyProtoHasCaps(PF1_FILERECV)) || !ServiceExists(MS_FILE_SENDFILE)) { /* no srfile present? */
+ CheckDlgButton(hwndDlg,IDC_CHECK_FILETRANSFER,FALSE);
+ EnableWindow(GetDlgItem(hwndDlg,IDC_CHECK_FILETRANSFER),FALSE);
+ }
+ /* check if cpu usage can be detected */
+ if(!PollCpuUsage(DisplayCpuUsageProc,(LPARAM)GetDlgItem(hwndDlg,IDC_TEXT_CURRENTCPU),1800)) {
+ CheckDlgButton(hwndDlg,IDC_CHECK_CPUUSAGE,FALSE);
+ EnableWindow(GetDlgItem(hwndDlg,IDC_CHECK_CPUUSAGE),FALSE);
+ }
+ SendMessage(hwndDlg,M_ENABLE_SUBCTLS,0,0);
+ MagneticWindows_AddWindow(hwndDlg);
+ Utils_RestoreWindowPositionNoSize(hwndDlg,NULL,"AutoShutdown","SettingsDlg_");
+ return TRUE; /* default focus */
+ }
+ case WM_DESTROY:
+ { HICON hIcon;
+ HFONT hFont;
+ if(ServiceExists(MS_AUTOREPLACER_ADDWINHANDLE))
+ CallService(MS_AUTOREPLACER_REMWINHANDLE,0,(LPARAM)GetDlgItem(hwndDlg,IDC_EDIT_MESSAGE));
+ Utils_SaveWindowPosition(hwndDlg,NULL,"AutoShutdown","SettingsDlg_");
+ MagneticWindows_RemoveWindow(hwndDlg);
+ hIcon=(HICON)SendDlgItemMessage(hwndDlg,IDC_ICON_HEADER,STM_SETIMAGE,IMAGE_ICON,(LPARAM)NULL);
+ IcoLib_ReleaseIcon(hIcon); /* does NULL check */
+ hFont=(HFONT)SendDlgItemMessage(hwndDlg,IDC_TEXT_HEADER,WM_GETFONT,0,0);
+ SendDlgItemMessage(hwndDlg,IDC_TEXT_HEADER,WM_SETFONT,(WPARAM)NULL,FALSE); /* no return value */
+ if(hFont!=NULL) DeleteObject(hFont);
+ hwndSettingsDlg=NULL;
+ return TRUE;
+ }
+ case WM_CTLCOLORSTATIC:
+ switch(GetDlgCtrlID((HWND)lParam)) {
+ case IDC_ICON_HEADER:
+ SetBkMode((HDC)wParam,TRANSPARENT);
+ case IDC_RECT_HEADER:
+ /* need to set COLOR_WINDOW manually for Win9x */
+ SetBkColor((HDC)wParam,GetSysColor(COLOR_WINDOW));
+ return (BOOL)GetSysColorBrush(COLOR_WINDOW);
+ case IDC_TEXT_HEADER:
+ case IDC_TEXT_HEADERDESC:
+ SetBkMode((HDC)wParam,TRANSPARENT);
+ return (BOOL)GetStockObject(NULL_BRUSH);
+ }
+ break;
+ case M_ENABLE_SUBCTLS:
+ { BOOL checked=IsDlgButtonChecked(hwndDlg,IDC_CHECK_MESSAGE)!=0;
+ EnableDlgItem(hwndDlg,IDC_EDIT_MESSAGE,checked);
+ checked=IsDlgButtonChecked(hwndDlg,IDC_CHECK_SPECIFICTIME)!=0;
+ EnableDlgItem(hwndDlg,IDC_RADIO_STTIME,checked);
+ EnableDlgItem(hwndDlg,IDC_RADIO_STCOUNTDOWN,checked);
+ checked=(IsDlgButtonChecked(hwndDlg,IDC_CHECK_SPECIFICTIME) && IsDlgButtonChecked(hwndDlg,IDC_RADIO_STTIME));
+ EnableDlgItem(hwndDlg,IDC_TIME_TIMESTAMP,checked);
+ EnableDlgItem(hwndDlg,IDC_DATE_TIMESTAMP,checked);
+ checked=(IsDlgButtonChecked(hwndDlg,IDC_CHECK_SPECIFICTIME) && IsDlgButtonChecked(hwndDlg,IDC_RADIO_STCOUNTDOWN));
+ EnableDlgItem(hwndDlg,IDC_EDIT_COUNTDOWN,checked);
+ EnableDlgItem(hwndDlg,IDC_SPIN_COUNTDOWN,checked);
+ EnableDlgItem(hwndDlg,IDC_COMBO_COUNTDOWNUNIT,checked);
+ checked=IsDlgButtonChecked(hwndDlg,IDC_CHECK_IDLE)!=0;
+ EnableDlgItem(hwndDlg,IDC_URL_IDLE,checked);
+ checked=IsDlgButtonChecked(hwndDlg,IDC_CHECK_CPUUSAGE)!=0;
+ EnableDlgItem(hwndDlg,IDC_EDIT_CPUUSAGE,checked);
+ EnableDlgItem(hwndDlg,IDC_SPIN_CPUUSAGE,checked);
+ EnableDlgItem(hwndDlg,IDC_TEXT_PERCENT,checked);
+ EnableDlgItem(hwndDlg,IDC_TEXT_CURRENTCPU,checked);
+ checked=(IsDlgButtonChecked(hwndDlg,IDC_CHECK_SPECIFICTIME) || IsDlgButtonChecked(hwndDlg,IDC_CHECK_MESSAGE) ||
+ IsDlgButtonChecked(hwndDlg,IDC_CHECK_IDLE) || IsDlgButtonChecked(hwndDlg,IDC_CHECK_STATUS) ||
+ IsDlgButtonChecked(hwndDlg,IDC_CHECK_FILETRANSFER) || IsDlgButtonChecked(hwndDlg,IDC_CHECK_CPUUSAGE));
+ EnableDlgItem(hwndDlg,IDOK,checked);
+ }
+ return TRUE;
+ case M_UPDATE_SHUTDOWNDESC: /* lParam=(LPARAM)(HWND)hwndCombo */
+ { BYTE shutdownType;
+ shutdownType=(BYTE)SendMessage((HWND)lParam,CB_GETITEMDATA,SendMessage((HWND)lParam,CB_GETCURSEL,0,0),0);
+ SetDlgItemText(hwndDlg,IDC_TEXT_SHUTDOWNTYPE,(TCHAR*)ServiceGetTypeDescription(shutdownType,GSTDF_LONGDESC|GSTDF_TCHAR));
+ return TRUE;
+ }
+ case WM_TIMECHANGE: /* system time changed */
+ SendMessage(hwndDlg,M_CHECK_DATETIME,0,0);
+ return TRUE;
+ case M_CHECK_DATETIME:
+ { SYSTEMTIME st,stBuf;
+ time_t timestamp;
+ DateTime_GetSystemtime(GetDlgItem(hwndDlg,IDC_DATE_TIMESTAMP),&stBuf);
+ DateTime_GetSystemtime(GetDlgItem(hwndDlg,IDC_TIME_TIMESTAMP),&st);
+ st.wDay=stBuf.wDay;
+ st.wDayOfWeek=stBuf.wDayOfWeek;
+ st.wMonth=stBuf.wMonth;
+ st.wYear=stBuf.wYear;
+ GetLocalTime(&stBuf);
+ if(SystemTimeToTimeStamp(&st,&timestamp)) {
+ /* set to current date if earlier */
+ if(timestamp<time(NULL)) {
+ st.wDay=stBuf.wDay;
+ st.wDayOfWeek=stBuf.wDayOfWeek;
+ st.wMonth=stBuf.wMonth;
+ st.wYear=stBuf.wYear;
+ if(SystemTimeToTimeStamp(&st,&timestamp)) {
+ /* step one day up if still earlier */
+ if(timestamp<time(NULL)) {
+ timestamp+=24*60*60;
+ TimeStampToSystemTime(timestamp,&st);
+ }
+ }
+ }
+ }
+ DateTime_SetRange(GetDlgItem(hwndDlg,IDC_DATE_TIMESTAMP),GDTR_MIN,&stBuf);
+ DateTime_SetRange(GetDlgItem(hwndDlg,IDC_TIME_TIMESTAMP),GDTR_MIN,&stBuf);
+ DateTime_SetSystemtime(GetDlgItem(hwndDlg,IDC_DATE_TIMESTAMP),GDT_VALID,&st);
+ DateTime_SetSystemtime(GetDlgItem(hwndDlg,IDC_TIME_TIMESTAMP),GDT_VALID,&st);
+ return TRUE;
+ }
+ case WM_NOTIFY:
+ switch(((NMHDR*)lParam)->idFrom) {
+ case IDC_TIME_TIMESTAMP:
+ case IDC_DATE_TIMESTAMP:
+ switch(((NMHDR*)lParam)->code) {
+ case DTN_CLOSEUP:
+ case NM_KILLFOCUS:
+ PostMessage(hwndDlg,M_CHECK_DATETIME,0,0);
+ return TRUE;
+ }
+ }
+ break;
+ case WM_COMMAND:
+ switch(LOWORD(wParam)) {
+ case IDC_CHECK_MESSAGE:
+ case IDC_CHECK_FILETRANSFER:
+ case IDC_CHECK_IDLE:
+ case IDC_CHECK_CPUUSAGE:
+ case IDC_CHECK_STATUS:
+ case IDC_CHECK_SPECIFICTIME:
+ case IDC_RADIO_STTIME:
+ case IDC_RADIO_STCOUNTDOWN:
+ SendMessage(hwndDlg,M_ENABLE_SUBCTLS,0,0);
+ return TRUE;
+ case IDC_EDIT_COUNTDOWN:
+ if(HIWORD(wParam)==EN_KILLFOCUS) {
+ if((int)GetDlgItemInt(hwndDlg,IDC_EDIT_COUNTDOWN,NULL,TRUE)<1) {
+ SendDlgItemMessage(hwndDlg,IDC_SPIN_COUNTDOWN,UDM_SETPOS,0,MAKELPARAM(1,0));
+ SetDlgItemInt(hwndDlg,IDC_EDIT_COUNTDOWN,1,FALSE);
+ }
+ return TRUE;
+ }
+ break;
+ case IDC_EDIT_CPUUSAGE:
+ if(HIWORD(wParam)==EN_KILLFOCUS) {
+ WORD val;
+ val=(WORD)GetDlgItemInt(hwndDlg,IDC_EDIT_CPUUSAGE,NULL,FALSE);
+ if(val<1) val=1;
+ else if(val>100) val=100;
+ SendDlgItemMessage(hwndDlg,IDC_SPIN_CPUUSAGE,UDM_SETPOS,0,MAKELPARAM(val,0));
+ SetDlgItemInt(hwndDlg,IDC_EDIT_CPUUSAGE,val,FALSE);
+ return TRUE;
+ }
+ break;
+ case IDC_URL_IDLE:
+ { OPENOPTIONSDIALOG ood;
+ ood.cbSize=sizeof(ood);
+ ood.pszGroup="Status"; /* autotranslated */
+ ood.pszPage="Idle"; /* autotranslated */
+ ood.pszTab=NULL;
+ CallService(MS_OPT_OPENOPTIONS,0,(LPARAM)&ood);
+ return TRUE;
+ }
+ case IDC_COMBO_SHUTDOWNTYPE:
+ if(HIWORD(wParam)==CBN_SELCHANGE)
+ SendMessage(hwndDlg,M_UPDATE_SHUTDOWNDESC,0,lParam);
+ return TRUE;
+ case IDOK: /* save settings and start watcher */
+ ShowWindow(hwndDlg,SW_HIDE);
+ /* message text */
+ { HWND hwndEdit=GetDlgItem(hwndDlg,IDC_EDIT_MESSAGE);
+ int len=GetWindowTextLength(hwndEdit)+1;
+ TCHAR *pszText=(TCHAR*)mir_alloc(len*sizeof(TCHAR));
+ if(pszText!=NULL && GetWindowText(hwndEdit,pszText,len+1)) {
+ TrimString(pszText);
+ DBWriteContactSettingTString(NULL,"AutoShutdown","Message",pszText);
+ }
+ mir_free(pszText); /* does NULL check */
+ }
+ /* timestamp */
+ { SYSTEMTIME st;
+ time_t timestamp;
+ DateTime_GetSystemtime(GetDlgItem(hwndDlg,IDC_TIME_TIMESTAMP),&st); /* time gets synchronized */
+ if(!SystemTimeToTimeStamp(&st,&timestamp))
+ timestamp=time(NULL);
+ DBWriteContactSettingDword(NULL,"AutoShutdown","TimeStamp",(DWORD)timestamp);
+ }
+ /* shutdown type */
+ { int index;
+ index=SendDlgItemMessage(hwndDlg,IDC_COMBO_SHUTDOWNTYPE,CB_GETCURSEL,0,0);
+ if(index!=LB_ERR) DBWriteContactSettingByte(NULL,"AutoShutdown","ShutdownType",(BYTE)SendDlgItemMessage(hwndDlg,IDC_COMBO_SHUTDOWNTYPE,CB_GETITEMDATA,(WPARAM)index,0));
+ index=SendDlgItemMessage(hwndDlg,IDC_COMBO_COUNTDOWNUNIT,CB_GETCURSEL,0,0);
+ if(index!=LB_ERR) DBWriteContactSettingDword(NULL,"AutoShutdown","CountdownUnit",(DWORD)SendDlgItemMessage(hwndDlg,IDC_COMBO_COUNTDOWNUNIT,CB_GETITEMDATA,(WPARAM)index,0));
+ DBWriteContactSettingDword(NULL,"AutoShutdown","Countdown",(DWORD)GetDlgItemInt(hwndDlg,IDC_EDIT_COUNTDOWN,NULL,FALSE));
+ DBWriteContactSettingByte(NULL,"AutoShutdown","CpuUsageThreshold",(BYTE)GetDlgItemInt(hwndDlg,IDC_EDIT_CPUUSAGE,NULL,FALSE));
+ }
+ /* watcher type */
+ { WORD watcherType;
+ watcherType=(WORD)(IsDlgButtonChecked(hwndDlg,IDC_RADIO_STTIME)?SDWTF_ST_TIME:SDWTF_ST_COUNTDOWN);
+ if(IsDlgButtonChecked(hwndDlg,IDC_CHECK_SPECIFICTIME)) watcherType|=SDWTF_SPECIFICTIME;
+ if(IsDlgButtonChecked(hwndDlg,IDC_CHECK_MESSAGE)) watcherType|=SDWTF_MESSAGE;
+ if(IsDlgButtonChecked(hwndDlg,IDC_CHECK_FILETRANSFER)) watcherType|=SDWTF_FILETRANSFER;
+ if(IsDlgButtonChecked(hwndDlg,IDC_CHECK_IDLE)) watcherType|=SDWTF_IDLE;
+ if(IsDlgButtonChecked(hwndDlg,IDC_CHECK_STATUS)) watcherType|=SDWTF_STATUS;
+ if(IsDlgButtonChecked(hwndDlg,IDC_CHECK_CPUUSAGE)) watcherType|=SDWTF_CPUUSAGE;
+ DBWriteContactSettingWord(NULL,"AutoShutdown","WatcherFlags",watcherType);
+ ServiceStartWatcher(0,watcherType);
+ }
+ /* fall through */
+ case IDCANCEL: /* WM_CLOSE */
+ DestroyWindow(hwndDlg);
+ return TRUE;
+ }
+ break;
+ }
+ CallSnappingWindowProc(hwndDlg,msg,wParam,lParam); /* Snapping Windows plugin */
+ return FALSE;
+}
+
+/************************* Services ***********************************/
+
+static int ServiceShowSettingsDialog(WPARAM wParam,LPARAM lParam)
+{
+ UNREFERENCED_PARAMETER(wParam);
+ UNREFERENCED_PARAMETER(lParam);
+ if(hwndSettingsDlg!=NULL) { /* already opened, bring to front */
+ SetForegroundWindow(hwndSettingsDlg);
+ return 0;
+ }
+ return (CreateDialog(hInst,MAKEINTRESOURCE(IDD_SETTINGS),NULL,SettingsDlgProc)==NULL);
+}
+
+/************************* Toolbar ************************************/
+
+static WORD hToolbarButton;
+
+static int ToolbarLoaded(WPARAM wParam,LPARAM lParam)
+{
+ TTBButtonV2 ttbb;
+ UNREFERENCED_PARAMETER(wParam);
+ UNREFERENCED_PARAMETER(lParam);
+
+ ZeroMemory(&ttbb,sizeof(ttbb));
+ ttbb.cbSize=sizeof(ttbb);
+ /* toptoolbar offers icolib support */
+ ttbb.hIconUp=(HICON)LoadImage(hInst,MAKEINTRESOURCE(IDI_ACTIVE),IMAGE_ICON,0,0,0);
+ ttbb.hIconDn=(HICON)LoadImage(hInst,MAKEINTRESOURCE(IDI_INACTIVE),IMAGE_ICON,0,0,0);
+ ttbb.pszServiceUp=ttbb.pszServiceDown="AutoShutdown/MenuCommand";
+ ttbb.dwFlags=TTBBF_VISIBLE|TTBBF_SHOWTOOLTIP;
+ ttbb.name=Translate("Start/Stop automatic shutdown");
+
+ hToolbarButton=(WORD)CallService(MS_TTB_ADDBUTTON,(WPARAM)&ttbb,0);
+ if(ttbb.hIconUp!=NULL) DestroyIcon(ttbb.hIconUp);
+ if(ttbb.hIconDn!=NULL) DestroyIcon(ttbb.hIconDn);
+ return 0;
+}
+
+void SetShutdownToolbarButton(BOOL fActive)
+{
+ if(hToolbarButton) {
+ CallService(MS_TTB_SETBUTTONSTATE,hToolbarButton,fActive?TTBST_PUSHED:TTBST_RELEASED);
+ CallService(MS_TTB_SETBUTTONOPTIONS,MAKEWPARAM(TTBO_TIPNAME,hToolbarButton),(LPARAM)(fActive?Translate("Sdop automatic shutdown"):Translate("Start automatic shutdown")));
+ }
+}
+
+/************************* Menu Item **********************************/
+
+static HANDLE hMainMenuItem,hTrayMenuItem;
+extern HANDLE hActiveIcon,hInactiveIcon;
+
+void SetShutdownMenuItem(BOOL fActive)
+{
+ CLISTMENUITEM cmi;
+ ZeroMemory(&cmi,sizeof(cmi));
+ cmi.cbSize=sizeof(cmi);
+
+ /* main menu */
+ cmi.position=2001090000;
+ cmi.icolibItem=fActive?hActiveIcon:hInactiveIcon;
+ cmi.ptszName=fActive?_T("Stop automatic &shutdown"):_T("Automatic &shutdown..."); /* autotranslated */
+ cmi.pszService="AutoShutdown/MenuCommand";
+ cmi.flags=CMIF_TCHAR|CMIF_ICONFROMICOLIB;
+ if(hMainMenuItem!=NULL) {
+ cmi.flags|=CMIM_NAME|CMIM_ICON;
+ CallService(MS_CLIST_MODIFYMENUITEM,(WPARAM)hMainMenuItem,(LPARAM)&cmi);
+ }
+ else hMainMenuItem=(HANDLE)CallService(MS_CLIST_ADDMAINMENUITEM,0,(LPARAM)&cmi);
+
+ /* tray menu */
+ cmi.position=899999;
+ if(hTrayMenuItem!=NULL) {
+ cmi.flags|=CMIM_NAME|CMIM_ICON;
+ CallService(MS_CLIST_MODIFYMENUITEM,(WPARAM)hTrayMenuItem,(LPARAM)&cmi);
+ }
+ else hTrayMenuItem=(HANDLE)CallService(MS_CLIST_ADDTRAYMENUITEM,0,(LPARAM)&cmi);
+
+ IcoLib_ReleaseIcon(cmi.hIcon);
+}
+
+static int MenuItemCommand(WPARAM wParam,LPARAM lParam)
+{
+ UNREFERENCED_PARAMETER(wParam);
+ UNREFERENCED_PARAMETER(lParam);
+ /* toggle between StopWatcher and ShowSettingsDdialog */
+ if(ServiceIsWatcherEnabled(0,0))
+ ServiceStopWatcher(0,0);
+ else
+ ServiceShowSettingsDialog(0,0);
+ return 0;
+}
+
+/************************* Misc ***************************************/
+
+void InitSettingsDlg(void)
+{
+ /* Menu Item */
+ hServiceMenuCommand=CreateServiceFunction("AutoShutdown/MenuCommand",MenuItemCommand);
+ hMainMenuItem=hTrayMenuItem=NULL;
+ SetShutdownMenuItem(FALSE);
+ /* Toolbar Item */
+ hToolbarButton=0;
+ hHookToolbarLoaded=HookEvent(ME_TTB_MODULELOADED,ToolbarLoaded); /* no service to check for */
+ /* Hotkey */
+ SkinAddNewHotkey("AutoShutdown_Toggle",Translate("Main"),Translate("Toggle Automatic Shutdown"),'T',HOTKEYF_CONTROL|HOTKEYF_SHIFT,"AutoShutdown/MenuCommand");
+ /* Services */
+ hwndSettingsDlg=NULL;
+ hServiceShowDlg=CreateServiceFunction(MS_AUTOSHUTDOWN_SHOWSETTINGSDIALOG,ServiceShowSettingsDialog);
+}
+
+void UninitSettingsDlg(void)
+{
+ /* Toolbar Item */
+ UnhookEvent(hHookToolbarLoaded);
+ /* Menu Item */
+ DestroyServiceFunction(hServiceMenuCommand);
+ /* Services */
+ DestroyServiceFunction(hServiceShowDlg);
+}
+
diff --git a/plugins/AutoShutdown/settingsdlg.h b/plugins/AutoShutdown/settingsdlg.h
new file mode 100644
index 0000000000..2f7bf8ea84
--- /dev/null
+++ b/plugins/AutoShutdown/settingsdlg.h
@@ -0,0 +1,30 @@
+/*
+
+'AutoShutdown'-Plugin for Miranda IM
+
+Copyright 2004-2007 H. Herkenrath
+
+This program is free software; you can redistribute it and/or
+modify it under the terms of the GNU General Public License
+as published by the Free Software Foundation; either version 2
+of the License, or (at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program (Shutdown-License.txt); if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+*/
+
+/* Menu Item */
+void SetShutdownMenuItem(BOOL fActive);
+
+/* Toolbar Button */
+void SetShutdownToolbarButton(BOOL fActive);
+
+/* Misc */
+void InitSettingsDlg(void);
+void UninitSettingsDlg(void);
diff --git a/plugins/AutoShutdown/shutdown.def b/plugins/AutoShutdown/shutdown.def
new file mode 100644
index 0000000000..09d13e6c16
--- /dev/null
+++ b/plugins/AutoShutdown/shutdown.def
@@ -0,0 +1,11 @@
+LIBRARY shutdown BASE=0x11070000
+SECTIONS
+ ; obfuscated email address
+ .rdata READ WRITE
+EXPORTS
+ MirandaPluginInfo PRIVATE
+ Load PRIVATE
+ Unload PRIVATE
+ ; v0.8 support
+ MirandaPluginInfoEx PRIVATE
+ MirandaPluginInterfaces PRIVATE
diff --git a/plugins/AutoShutdown/shutdown.dep b/plugins/AutoShutdown/shutdown.dep
new file mode 100644
index 0000000000..ec15869669
--- /dev/null
+++ b/plugins/AutoShutdown/shutdown.dep
@@ -0,0 +1,394 @@
+# Microsoft Developer Studio erstellte Abhängigkeitsdatei, einbezogen von shutdown.mak
+
+.\cpuusage.c : \
+ ".\common.h"\
+ ".\cpuusage.h"\
+ ".\frame.h"\
+ ".\include\m_autoreplacer.h"\
+ ".\include\m_button.h"\
+ ".\include\m_clc.h"\
+ ".\include\m_clist.h"\
+ ".\include\m_clistint.h"\
+ ".\include\m_clui.h"\
+ ".\include\m_cluiframes.h"\
+ ".\include\m_database.h"\
+ ".\include\m_file.h"\
+ ".\include\m_fontservice.h"\
+ ".\include\m_genmenu.h"\
+ ".\include\m_hddinfo.h"\
+ ".\include\m_hotkey.h"\
+ ".\include\m_hotkeysplus.h"\
+ ".\include\m_hotkeysservice.h"\
+ ".\include\m_icolib.h"\
+ ".\include\m_idle.h"\
+ ".\include\m_langpack.h"\
+ ".\include\m_magneticwindows.h"\
+ ".\include\m_message.h"\
+ ".\include\m_mwclc.h"\
+ ".\include\m_options.h"\
+ ".\include\m_plugins.h"\
+ ".\include\m_protocols.h"\
+ ".\include\m_protosvc.h"\
+ ".\include\m_skin.h"\
+ ".\include\m_snappingwindows.h"\
+ ".\include\m_system.h"\
+ ".\include\m_toptoolbar.h"\
+ ".\include\m_trigger.h"\
+ ".\include\m_utils.h"\
+ ".\include\m_weather.h"\
+ ".\include\newpluginapi.h"\
+ ".\include\statusmodes.h"\
+ ".\include\win2k.h"\
+ ".\m_shutdown.h"\
+ ".\options.h"\
+ ".\settingsdlg.h"\
+ ".\shutdownsvc.h"\
+ ".\utils.h"\
+ ".\watcher.h"\
+ "e:\vc98\include\basetsd.h"\
+
+
+.\frame.c : \
+ ".\common.h"\
+ ".\cpuusage.h"\
+ ".\frame.h"\
+ ".\include\m_autoreplacer.h"\
+ ".\include\m_button.h"\
+ ".\include\m_clc.h"\
+ ".\include\m_clist.h"\
+ ".\include\m_clistint.h"\
+ ".\include\m_clui.h"\
+ ".\include\m_cluiframes.h"\
+ ".\include\m_database.h"\
+ ".\include\m_file.h"\
+ ".\include\m_fontservice.h"\
+ ".\include\m_genmenu.h"\
+ ".\include\m_hddinfo.h"\
+ ".\include\m_hotkey.h"\
+ ".\include\m_hotkeysplus.h"\
+ ".\include\m_hotkeysservice.h"\
+ ".\include\m_icolib.h"\
+ ".\include\m_idle.h"\
+ ".\include\m_langpack.h"\
+ ".\include\m_magneticwindows.h"\
+ ".\include\m_message.h"\
+ ".\include\m_mwclc.h"\
+ ".\include\m_options.h"\
+ ".\include\m_plugins.h"\
+ ".\include\m_protocols.h"\
+ ".\include\m_protosvc.h"\
+ ".\include\m_skin.h"\
+ ".\include\m_snappingwindows.h"\
+ ".\include\m_system.h"\
+ ".\include\m_toptoolbar.h"\
+ ".\include\m_trigger.h"\
+ ".\include\m_utils.h"\
+ ".\include\m_weather.h"\
+ ".\include\newpluginapi.h"\
+ ".\include\statusmodes.h"\
+ ".\include\win2k.h"\
+ ".\m_shutdown.h"\
+ ".\options.h"\
+ ".\settingsdlg.h"\
+ ".\shutdownsvc.h"\
+ ".\utils.h"\
+ ".\watcher.h"\
+ "e:\vc98\include\basetsd.h"\
+
+
+.\main.c : \
+ ".\common.h"\
+ ".\cpuusage.h"\
+ ".\frame.h"\
+ ".\include\m_autoreplacer.h"\
+ ".\include\m_button.h"\
+ ".\include\m_clc.h"\
+ ".\include\m_clist.h"\
+ ".\include\m_clistint.h"\
+ ".\include\m_clui.h"\
+ ".\include\m_cluiframes.h"\
+ ".\include\m_database.h"\
+ ".\include\m_file.h"\
+ ".\include\m_fontservice.h"\
+ ".\include\m_genmenu.h"\
+ ".\include\m_hddinfo.h"\
+ ".\include\m_hotkey.h"\
+ ".\include\m_hotkeysplus.h"\
+ ".\include\m_hotkeysservice.h"\
+ ".\include\m_icolib.h"\
+ ".\include\m_idle.h"\
+ ".\include\m_langpack.h"\
+ ".\include\m_magneticwindows.h"\
+ ".\include\m_message.h"\
+ ".\include\m_mwclc.h"\
+ ".\include\m_options.h"\
+ ".\include\m_plugins.h"\
+ ".\include\m_protocols.h"\
+ ".\include\m_protosvc.h"\
+ ".\include\m_skin.h"\
+ ".\include\m_snappingwindows.h"\
+ ".\include\m_system.h"\
+ ".\include\m_toptoolbar.h"\
+ ".\include\m_trigger.h"\
+ ".\include\m_utils.h"\
+ ".\include\m_weather.h"\
+ ".\include\newpluginapi.h"\
+ ".\include\statusmodes.h"\
+ ".\include\win2k.h"\
+ ".\m_shutdown.h"\
+ ".\options.h"\
+ ".\settingsdlg.h"\
+ ".\shutdownsvc.h"\
+ ".\utils.h"\
+ ".\version.h"\
+ ".\watcher.h"\
+ "e:\vc98\include\basetsd.h"\
+
+
+.\options.c : \
+ ".\common.h"\
+ ".\cpuusage.h"\
+ ".\frame.h"\
+ ".\include\m_autoreplacer.h"\
+ ".\include\m_button.h"\
+ ".\include\m_clc.h"\
+ ".\include\m_clist.h"\
+ ".\include\m_clistint.h"\
+ ".\include\m_clui.h"\
+ ".\include\m_cluiframes.h"\
+ ".\include\m_database.h"\
+ ".\include\m_file.h"\
+ ".\include\m_fontservice.h"\
+ ".\include\m_genmenu.h"\
+ ".\include\m_hddinfo.h"\
+ ".\include\m_hotkey.h"\
+ ".\include\m_hotkeysplus.h"\
+ ".\include\m_hotkeysservice.h"\
+ ".\include\m_icolib.h"\
+ ".\include\m_idle.h"\
+ ".\include\m_langpack.h"\
+ ".\include\m_magneticwindows.h"\
+ ".\include\m_message.h"\
+ ".\include\m_mwclc.h"\
+ ".\include\m_options.h"\
+ ".\include\m_plugins.h"\
+ ".\include\m_protocols.h"\
+ ".\include\m_protosvc.h"\
+ ".\include\m_skin.h"\
+ ".\include\m_snappingwindows.h"\
+ ".\include\m_system.h"\
+ ".\include\m_toptoolbar.h"\
+ ".\include\m_trigger.h"\
+ ".\include\m_utils.h"\
+ ".\include\m_weather.h"\
+ ".\include\newpluginapi.h"\
+ ".\include\statusmodes.h"\
+ ".\include\win2k.h"\
+ ".\m_shutdown.h"\
+ ".\options.h"\
+ ".\settingsdlg.h"\
+ ".\shutdownsvc.h"\
+ ".\utils.h"\
+ ".\watcher.h"\
+ "e:\vc98\include\basetsd.h"\
+
+
+.\settingsdlg.c : \
+ ".\common.h"\
+ ".\cpuusage.h"\
+ ".\frame.h"\
+ ".\include\m_autoreplacer.h"\
+ ".\include\m_button.h"\
+ ".\include\m_clc.h"\
+ ".\include\m_clist.h"\
+ ".\include\m_clistint.h"\
+ ".\include\m_clui.h"\
+ ".\include\m_cluiframes.h"\
+ ".\include\m_database.h"\
+ ".\include\m_file.h"\
+ ".\include\m_fontservice.h"\
+ ".\include\m_genmenu.h"\
+ ".\include\m_hddinfo.h"\
+ ".\include\m_hotkey.h"\
+ ".\include\m_hotkeysplus.h"\
+ ".\include\m_hotkeysservice.h"\
+ ".\include\m_icolib.h"\
+ ".\include\m_idle.h"\
+ ".\include\m_langpack.h"\
+ ".\include\m_magneticwindows.h"\
+ ".\include\m_message.h"\
+ ".\include\m_mwclc.h"\
+ ".\include\m_options.h"\
+ ".\include\m_plugins.h"\
+ ".\include\m_protocols.h"\
+ ".\include\m_protosvc.h"\
+ ".\include\m_skin.h"\
+ ".\include\m_snappingwindows.h"\
+ ".\include\m_system.h"\
+ ".\include\m_toptoolbar.h"\
+ ".\include\m_trigger.h"\
+ ".\include\m_utils.h"\
+ ".\include\m_weather.h"\
+ ".\include\newpluginapi.h"\
+ ".\include\statusmodes.h"\
+ ".\include\win2k.h"\
+ ".\m_shutdown.h"\
+ ".\options.h"\
+ ".\settingsdlg.h"\
+ ".\shutdownsvc.h"\
+ ".\utils.h"\
+ ".\watcher.h"\
+ "e:\vc98\include\basetsd.h"\
+
+
+.\shutdownsvc.c : \
+ ".\common.h"\
+ ".\cpuusage.h"\
+ ".\frame.h"\
+ ".\include\m_autoreplacer.h"\
+ ".\include\m_button.h"\
+ ".\include\m_clc.h"\
+ ".\include\m_clist.h"\
+ ".\include\m_clistint.h"\
+ ".\include\m_clui.h"\
+ ".\include\m_cluiframes.h"\
+ ".\include\m_database.h"\
+ ".\include\m_file.h"\
+ ".\include\m_fontservice.h"\
+ ".\include\m_genmenu.h"\
+ ".\include\m_hddinfo.h"\
+ ".\include\m_hotkey.h"\
+ ".\include\m_hotkeysplus.h"\
+ ".\include\m_hotkeysservice.h"\
+ ".\include\m_icolib.h"\
+ ".\include\m_idle.h"\
+ ".\include\m_langpack.h"\
+ ".\include\m_magneticwindows.h"\
+ ".\include\m_message.h"\
+ ".\include\m_mwclc.h"\
+ ".\include\m_options.h"\
+ ".\include\m_plugins.h"\
+ ".\include\m_protocols.h"\
+ ".\include\m_protosvc.h"\
+ ".\include\m_skin.h"\
+ ".\include\m_snappingwindows.h"\
+ ".\include\m_system.h"\
+ ".\include\m_toptoolbar.h"\
+ ".\include\m_trigger.h"\
+ ".\include\m_utils.h"\
+ ".\include\m_weather.h"\
+ ".\include\newpluginapi.h"\
+ ".\include\statusmodes.h"\
+ ".\include\win2k.h"\
+ ".\m_shutdown.h"\
+ ".\options.h"\
+ ".\settingsdlg.h"\
+ ".\shutdownsvc.h"\
+ ".\utils.h"\
+ ".\watcher.h"\
+ "e:\vc98\include\basetsd.h"\
+
+
+.\utils.c : \
+ ".\common.h"\
+ ".\cpuusage.h"\
+ ".\frame.h"\
+ ".\include\m_autoreplacer.h"\
+ ".\include\m_button.h"\
+ ".\include\m_clc.h"\
+ ".\include\m_clist.h"\
+ ".\include\m_clistint.h"\
+ ".\include\m_clui.h"\
+ ".\include\m_cluiframes.h"\
+ ".\include\m_database.h"\
+ ".\include\m_file.h"\
+ ".\include\m_fontservice.h"\
+ ".\include\m_genmenu.h"\
+ ".\include\m_hddinfo.h"\
+ ".\include\m_hotkey.h"\
+ ".\include\m_hotkeysplus.h"\
+ ".\include\m_hotkeysservice.h"\
+ ".\include\m_icolib.h"\
+ ".\include\m_idle.h"\
+ ".\include\m_langpack.h"\
+ ".\include\m_magneticwindows.h"\
+ ".\include\m_message.h"\
+ ".\include\m_mwclc.h"\
+ ".\include\m_options.h"\
+ ".\include\m_plugins.h"\
+ ".\include\m_protocols.h"\
+ ".\include\m_protosvc.h"\
+ ".\include\m_skin.h"\
+ ".\include\m_snappingwindows.h"\
+ ".\include\m_system.h"\
+ ".\include\m_toptoolbar.h"\
+ ".\include\m_trigger.h"\
+ ".\include\m_utils.h"\
+ ".\include\m_weather.h"\
+ ".\include\newpluginapi.h"\
+ ".\include\statusmodes.h"\
+ ".\include\win2k.h"\
+ ".\m_shutdown.h"\
+ ".\options.h"\
+ ".\settingsdlg.h"\
+ ".\shutdownsvc.h"\
+ ".\utils.h"\
+ ".\watcher.h"\
+ "e:\vc98\include\basetsd.h"\
+
+
+.\watcher.c : \
+ ".\common.h"\
+ ".\cpuusage.h"\
+ ".\frame.h"\
+ ".\include\m_autoreplacer.h"\
+ ".\include\m_button.h"\
+ ".\include\m_clc.h"\
+ ".\include\m_clist.h"\
+ ".\include\m_clistint.h"\
+ ".\include\m_clui.h"\
+ ".\include\m_cluiframes.h"\
+ ".\include\m_database.h"\
+ ".\include\m_file.h"\
+ ".\include\m_fontservice.h"\
+ ".\include\m_genmenu.h"\
+ ".\include\m_hddinfo.h"\
+ ".\include\m_hotkey.h"\
+ ".\include\m_hotkeysplus.h"\
+ ".\include\m_hotkeysservice.h"\
+ ".\include\m_icolib.h"\
+ ".\include\m_idle.h"\
+ ".\include\m_langpack.h"\
+ ".\include\m_magneticwindows.h"\
+ ".\include\m_message.h"\
+ ".\include\m_mwclc.h"\
+ ".\include\m_options.h"\
+ ".\include\m_plugins.h"\
+ ".\include\m_protocols.h"\
+ ".\include\m_protosvc.h"\
+ ".\include\m_skin.h"\
+ ".\include\m_snappingwindows.h"\
+ ".\include\m_system.h"\
+ ".\include\m_toptoolbar.h"\
+ ".\include\m_trigger.h"\
+ ".\include\m_utils.h"\
+ ".\include\m_weather.h"\
+ ".\include\newpluginapi.h"\
+ ".\include\statusmodes.h"\
+ ".\include\win2k.h"\
+ ".\m_shutdown.h"\
+ ".\options.h"\
+ ".\settingsdlg.h"\
+ ".\shutdownsvc.h"\
+ ".\utils.h"\
+ ".\watcher.h"\
+ "e:\vc98\include\basetsd.h"\
+
+
+.\resource.rc : \
+ ".\include\m_utils.h"\
+ ".\res\active.ico"\
+ ".\res\header.ico"\
+ ".\res\inactive.ico"\
+ ".\version.rc"\
+
diff --git a/plugins/AutoShutdown/shutdown.dsp b/plugins/AutoShutdown/shutdown.dsp
new file mode 100644
index 0000000000..52d65badfa
--- /dev/null
+++ b/plugins/AutoShutdown/shutdown.dsp
@@ -0,0 +1,451 @@
+# Microsoft Developer Studio Project File - Name="shutdown" - Package Owner=<4>
+# Microsoft Developer Studio Generated Build File, Format Version 6.00
+# ** NICHT BEARBEITEN **
+
+# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102
+
+CFG=shutdown - Win32 Release
+!MESSAGE Dies ist kein gültiges Makefile. Zum Erstellen dieses Projekts mit NMAKE
+!MESSAGE verwenden Sie den Befehl "Makefile exportieren" und führen Sie den Befehl
+!MESSAGE
+!MESSAGE NMAKE /f "shutdown.mak".
+!MESSAGE
+!MESSAGE Sie können beim Ausführen von NMAKE eine Konfiguration angeben
+!MESSAGE durch Definieren des Makros CFG in der Befehlszeile. Zum Beispiel:
+!MESSAGE
+!MESSAGE NMAKE /f "shutdown.mak" CFG="shutdown - Win32 Release"
+!MESSAGE
+!MESSAGE Für die Konfiguration stehen zur Auswahl:
+!MESSAGE
+!MESSAGE "shutdown - Win32 Release" (basierend auf "Win32 (x86) Dynamic-Link Library")
+!MESSAGE "shutdown - Win32 Debug" (basierend auf "Win32 (x86) Dynamic-Link Library")
+!MESSAGE "shutdown - Win32 Release Unicode" (basierend auf "Win32 (x86) Dynamic-Link Library")
+!MESSAGE "shutdown - Win32 Debug Unicode" (basierend auf "Win32 (x86) Dynamic-Link Library")
+!MESSAGE
+
+# Begin Project
+# PROP AllowPerConfigDependencies 0
+# PROP Scc_ProjName ""
+# PROP Scc_LocalPath ""
+CPP=cl.exe
+MTL=midl.exe
+RSC=rc.exe
+
+!IF "$(CFG)" == "shutdown - Win32 Release"
+
+# PROP BASE Use_MFC 0
+# PROP BASE Use_Debug_Libraries 0
+# PROP BASE Output_Dir "release/ANSI"
+# PROP BASE Intermediate_Dir "temp/Release/ANSI"
+# PROP BASE Target_Dir "release/ANSI"
+# PROP Use_MFC 0
+# PROP Use_Debug_Libraries 0
+# PROP Output_Dir "temp/Release/ANSI"
+# PROP Intermediate_Dir "temp/Release/ANSI"
+# PROP Ignore_Export_Lib 1
+# PROP Target_Dir "release/ANSI"
+# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "SHUTDOWN_EXPORTS" /YX /FD /c
+# ADD CPP /nologo /MD /W4 /GX /O2 /I ".\include" /D "NDEBUG" /D "WIN32" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "STRICT" /D "SHUTDOWN_EXPORTS" /U "NO_STRICT" /FR /FD /opt:nowin98 /c
+# SUBTRACT CPP /YX
+# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32
+# ADD MTL /nologo /D "NDEBUG" /win32
+# SUBTRACT MTL /mktyplib203 /Oicf
+# ADD BASE RSC /l 0x1009 /d "NDEBUG"
+# ADD RSC /l 0x409 /i ".\include" /d "NDEBUG"
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+LINK32=link.exe
+# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /machine:I386
+# ADD LINK32 kernel32.lib comctl32.lib gdi32.lib user32.lib shell32.lib advapi32.lib /nologo /base:"0x11070000" /dll /pdb:"./release/ANSI/shutdown.pdb" /map:"release/ANSI/shutdown.map" /debug /machine:I386 /nodefaultlib:"uuid.lib" /nodefaultlib:"OLDNAMES" /def:"shutdown.def" /out:"./release/ANSI/shutdown.dll" /mapinfo:lines /opt:nowin98 /ignore:4078 /RELEASE
+# SUBTRACT LINK32 /pdb:none
+
+!ELSEIF "$(CFG)" == "shutdown - Win32 Debug"
+
+# PROP BASE Use_MFC 0
+# PROP BASE Use_Debug_Libraries 1
+# PROP BASE Output_Dir "temp/Debug/ANSI"
+# PROP BASE Intermediate_Dir "temp/Debug/ANSI"
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 0
+# PROP Use_Debug_Libraries 1
+# PROP Output_Dir "temp/Debug/ANSI"
+# PROP Intermediate_Dir "temp/Debug/ANSI"
+# PROP Ignore_Export_Lib 1
+# PROP Target_Dir ""
+# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "SHUTDOWN_EXPORTS" /YX /FD /GZ /c
+# ADD CPP /nologo /MTd /W4 /Gm /Gi /GR /GX /ZI /Od /I ".\include" /D "_DEBUG" /D "WIN32" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "STRICT" /D "SHUTDOWN_EXPORTS" /U "NO_STRICT" /FR /FD /GZ /c
+# SUBTRACT CPP /WX /YX
+# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32
+# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32
+# SUBTRACT MTL /Oicf
+# ADD BASE RSC /l 0x1009 /d "_DEBUG"
+# ADD RSC /l 0x409 /i ".\include" /d "_DEBUG"
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+LINK32=link.exe
+# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /debug /machine:I386 /pdbtype:sept
+# ADD LINK32 kernel32.lib comctl32.lib gdi32.lib user32.lib shell32.lib advapi32.lib /nologo /base:"0x11070000" /dll /pdb:"D:/Miranda IM/ANSI/Plugins/shutdown.pdb" /map /debug /machine:I386 /nodefaultlib:"uuid.lib" /nodefaultlib:"OLDNAMES" /def:"shutdown.def" /out:"D:/Miranda IM/ANSI/Plugins/shutdown.dll" /pdbtype:sept
+# SUBTRACT LINK32 /verbose /pdb:none
+
+!ELSEIF "$(CFG)" == "shutdown - Win32 Release Unicode"
+
+# PROP BASE Use_MFC 0
+# PROP BASE Use_Debug_Libraries 0
+# PROP BASE Output_Dir "release/Unicode"
+# PROP BASE Intermediate_Dir "temp/Release/Unicode"
+# PROP BASE Target_Dir "release/Unicode"
+# PROP Use_MFC 0
+# PROP Use_Debug_Libraries 0
+# PROP Output_Dir "temp/Release/Unicode"
+# PROP Intermediate_Dir "temp/Release/Unicode"
+# PROP Ignore_Export_Lib 1
+# PROP Target_Dir "release/Unicode"
+# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "SHUTDOWN_EXPORTS" /YX /FD /c
+# ADD CPP /nologo /MD /W4 /GX /O2 /I ".\include" /D "NDEBUG" /D "UNICODE" /D "_UNICODE" /D "WIN32" /D "_WINDOWS" /D "_USRDLL" /D "STRICT" /D "SHUTDOWN_EXPORTS" /U "_MBCS" /U "NO_STRICT" /FR /FD /opt:nowin98 /c
+# SUBTRACT CPP /YX
+# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32
+# ADD MTL /nologo /D "NDEBUG" /win32
+# SUBTRACT MTL /mktyplib203 /Oicf
+# ADD BASE RSC /l 0x1009 /d "NDEBUG" /d "_UNICODE" /d "UNICODE"
+# ADD RSC /l 0x409 /i ".\include" /d "NDEBUG" /d "_UNICODE" /d "UNICODE"
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+LINK32=link.exe
+# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /machine:I386
+# ADD LINK32 kernel32.lib comctl32.lib gdi32.lib user32.lib shell32.lib advapi32.lib /nologo /base:"0x11070000" /dll /pdb:"./release/Unicode/shutdown.pdb" /map:"release/Unicode/shutdown.map" /debug /machine:I386 /nodefaultlib:"uuid.lib" /nodefaultlib:"OLDNAMES" /def:"shutdown.def" /out:"./release/Unicode/shutdown.dll" /mapinfo:lines /opt:nowin98 /ignore:4078 /RELEASE
+# SUBTRACT LINK32 /pdb:none
+
+!ELSEIF "$(CFG)" == "shutdown - Win32 Debug Unicode"
+
+# PROP BASE Use_MFC 0
+# PROP BASE Use_Debug_Libraries 1
+# PROP BASE Output_Dir "temp/Debug/Unicode"
+# PROP BASE Intermediate_Dir "temp/Debug/Unicode"
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 0
+# PROP Use_Debug_Libraries 1
+# PROP Output_Dir "temp/Debug/Unicode"
+# PROP Intermediate_Dir "temp/Debug/Unicode"
+# PROP Ignore_Export_Lib 1
+# PROP Target_Dir ""
+# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "SHUTDOWN_EXPORTS" /YX /FD /GZ /c
+# ADD CPP /nologo /MTd /W4 /Gm /Gi /GR /GX /ZI /Od /I ".\include" /D "_DEBUG" /D "UNICODE" /D "_UNICODE" /D "WIN32" /D "_WINDOWS" /D "_USRDLL" /D "STRICT" /D "SHUTDOWN_EXPORTS" /U "_MBCS" /U "NO_STRICT" /FR /FD /GZ /c
+# SUBTRACT CPP /WX /YX
+# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32
+# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32
+# SUBTRACT MTL /Oicf
+# ADD BASE RSC /l 0x1009 /d "_DEBUG" /d "_UNICODE" /d "UNICODE"
+# ADD RSC /l 0x409 /i ".\include" /d "_DEBUG" /d "_UNICODE" /d "UNICODE"
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+LINK32=link.exe
+# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /debug /machine:I386 /pdbtype:sept
+# ADD LINK32 kernel32.lib comctl32.lib gdi32.lib user32.lib shell32.lib advapi32.lib /nologo /base:"0x11070000" /dll /pdb:"D:/Miranda IM/Unicode/Plugins/shutdown.pdb" /map /debug /machine:I386 /nodefaultlib:"uuid.lib" /nodefaultlib:"OLDNAMES" /def:"shutdown.def" /out:"D:/Miranda IM/Unicode/Plugins/shutdown.dll" /pdbtype:sept
+# SUBTRACT LINK32 /pdb:none /nodefaultlib
+
+!ENDIF
+
+# Begin Target
+
+# Name "shutdown - Win32 Release"
+# Name "shutdown - Win32 Debug"
+# Name "shutdown - Win32 Release Unicode"
+# Name "shutdown - Win32 Debug Unicode"
+# Begin Group "Source Files"
+
+# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
+# Begin Source File
+
+SOURCE=.\cpuusage.c
+# End Source File
+# Begin Source File
+
+SOURCE=.\frame.c
+# End Source File
+# Begin Source File
+
+SOURCE=.\main.c
+# End Source File
+# Begin Source File
+
+SOURCE=.\options.c
+# End Source File
+# Begin Source File
+
+SOURCE=.\settingsdlg.c
+# End Source File
+# Begin Source File
+
+SOURCE=.\shutdownsvc.c
+# End Source File
+# Begin Source File
+
+SOURCE=.\utils.c
+# End Source File
+# Begin Source File
+
+SOURCE=.\watcher.c
+# End Source File
+# End Group
+# Begin Group "Header Files"
+
+# PROP Default_Filter "h;hpp;hxx;hm;inl"
+# Begin Source File
+
+SOURCE=.\common.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\cpuusage.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\frame.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\m_shutdown.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\options.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\settingsdlg.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\shutdownsvc.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\utils.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\watcher.h
+# End Source File
+# End Group
+# Begin Group "Resource Files"
+
+# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe"
+# Begin Source File
+
+SOURCE=.\res\active.ico
+# End Source File
+# Begin Source File
+
+SOURCE=.\res\header.ico
+# End Source File
+# Begin Source File
+
+SOURCE=.\res\inactive.ico
+# End Source File
+# Begin Source File
+
+SOURCE=.\resource.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\resource.rc
+# End Source File
+# Begin Source File
+
+SOURCE=.\version.h
+# End Source File
+# End Group
+# Begin Group "Documentation"
+
+# PROP Default_Filter "txt"
+# Begin Source File
+
+SOURCE=.\Extensions\countdown.wav
+# End Source File
+# Begin Source File
+
+SOURCE=.\m_shutdown.inc
+# End Source File
+# Begin Source File
+
+SOURCE=".\docs\Shutdown-Developer.txt"
+# End Source File
+# Begin Source File
+
+SOURCE=".\docs\Shutdown-License.txt"
+# End Source File
+# Begin Source File
+
+SOURCE=".\docs\Shutdown-Readme.txt"
+# End Source File
+# Begin Source File
+
+SOURCE=".\docs\Shutdown-Translation.txt"
+# End Source File
+# End Group
+# Begin Group "SDK"
+
+# PROP Default_Filter "*.h"
+# Begin Source File
+
+SOURCE=.\include\m_autoreplacer.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\include\m_button.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\include\m_clc.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\include\m_clist.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\include\m_clistint.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\include\m_clui.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\include\m_cluiframes.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\include\m_database.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\include\m_file.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\include\m_fontservice.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\include\m_genmenu.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\include\m_hddinfo.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\include\m_hotkey.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\include\m_hotkeysplus.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\include\m_hotkeysservice.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\include\m_icolib.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\include\m_idle.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\include\m_langpack.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\include\m_magneticwindows.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\include\m_message.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\include\m_mwclc.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\include\m_options.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\include\m_plugins.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\include\m_protocols.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\include\m_protomod.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\include\m_protosvc.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\include\m_skin.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\include\m_snappingwindows.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\include\m_system.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\include\m_toptoolbar.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\include\m_trigger.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\include\m_updater.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\include\m_utils.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\include\m_weather.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\include\newpluginapi.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\include\statusmodes.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\include\win2k.h
+# End Source File
+# End Group
+# Begin Source File
+
+SOURCE=.\Info_Src.txt
+# End Source File
+# Begin Source File
+
+SOURCE=.\License_Appendix.txt
+# End Source File
+# End Target
+# End Project
diff --git a/plugins/AutoShutdown/shutdown.dsw b/plugins/AutoShutdown/shutdown.dsw
new file mode 100644
index 0000000000..b5435be4b4
--- /dev/null
+++ b/plugins/AutoShutdown/shutdown.dsw
@@ -0,0 +1,29 @@
+Microsoft Developer Studio Workspace File, Format Version 6.00
+# WARNUNG: DIESE ARBEITSBEREICHSDATEI DARF NICHT BEARBEITET ODER GELÖSCHT WERDEN!
+
+###############################################################################
+
+Project: "shutdown"=".\shutdown.dsp" - Package Owner=<4>
+
+Package=<5>
+{{{
+}}}
+
+Package=<4>
+{{{
+}}}
+
+###############################################################################
+
+Global:
+
+Package=<5>
+{{{
+}}}
+
+Package=<3>
+{{{
+}}}
+
+###############################################################################
+
diff --git a/plugins/AutoShutdown/shutdown.mak b/plugins/AutoShutdown/shutdown.mak
new file mode 100644
index 0000000000..daaa0217de
--- /dev/null
+++ b/plugins/AutoShutdown/shutdown.mak
@@ -0,0 +1,435 @@
+# Microsoft Developer Studio Generated NMAKE File, Based on shutdown.dsp
+!IF "$(CFG)" == ""
+CFG=shutdown - Win32 Release
+!MESSAGE Keine Konfiguration angegeben. shutdown - Win32 Release wird als Standard verwendet.
+!ENDIF
+
+!IF "$(CFG)" != "shutdown - Win32 Release" && "$(CFG)" != "shutdown - Win32 Debug" && "$(CFG)" != "shutdown - Win32 Release Unicode" && "$(CFG)" != "shutdown - Win32 Debug Unicode"
+!MESSAGE Ungltige Konfiguration "$(CFG)" angegeben.
+!MESSAGE Sie k”nnen beim Ausfhren von NMAKE eine Konfiguration angeben
+!MESSAGE durch Definieren des Makros CFG in der Befehlszeile. Zum Beispiel:
+!MESSAGE
+!MESSAGE NMAKE /f "shutdown.mak" CFG="shutdown - Win32 Release"
+!MESSAGE
+!MESSAGE Fr die Konfiguration stehen zur Auswahl:
+!MESSAGE
+!MESSAGE "shutdown - Win32 Release" (basierend auf "Win32 (x86) Dynamic-Link Library")
+!MESSAGE "shutdown - Win32 Debug" (basierend auf "Win32 (x86) Dynamic-Link Library")
+!MESSAGE "shutdown - Win32 Release Unicode" (basierend auf "Win32 (x86) Dynamic-Link Library")
+!MESSAGE "shutdown - Win32 Debug Unicode" (basierend auf "Win32 (x86) Dynamic-Link Library")
+!MESSAGE
+!ERROR Eine ungltige Konfiguration wurde angegeben.
+!ENDIF
+
+!IF "$(OS)" == "Windows_NT"
+NULL=
+!ELSE
+NULL=nul
+!ENDIF
+
+CPP=cl.exe
+MTL=midl.exe
+RSC=rc.exe
+
+!IF "$(CFG)" == "shutdown - Win32 Release"
+
+OUTDIR=.\temp/Release/ANSI
+INTDIR=.\temp/Release/ANSI
+# Begin Custom Macros
+OutDir=.\temp/Release/ANSI
+# End Custom Macros
+
+ALL : ".\release\ANSI\shutdown.dll" "$(OUTDIR)\shutdown.bsc"
+
+
+CLEAN :
+ -@erase "$(INTDIR)\cpuusage.obj"
+ -@erase "$(INTDIR)\cpuusage.sbr"
+ -@erase "$(INTDIR)\frame.obj"
+ -@erase "$(INTDIR)\frame.sbr"
+ -@erase "$(INTDIR)\main.obj"
+ -@erase "$(INTDIR)\main.sbr"
+ -@erase "$(INTDIR)\options.obj"
+ -@erase "$(INTDIR)\options.sbr"
+ -@erase "$(INTDIR)\resource.res"
+ -@erase "$(INTDIR)\settingsdlg.obj"
+ -@erase "$(INTDIR)\settingsdlg.sbr"
+ -@erase "$(INTDIR)\shutdownsvc.obj"
+ -@erase "$(INTDIR)\shutdownsvc.sbr"
+ -@erase "$(INTDIR)\utils.obj"
+ -@erase "$(INTDIR)\utils.sbr"
+ -@erase "$(INTDIR)\vc60.idb"
+ -@erase "$(INTDIR)\watcher.obj"
+ -@erase "$(INTDIR)\watcher.sbr"
+ -@erase "$(OUTDIR)\shutdown.bsc"
+ -@erase "$(OUTDIR)\shutdown.exp"
+ -@erase ".\release\ANSI\shutdown.dll"
+ -@erase ".\release\ANSI\shutdown.pdb"
+
+"$(OUTDIR)" :
+ if not exist "$(OUTDIR)/$(NULL)" mkdir "$(OUTDIR)"
+
+CPP_PROJ=/nologo /MD /W4 /GX /O2 /I ".\include" /D "NDEBUG" /D "WIN32" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "STRICT" /D "SHUTDOWN_EXPORTS" /U "NO_STRICT" /FR"$(INTDIR)\\" /Fo"$(INTDIR)\\" /Fd"$(INTDIR)\\" /FD /opt:nowin98 /c
+MTL_PROJ=/nologo /D "NDEBUG" /win32
+RSC_PROJ=/l 0x409 /fo"$(INTDIR)\resource.res" /i ".\include" /d "NDEBUG"
+BSC32=bscmake.exe
+BSC32_FLAGS=/nologo /o"$(OUTDIR)\shutdown.bsc"
+BSC32_SBRS= \
+ "$(INTDIR)\cpuusage.sbr" \
+ "$(INTDIR)\frame.sbr" \
+ "$(INTDIR)\main.sbr" \
+ "$(INTDIR)\options.sbr" \
+ "$(INTDIR)\settingsdlg.sbr" \
+ "$(INTDIR)\shutdownsvc.sbr" \
+ "$(INTDIR)\utils.sbr" \
+ "$(INTDIR)\watcher.sbr"
+
+"$(OUTDIR)\shutdown.bsc" : "$(OUTDIR)" $(BSC32_SBRS)
+ $(BSC32) @<<
+ $(BSC32_FLAGS) $(BSC32_SBRS)
+<<
+
+LINK32=link.exe
+LINK32_FLAGS=kernel32.lib comctl32.lib gdi32.lib user32.lib shell32.lib advapi32.lib /nologo /base:"0x11070000" /dll /incremental:no /pdb:"./release/ANSI/shutdown.pdb" /debug /machine:I386 /nodefaultlib:"uuid.lib" /nodefaultlib:"OLDNAMES" /def:"shutdown.def" /out:"./release/ANSI/shutdown.dll" /implib:"$(OUTDIR)\shutdown.lib" /opt:nowin98 /ignore:4078 /RELEASE
+LINK32_OBJS= \
+ "$(INTDIR)\cpuusage.obj" \
+ "$(INTDIR)\frame.obj" \
+ "$(INTDIR)\main.obj" \
+ "$(INTDIR)\options.obj" \
+ "$(INTDIR)\settingsdlg.obj" \
+ "$(INTDIR)\shutdownsvc.obj" \
+ "$(INTDIR)\utils.obj" \
+ "$(INTDIR)\watcher.obj" \
+ "$(INTDIR)\resource.res"
+
+".\release\ANSI\shutdown.dll" : "$(OUTDIR)" $(DEF_FILE) $(LINK32_OBJS)
+ $(LINK32) @<<
+ $(LINK32_FLAGS) $(LINK32_OBJS)
+<<
+
+!ELSEIF "$(CFG)" == "shutdown - Win32 Debug"
+
+OUTDIR=.\temp/Debug/ANSI
+INTDIR=.\temp/Debug/ANSI
+# Begin Custom Macros
+OutDir=.\temp/Debug/ANSI
+# End Custom Macros
+
+ALL : "..\Miranda IM\ANSI\Plugins\shutdown.dll" "$(OUTDIR)\shutdown.bsc"
+
+
+CLEAN :
+ -@erase "$(INTDIR)\cpuusage.obj"
+ -@erase "$(INTDIR)\cpuusage.sbr"
+ -@erase "$(INTDIR)\frame.obj"
+ -@erase "$(INTDIR)\frame.sbr"
+ -@erase "$(INTDIR)\main.obj"
+ -@erase "$(INTDIR)\main.sbr"
+ -@erase "$(INTDIR)\options.obj"
+ -@erase "$(INTDIR)\options.sbr"
+ -@erase "$(INTDIR)\resource.res"
+ -@erase "$(INTDIR)\settingsdlg.obj"
+ -@erase "$(INTDIR)\settingsdlg.sbr"
+ -@erase "$(INTDIR)\shutdownsvc.obj"
+ -@erase "$(INTDIR)\shutdownsvc.sbr"
+ -@erase "$(INTDIR)\utils.obj"
+ -@erase "$(INTDIR)\utils.sbr"
+ -@erase "$(INTDIR)\vc60.idb"
+ -@erase "$(INTDIR)\vc60.pdb"
+ -@erase "$(INTDIR)\watcher.obj"
+ -@erase "$(INTDIR)\watcher.sbr"
+ -@erase "$(OUTDIR)\shutdown.bsc"
+ -@erase "$(OUTDIR)\shutdown.exp"
+ -@erase "$(OUTDIR)\shutdown.map"
+ -@erase "..\Miranda IM\ANSI\Plugins\shutdown.dll"
+ -@erase "..\Miranda IM\ANSI\Plugins\shutdown.ilk"
+ -@erase "..\Miranda IM\ANSI\Plugins\shutdown.pdb"
+
+"$(OUTDIR)" :
+ if not exist "$(OUTDIR)/$(NULL)" mkdir "$(OUTDIR)"
+
+CPP_PROJ=/nologo /MTd /W4 /Gm /Gi /GR /GX /ZI /Od /I ".\include" /D "_DEBUG" /D "WIN32" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "STRICT" /D "SHUTDOWN_EXPORTS" /U "NO_STRICT" /FR"$(INTDIR)\\" /Fo"$(INTDIR)\\" /Fd"$(INTDIR)\\" /FD /GZ /c
+MTL_PROJ=/nologo /D "_DEBUG" /mktyplib203 /win32
+RSC_PROJ=/l 0x409 /fo"$(INTDIR)\resource.res" /i ".\include" /d "_DEBUG"
+BSC32=bscmake.exe
+BSC32_FLAGS=/nologo /o"$(OUTDIR)\shutdown.bsc"
+BSC32_SBRS= \
+ "$(INTDIR)\cpuusage.sbr" \
+ "$(INTDIR)\frame.sbr" \
+ "$(INTDIR)\main.sbr" \
+ "$(INTDIR)\options.sbr" \
+ "$(INTDIR)\settingsdlg.sbr" \
+ "$(INTDIR)\shutdownsvc.sbr" \
+ "$(INTDIR)\utils.sbr" \
+ "$(INTDIR)\watcher.sbr"
+
+"$(OUTDIR)\shutdown.bsc" : "$(OUTDIR)" $(BSC32_SBRS)
+ $(BSC32) @<<
+ $(BSC32_FLAGS) $(BSC32_SBRS)
+<<
+
+LINK32=link.exe
+LINK32_FLAGS=kernel32.lib comctl32.lib gdi32.lib user32.lib shell32.lib advapi32.lib /nologo /base:"0x11070000" /dll /incremental:yes /pdb:"C:/Dokumente und Einstellungen/bib-nutzer/Desktop/Miranda IM/ANSI/Plugins/shutdown.pdb" /map:"$(INTDIR)\shutdown.map" /debug /machine:I386 /nodefaultlib:"uuid.lib" /nodefaultlib:"OLDNAMES" /def:"shutdown.def" /out:"C:/Dokumente und Einstellungen/bib-nutzer/Desktop/Miranda IM/ANSI/Plugins/shutdown.dll" /implib:"$(OUTDIR)\shutdown.lib" /pdbtype:sept
+LINK32_OBJS= \
+ "$(INTDIR)\cpuusage.obj" \
+ "$(INTDIR)\frame.obj" \
+ "$(INTDIR)\main.obj" \
+ "$(INTDIR)\options.obj" \
+ "$(INTDIR)\settingsdlg.obj" \
+ "$(INTDIR)\shutdownsvc.obj" \
+ "$(INTDIR)\utils.obj" \
+ "$(INTDIR)\watcher.obj" \
+ "$(INTDIR)\resource.res"
+
+"..\Miranda IM\ANSI\Plugins\shutdown.dll" : "$(OUTDIR)" $(DEF_FILE) $(LINK32_OBJS)
+ $(LINK32) @<<
+ $(LINK32_FLAGS) $(LINK32_OBJS)
+<<
+
+!ELSEIF "$(CFG)" == "shutdown - Win32 Release Unicode"
+
+OUTDIR=.\temp/Release/Unicode
+INTDIR=.\temp/Release/Unicode
+# Begin Custom Macros
+OutDir=.\temp/Release/Unicode
+# End Custom Macros
+
+ALL : ".\release\Unicode\shutdown.dll" "$(OUTDIR)\shutdown.bsc"
+
+
+CLEAN :
+ -@erase "$(INTDIR)\cpuusage.obj"
+ -@erase "$(INTDIR)\cpuusage.sbr"
+ -@erase "$(INTDIR)\frame.obj"
+ -@erase "$(INTDIR)\frame.sbr"
+ -@erase "$(INTDIR)\main.obj"
+ -@erase "$(INTDIR)\main.sbr"
+ -@erase "$(INTDIR)\options.obj"
+ -@erase "$(INTDIR)\options.sbr"
+ -@erase "$(INTDIR)\resource.res"
+ -@erase "$(INTDIR)\settingsdlg.obj"
+ -@erase "$(INTDIR)\settingsdlg.sbr"
+ -@erase "$(INTDIR)\shutdownsvc.obj"
+ -@erase "$(INTDIR)\shutdownsvc.sbr"
+ -@erase "$(INTDIR)\utils.obj"
+ -@erase "$(INTDIR)\utils.sbr"
+ -@erase "$(INTDIR)\vc60.idb"
+ -@erase "$(INTDIR)\watcher.obj"
+ -@erase "$(INTDIR)\watcher.sbr"
+ -@erase "$(OUTDIR)\shutdown.bsc"
+ -@erase "$(OUTDIR)\shutdown.exp"
+ -@erase ".\release\Unicode\shutdown.dll"
+ -@erase ".\release\Unicode\shutdown.pdb"
+
+"$(OUTDIR)" :
+ if not exist "$(OUTDIR)/$(NULL)" mkdir "$(OUTDIR)"
+
+CPP_PROJ=/nologo /MD /W4 /GX /O2 /I ".\include" /D "NDEBUG" /D "UNICODE" /D "_UNICODE" /D "WIN32" /D "_WINDOWS" /D "_USRDLL" /D "STRICT" /D "SHUTDOWN_EXPORTS" /U "_MBCS" /U "NO_STRICT" /FR"$(INTDIR)\\" /Fp"$(INTDIR)\shutdown.pch" /YX"common.h" /Fo"$(INTDIR)\\" /Fd"$(INTDIR)\\" /FD /opt:nowin98 /c
+MTL_PROJ=/nologo /D "NDEBUG" /win32
+RSC_PROJ=/l 0x409 /fo"$(INTDIR)\resource.res" /i ".\include" /d "NDEBUG" /d "_UNICODE" /d "UNICODE"
+BSC32=bscmake.exe
+BSC32_FLAGS=/nologo /o"$(OUTDIR)\shutdown.bsc"
+BSC32_SBRS= \
+ "$(INTDIR)\cpuusage.sbr" \
+ "$(INTDIR)\frame.sbr" \
+ "$(INTDIR)\main.sbr" \
+ "$(INTDIR)\options.sbr" \
+ "$(INTDIR)\settingsdlg.sbr" \
+ "$(INTDIR)\shutdownsvc.sbr" \
+ "$(INTDIR)\utils.sbr" \
+ "$(INTDIR)\watcher.sbr"
+
+"$(OUTDIR)\shutdown.bsc" : "$(OUTDIR)" $(BSC32_SBRS)
+ $(BSC32) @<<
+ $(BSC32_FLAGS) $(BSC32_SBRS)
+<<
+
+LINK32=link.exe
+LINK32_FLAGS=kernel32.lib comctl32.lib gdi32.lib user32.lib shell32.lib advapi32.lib /nologo /base:"0x11070000" /dll /incremental:no /pdb:"./release/Unicode/shutdown.pdb" /debug /machine:I386 /nodefaultlib:"uuid.lib" /nodefaultlib:"OLDNAMES" /def:"shutdown.def" /out:"./release/Unicode/shutdown.dll" /implib:"$(OUTDIR)\shutdown.lib" /opt:nowin98 /ignore:4078 /RELEASE
+LINK32_OBJS= \
+ "$(INTDIR)\cpuusage.obj" \
+ "$(INTDIR)\frame.obj" \
+ "$(INTDIR)\main.obj" \
+ "$(INTDIR)\options.obj" \
+ "$(INTDIR)\settingsdlg.obj" \
+ "$(INTDIR)\shutdownsvc.obj" \
+ "$(INTDIR)\utils.obj" \
+ "$(INTDIR)\watcher.obj" \
+ "$(INTDIR)\resource.res"
+
+".\release\Unicode\shutdown.dll" : "$(OUTDIR)" $(DEF_FILE) $(LINK32_OBJS)
+ $(LINK32) @<<
+ $(LINK32_FLAGS) $(LINK32_OBJS)
+<<
+
+!ELSEIF "$(CFG)" == "shutdown - Win32 Debug Unicode"
+
+OUTDIR=.\temp/Debug/Unicode
+INTDIR=.\temp/Debug/Unicode
+# Begin Custom Macros
+OutDir=.\temp/Debug/Unicode
+# End Custom Macros
+
+ALL : "..\Miranda IM\Unicode\Plugins\shutdown.dll" "$(OUTDIR)\shutdown.bsc"
+
+
+CLEAN :
+ -@erase "$(INTDIR)\cpuusage.obj"
+ -@erase "$(INTDIR)\cpuusage.sbr"
+ -@erase "$(INTDIR)\frame.obj"
+ -@erase "$(INTDIR)\frame.sbr"
+ -@erase "$(INTDIR)\main.obj"
+ -@erase "$(INTDIR)\main.sbr"
+ -@erase "$(INTDIR)\options.obj"
+ -@erase "$(INTDIR)\options.sbr"
+ -@erase "$(INTDIR)\resource.res"
+ -@erase "$(INTDIR)\settingsdlg.obj"
+ -@erase "$(INTDIR)\settingsdlg.sbr"
+ -@erase "$(INTDIR)\shutdownsvc.obj"
+ -@erase "$(INTDIR)\shutdownsvc.sbr"
+ -@erase "$(INTDIR)\utils.obj"
+ -@erase "$(INTDIR)\utils.sbr"
+ -@erase "$(INTDIR)\vc60.idb"
+ -@erase "$(INTDIR)\vc60.pdb"
+ -@erase "$(INTDIR)\watcher.obj"
+ -@erase "$(INTDIR)\watcher.sbr"
+ -@erase "$(OUTDIR)\shutdown.bsc"
+ -@erase "$(OUTDIR)\shutdown.exp"
+ -@erase "$(OUTDIR)\shutdown.map"
+ -@erase "..\Miranda IM\Unicode\Plugins\shutdown.dll"
+ -@erase "..\Miranda IM\Unicode\Plugins\shutdown.ilk"
+ -@erase "..\Miranda IM\Unicode\Plugins\shutdown.pdb"
+
+"$(OUTDIR)" :
+ if not exist "$(OUTDIR)/$(NULL)" mkdir "$(OUTDIR)"
+
+CPP_PROJ=/nologo /MTd /W4 /Gm /Gi /GR /GX /ZI /Od /I ".\include" /D "_DEBUG" /D "UNICODE" /D "_UNICODE" /D "WIN32" /D "_WINDOWS" /D "_USRDLL" /D "STRICT" /D "SHUTDOWN_EXPORTS" /U "_MBCS" /U "NO_STRICT" /FR"$(INTDIR)\\" /Fo"$(INTDIR)\\" /Fd"$(INTDIR)\\" /FD /GZ /c
+MTL_PROJ=/nologo /D "_DEBUG" /mktyplib203 /win32
+RSC_PROJ=/l 0x409 /fo"$(INTDIR)\resource.res" /i ".\include" /d "_DEBUG" /d "_UNICODE" /d "UNICODE"
+BSC32=bscmake.exe
+BSC32_FLAGS=/nologo /o"$(OUTDIR)\shutdown.bsc"
+BSC32_SBRS= \
+ "$(INTDIR)\cpuusage.sbr" \
+ "$(INTDIR)\frame.sbr" \
+ "$(INTDIR)\main.sbr" \
+ "$(INTDIR)\options.sbr" \
+ "$(INTDIR)\settingsdlg.sbr" \
+ "$(INTDIR)\shutdownsvc.sbr" \
+ "$(INTDIR)\utils.sbr" \
+ "$(INTDIR)\watcher.sbr"
+
+"$(OUTDIR)\shutdown.bsc" : "$(OUTDIR)" $(BSC32_SBRS)
+ $(BSC32) @<<
+ $(BSC32_FLAGS) $(BSC32_SBRS)
+<<
+
+LINK32=link.exe
+LINK32_FLAGS=kernel32.lib comctl32.lib gdi32.lib user32.lib shell32.lib advapi32.lib /nologo /base:"0x11070000" /dll /incremental:yes /pdb:"C:/Dokumente und Einstellungen/bib-nutzer/Desktop/Miranda IM/Unicode/Plugins/shutdown.pdb" /map:"$(INTDIR)\shutdown.map" /debug /machine:I386 /nodefaultlib:"uuid.lib" /nodefaultlib:"OLDNAMES" /def:"shutdown.def" /out:"C:/Dokumente und Einstellungen/bib-nutzer/Desktop/Miranda IM/Unicode/Plugins/shutdown.dll" /implib:"$(OUTDIR)\shutdown.lib" /pdbtype:sept
+LINK32_OBJS= \
+ "$(INTDIR)\cpuusage.obj" \
+ "$(INTDIR)\frame.obj" \
+ "$(INTDIR)\main.obj" \
+ "$(INTDIR)\options.obj" \
+ "$(INTDIR)\settingsdlg.obj" \
+ "$(INTDIR)\shutdownsvc.obj" \
+ "$(INTDIR)\utils.obj" \
+ "$(INTDIR)\watcher.obj" \
+ "$(INTDIR)\resource.res"
+
+"..\Miranda IM\Unicode\Plugins\shutdown.dll" : "$(OUTDIR)" $(DEF_FILE) $(LINK32_OBJS)
+ $(LINK32) @<<
+ $(LINK32_FLAGS) $(LINK32_OBJS)
+<<
+
+!ENDIF
+
+.c{$(INTDIR)}.obj::
+ $(CPP) @<<
+ $(CPP_PROJ) $<
+<<
+
+.cpp{$(INTDIR)}.obj::
+ $(CPP) @<<
+ $(CPP_PROJ) $<
+<<
+
+.cxx{$(INTDIR)}.obj::
+ $(CPP) @<<
+ $(CPP_PROJ) $<
+<<
+
+.c{$(INTDIR)}.sbr::
+ $(CPP) @<<
+ $(CPP_PROJ) $<
+<<
+
+.cpp{$(INTDIR)}.sbr::
+ $(CPP) @<<
+ $(CPP_PROJ) $<
+<<
+
+.cxx{$(INTDIR)}.sbr::
+ $(CPP) @<<
+ $(CPP_PROJ) $<
+<<
+
+
+!IF "$(NO_EXTERNAL_DEPS)" != "1"
+!IF EXISTS("shutdown.dep")
+!INCLUDE "shutdown.dep"
+!ELSE
+!MESSAGE Warning: cannot find "shutdown.dep"
+!ENDIF
+!ENDIF
+
+
+!IF "$(CFG)" == "shutdown - Win32 Release" || "$(CFG)" == "shutdown - Win32 Debug" || "$(CFG)" == "shutdown - Win32 Release Unicode" || "$(CFG)" == "shutdown - Win32 Debug Unicode"
+SOURCE=.\cpuusage.c
+
+"$(INTDIR)\cpuusage.obj" "$(INTDIR)\cpuusage.sbr" : $(SOURCE) "$(INTDIR)"
+
+
+SOURCE=.\frame.c
+
+"$(INTDIR)\frame.obj" "$(INTDIR)\frame.sbr" : $(SOURCE) "$(INTDIR)"
+
+
+SOURCE=.\main.c
+
+"$(INTDIR)\main.obj" "$(INTDIR)\main.sbr" : $(SOURCE) "$(INTDIR)"
+
+
+SOURCE=.\options.c
+
+"$(INTDIR)\options.obj" "$(INTDIR)\options.sbr" : $(SOURCE) "$(INTDIR)"
+
+
+SOURCE=.\settingsdlg.c
+
+"$(INTDIR)\settingsdlg.obj" "$(INTDIR)\settingsdlg.sbr" : $(SOURCE) "$(INTDIR)"
+
+
+SOURCE=.\shutdownsvc.c
+
+"$(INTDIR)\shutdownsvc.obj" "$(INTDIR)\shutdownsvc.sbr" : $(SOURCE) "$(INTDIR)"
+
+
+SOURCE=.\utils.c
+
+"$(INTDIR)\utils.obj" "$(INTDIR)\utils.sbr" : $(SOURCE) "$(INTDIR)"
+
+
+SOURCE=.\watcher.c
+
+"$(INTDIR)\watcher.obj" "$(INTDIR)\watcher.sbr" : $(SOURCE) "$(INTDIR)"
+
+
+SOURCE=.\resource.rc
+
+"$(INTDIR)\resource.res" : $(SOURCE) "$(INTDIR)"
+ $(RSC) $(RSC_PROJ) $(SOURCE)
+
+
+
+!ENDIF
+
diff --git a/plugins/AutoShutdown/shutdownsvc.c b/plugins/AutoShutdown/shutdownsvc.c
new file mode 100644
index 0000000000..2b519cc512
--- /dev/null
+++ b/plugins/AutoShutdown/shutdownsvc.c
@@ -0,0 +1,624 @@
+/*
+
+'AutoShutdown'-Plugin for Miranda IM
+
+Copyright 2004-2007 H. Herkenrath
+
+This program is free software; you can redistribute it and/or
+modify it under the terms of the GNU General Public License
+as published by the Free Software Foundation; either version 2
+of the License, or (at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program (Shutdown-License.txt); if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+*/
+
+#include "common.h"
+
+/* Shutdown Dialog */
+static HWND hwndShutdownDlg;
+extern HINSTANCE hInst;
+/* Services */
+static HANDLE hEventOkToShutdown,hEventShutdown;
+static HANDLE hServiceShutdown,hServiceIsTypeEnabled,hServiceGetTypeDesc;
+
+/************************* Utils **************************************/
+
+static BOOL WinNT_SetPrivilege(TCHAR *pszPrivName,BOOL bEnable)
+{
+ BOOL bReturn=FALSE;
+ HANDLE hToken;
+ TOKEN_PRIVILEGES tkp;
+ /* get a token for this process */
+ if(OpenProcessToken(GetCurrentProcess(),TOKEN_ADJUST_PRIVILEGES|TOKEN_QUERY,&hToken)) {
+ tkp.PrivilegeCount=1; /* one privilege is to set */
+ /* get the LUID for the shutdown privilege */
+ if(LookupPrivilegeValue(NULL,pszPrivName,&tkp.Privileges[0].Luid)) {
+ tkp.Privileges[0].Attributes=bEnable?SE_PRIVILEGE_ENABLED:0;
+ /* get the shutdown privilege for this process */
+ bReturn=AdjustTokenPrivileges(hToken,FALSE,&tkp,0,(PTOKEN_PRIVILEGES)NULL,0);
+ }
+ CloseHandle(hToken);
+ }
+ return bReturn;
+}
+
+static void BroadcastEndSession(DWORD dwRecipients,LPARAM lParam)
+{
+ LONG (WINAPI *pfnBroadcastSystemMessage)(DWORD,DWORD*,UINT,WPARAM,LPARAM);
+#if defined(_UNICODE)
+ *(PROC*)&pfnBroadcastSystemMessage=GetProcAddress(GetModuleHandleA("USER32"),"BroadcastSystemMessageW");
+#else
+ *(PROC*)&pfnBroadcastSystemMessage=GetProcAddress(GetModuleHandleA("USER32"),"BroadcastSystemMessageA");
+ if(!pfnBroadcastSystemMessage) /* Win95 has undecorated API */
+ *(PROC*)&pfnBroadcastSystemMessage=GetProcAddress(GetModuleHandleA("USER32"),"BroadcastSystemMessage");
+#endif
+ if(pfnBroadcastSystemMessage)
+ pfnBroadcastSystemMessage(BSF_FORCEIFHUNG,&dwRecipients,WM_ENDSESSION,TRUE,lParam);
+}
+
+static BOOL WinNT_IsWorkStationLocked(void)
+{
+ HDESK hDesk;
+ TCHAR szName[8];
+ DWORD cbName;
+ BOOL bLocked;
+ hDesk=OpenInputDesktop(0,FALSE,DESKTOP_READOBJECTS);
+ if(hDesk==NULL) return TRUE;
+ bLocked=(!GetUserObjectInformation(hDesk,UOI_NAME,szName,SIZEOF(szName),&cbName) || lstrcmpi(szName,_T("default"))!=0);
+ CloseDesktop(hDesk);
+ return bLocked;
+}
+
+#if !defined(_UNICODE)
+static void Win9x_TerminateExplorer(void)
+{
+ HANDLE hProcess;
+ DWORD idProcess;
+ if(GetWindowThreadProcessId(GetDesktopWindow(),&idProcess)) {
+ hProcess=OpenProcess(PROCESS_TERMINATE,FALSE,idProcess);
+ if(hProcess!=NULL) {
+ TerminateProcess(hProcess,0);
+ CloseHandle(hProcess);
+ }
+ }
+}
+#endif
+
+/************************* Workers ************************************/
+
+static BOOL IsShutdownTypeEnabled(BYTE shutdownType)
+{
+ BOOL bReturn=FALSE;
+ switch(shutdownType) {
+ case SDSDT_HIBERNATE:
+ case SDSDT_STANDBY:
+ { HMODULE hPowerDLL=LoadLibraryA("POWRPROF"); /* all ascii */
+ if(hPowerDLL!=NULL) {
+ BOOLEAN (STDAPICALLTYPE *pfnIsPwrModeAllowed)(void);
+ *(PROC*)&pfnIsPwrModeAllowed=GetProcAddress(hPowerDLL,(shutdownType==SDSDT_HIBERNATE)?"IsPwrHibernateAllowed":"IsPwrSuspendAllowed");
+ if(pfnIsPwrModeAllowed) bReturn=pfnIsPwrModeAllowed()!=0;
+ FreeLibrary(hPowerDLL);
+ }
+ }
+ /* test privilege */
+ if(bReturn && IsWinVerNT()) {
+ bReturn=WinNT_SetPrivilege(SE_SHUTDOWN_NAME,TRUE);
+ if(bReturn) WinNT_SetPrivilege(SE_SHUTDOWN_NAME,FALSE);
+ }
+ break;
+ case SDSDT_LOGOFF:
+ { HKEY hKey;
+ DWORD dwSetting,dwSize;
+ /* NoLogOff is BINARY on Win9x/ME and DWORD on Win2000+ */
+ bReturn=TRUE;
+ if(RegOpenKeyEx(HKEY_CURRENT_USER,_T("Software\\Microsoft\\Windows\\CurrentVersion\\Policies\\Explorer"),0,KEY_QUERY_VALUE,&hKey)==ERROR_SUCCESS) {
+ dwSize=sizeof(dwSetting);
+ if(RegQueryValueEx(hKey,_T("NoLogOff"),0,NULL,(void*)&dwSetting,&dwSize)==ERROR_SUCCESS)
+ if(dwSetting) bReturn=FALSE;
+ RegCloseKey(hKey);
+ }
+ }
+ break;
+ case SDSDT_LOCKWORKSTATION:
+ { void (WINAPI *pfnLockWorkStation)(void);
+ *(PROC*)&pfnLockWorkStation=GetProcAddress(GetModuleHandleA("USER32"),"LockWorkStation");
+ if(pfnLockWorkStation) {
+ HKEY hKey;
+ DWORD dwSize,dwSetting;
+ /* DisableLockWorkstation is DWORD on Win2000+ */
+ bReturn=TRUE;
+ if(RegOpenKeyEx(HKEY_CURRENT_USER,_T("Software\\Microsoft\\Windows\\CurrentVersion\\Policies\\System"),0,KEY_QUERY_VALUE,&hKey)==ERROR_SUCCESS) {
+ dwSize=sizeof(dwSetting);
+ if(!RegQueryValueEx(hKey,_T("DisableLockWorkstation"),0,NULL,(void*)&dwSetting,&dwSize))
+ if(dwSetting) bReturn=FALSE;
+ RegCloseKey(hKey);
+ }
+ }
+ else if(IsWinVerNT()) /* for WinNT4 */
+ bReturn=SearchPath(NULL,_T("LOGIN.SCR"),NULL,0,NULL,NULL)!=0;
+ }
+ break;
+ case SDSDT_CLOSERASCONNECTIONS:
+ /* check if RAS installed/available */
+ bReturn=SearchPath(NULL,_T("RASAPI32"),_T(".DLL"),0,NULL,NULL)!=0;
+ break;
+ case SDSDT_SETMIRANDAOFFLINE:
+ case SDSDT_CLOSEMIRANDA:
+ bReturn=TRUE; /* always possible */
+ break;
+ case SDSDT_REBOOT:
+ case SDSDT_SHUTDOWN:
+ /* test privileges */
+ if(IsWinVerNT()) {
+ bReturn=WinNT_SetPrivilege(SE_SHUTDOWN_NAME,TRUE);
+ if(bReturn) WinNT_SetPrivilege(SE_SHUTDOWN_NAME,FALSE);
+ }
+ else bReturn=TRUE;
+ break;
+ }
+ return bReturn;
+}
+
+static DWORD ShutdownNow(BYTE shutdownType)
+{
+ DWORD dwErrCode=ERROR_SUCCESS;
+ switch(shutdownType) {
+ case SDSDT_CLOSEMIRANDA:
+ if(!Miranda_Terminated()) {
+ /* waiting for short until ready (but not too long...) */
+ DWORD dwLastTickCount=GetTickCount();
+ while(!CallService(MS_SYSTEM_OKTOEXIT,0,0)) {
+ /* infinite loop protection (max 5 sec) */
+ if(GetTickCount()-dwLastTickCount>=5000) { /* wraparound works */
+ OutputDebugStringA("Timeout (5 sec)\n"); /* tell others, all ascii */
+ break;
+ }
+ SleepEx(1000,TRUE);
+ if(Miranda_Terminated()) break; /* someone else did it */
+ OutputDebugStringA("Not ready to exit. Waiting...\n"); /* tell others, all ascii */
+ }
+ /* shutdown service must be called from main thread anyway */
+ if(!DestroyWindow((HWND)CallService(MS_CLUI_GETHWND,0,0)))
+ dwErrCode=GetLastError();
+ }
+ break;
+ case SDSDT_SETMIRANDAOFFLINE:
+ /* set global status mode to offline (is remembered by Miranda on exit) */
+ CallService(MS_CLIST_SETSTATUSMODE,(WPARAM)ID_STATUS_OFFLINE,(LPARAM)NULL);
+ break;
+ case SDSDT_STANDBY:
+ case SDSDT_HIBERNATE:
+ WinNT_SetPrivilege(SE_SHUTDOWN_NAME,TRUE);
+ if(!SetSystemPowerState(shutdownType==SDSDT_STANDBY,TRUE))
+ dwErrCode=GetLastError();
+ WinNT_SetPrivilege(SE_SHUTDOWN_NAME,FALSE);
+ break;
+ case SDSDT_LOCKWORKSTATION:
+ { BOOL (WINAPI *pfnLockWorkStation)(void);
+ *(PROC*)&pfnLockWorkStation=GetProcAddress(GetModuleHandleA("USER32"),"LockWorkStation");
+ if(pfnLockWorkStation!=NULL) /* Win2000+ */
+ if(!pfnLockWorkStation() && !WinNT_IsWorkStationLocked())
+ dwErrCode=GetLastError();
+ else if(IsWinVerNT()) { /* WinNT4 */
+ HKEY hKey;
+ /* start LOGON.SCR screensaver (locks workstation on NT4) */
+ if(!SearchPath(NULL,_T("LOGIN.SCR"),NULL,0,NULL,NULL)) {
+ if(RegCreateKeyEx(HKEY_CURRENT_USER,_T("Control Panel\\Desktop"),0,NULL,REG_OPTION_VOLATILE,KEY_QUERY_VALUE|KEY_SET_VALUE,NULL,&hKey,NULL)==ERROR_SUCCESS) {
+ TCHAR szScreenSaveActive[2],szScreenSaverIsSecure[2],szScrnsaveExe[MAX_PATH];
+ DWORD dwSize;
+ /* save old settings */
+ dwSize=sizeof(szScreenSaveActive); /* in bytes */
+ ZeroMemory(&szScreenSaveActive,dwSize);
+ RegQueryValueEx(hKey,_T("ScreenSaveActive"),0,NULL,(void*)szScreenSaveActive,&dwSize);
+ dwSize=sizeof(szScreenSaverIsSecure); /* in bytes */
+ ZeroMemory(&szScreenSaverIsSecure, dwSize);
+ RegQueryValueEx(hKey,_T("ScreenSaverIsSecure"),0,NULL,(void*)szScreenSaverIsSecure,&dwSize);
+ dwSize=sizeof(szScrnsaveExe); /* in bytes */
+ ZeroMemory(&szScrnsaveExe,dwSize);
+ RegQueryValueEx(hKey,_T("SCRNSAVE.EXE"),0,NULL,(void*)szScrnsaveExe,&dwSize);
+ /* set LOGON.SCR data */
+ if(!RegSetValueEx(hKey,_T("ScreenSaveActive"),0,REG_SZ,(void*)_T("1"),2) &&
+ !RegSetValueEx(hKey,_T("ScreenSaverIsSecure"),0,REG_SZ,(void*)"1",2) &&
+ !RegSetValueEx(hKey,_T("SCRNSAVE.EXE"),0,REG_SZ,(void*)_T("LOGIN.SCR"),10))
+ SendMessage(GetForegroundWindow(),WM_SYSCOMMAND,SC_SCREENSAVE,0);
+ else dwErrCode=GetLastError();
+ /* restore old settings */
+ RegSetValueEx(hKey,_T("ScreenSaveActive"),0,REG_SZ,(void*)szScreenSaveActive,(lstrlen(szScreenSaveActive)+1)*sizeof(TCHAR));
+ RegSetValueEx(hKey,_T("ScreenSaverIsSecure"),0,REG_SZ,(void*)szScreenSaverIsSecure,(lstrlen(szScreenSaverIsSecure)+1)*sizeof(TCHAR));
+ RegSetValueEx(hKey,_T("SCRNSAVE.EXE"),0,REG_SZ,(void*)szScrnsaveExe,(lstrlen(szScrnsaveExe)+1)*sizeof(TCHAR));
+ RegCloseKey(hKey);
+ } else dwErrCode=GetLastError();
+ } else dwErrCode=GetLastError();
+ } else dwErrCode=GetLastError();
+ }
+ break;
+ case SDSDT_CLOSERASCONNECTIONS:
+ ShutdownNow(SDSDT_SETMIRANDAOFFLINE); /* set Miranda offline */
+ /* hang up all ras connections */
+ { HMODULE hRasApiDLL=LoadLibrary(_T("RASAPI32")); /* all ascii */
+ if(hRasApiDLL!=NULL) {
+ DWORD (APIENTRY *pfnRasEnumConnections)(RASCONN*,DWORD*,DWORD*);
+ DWORD (APIENTRY *pfnRasHangUp)(HRASCONN);
+ DWORD (APIENTRY *pfnRasGetConnectStatus)(HRASCONN,RASCONNSTATUS*);
+ #if defined(_UNICODE)
+ *(PROC*)&pfnRasEnumConnections=GetProcAddress(hRasApiDLL,"RasEnumConnectionsW");
+ *(PROC*)&pfnRasHangUp=GetProcAddress(hRasApiDLL,"RasHangUpW");
+ *(PROC*)&pfnRasGetConnectStatus=GetProcAddress(hRasApiDLL,"RasGetConnectStatusW");
+ #else
+ *(PROC*)&pfnRasEnumConnections=GetProcAddress(hRasApiDLL,"RasEnumConnectionsA");
+ *(PROC*)&pfnRasHangUp=GetProcAddress(hRasApiDLL,"RasHangUpA");
+ *(PROC*)&pfnRasGetConnectStatus=GetProcAddress(hRasApiDLL,"RasGetConnectStatusA");
+ #endif
+ if(pfnRasEnumConnections && pfnRasGetConnectStatus && pfnRasHangUp) {
+ RASCONN *paConn;
+ RASCONN *paConnBuf;
+ DWORD dwConnSize,dwConnItems,dwRetries;
+ RASCONNSTATUS rcs;
+ DWORD dw,dwLastTickCount;
+
+ dwConnSize=sizeof(RASCONN);
+ dwConnItems=0;
+ paConn=(RASCONN*)mir_alloc(dwConnSize);
+ dwErrCode=ERROR_NOT_ENOUGH_MEMORY;
+ if(paConn!=NULL)
+ for(dwRetries=5;dwRetries!=0;dwRetries--) { /* prevent infinite loop (rare) */
+ ZeroMemory(paConn,dwConnSize);
+ paConn[0].dwSize=sizeof(RASCONN);
+ dwErrCode=pfnRasEnumConnections(paConn,&dwConnSize,&dwConnItems);
+ if(dwErrCode!=ERROR_BUFFER_TOO_SMALL) break;
+ paConnBuf=(RASCONN*)mir_realloc(paConn,dwConnSize);
+ if(paConnBuf!=NULL) {
+ mir_free(paConn);
+ paConn=NULL;
+ dwErrCode=ERROR_NOT_ENOUGH_MEMORY;
+ break;
+ }
+ paConn=paConnBuf;
+ }
+ if(dwErrCode==ERROR_SUCCESS || dwErrCode==ERROR_BUFFER_TOO_SMALL) {
+ for(dw=0;dw<dwConnItems;++dw) {
+ if(dwErrCode) {
+ if(pfnRasHangUp(paConn[dw].hrasconn))
+ paConn[dw].hrasconn=NULL; /* do not wait for on error */
+ } else {
+ dwErrCode=pfnRasHangUp(paConn[dw].hrasconn);
+ if(!dwErrCode) paConn[dw].hrasconn=NULL; /* do not wait for on error */
+ }
+ }
+ /* RAS does not allow to quit directly after HangUp (see docs) */
+ dwLastTickCount=GetTickCount();
+ ZeroMemory(&rcs,sizeof(RASCONNSTATUS));
+ rcs.dwSize=sizeof(RASCONNSTATUS);
+ for(dw=0;dw<dwConnItems;++dw)
+ if(paConn[dw].hrasconn!=NULL)
+ while(pfnRasGetConnectStatus(paConn[dw].hrasconn, &rcs)!=ERROR_INVALID_HANDLE) {
+ Sleep(0); /* give rest of time silce to other threads with equal priority */
+ /* infinite loop protection (3000ms defined in docs) */
+ dwRetries=GetTickCount();
+ if(dwRetries-dwLastTickCount>3000) break; /* wraparound works */
+ }
+ }
+ mir_free(paConn); /* does NULL check */
+ } else dwErrCode=GetLastError();
+ FreeLibrary(hRasApiDLL);
+ } else dwErrCode=GetLastError();
+ }
+ /* set Miranda to offline again, to remain offline with reconnection plugins */
+ ShutdownNow(SDSDT_SETMIRANDAOFFLINE);
+ break;
+ case SDSDT_REBOOT:
+ case SDSDT_SHUTDOWN:
+ if(GetSystemMetrics(SM_SHUTTINGDOWN)) { /* Win2000+, 0 on error */
+ dwErrCode=ERROR_SHUTDOWN_IN_PROGRESS;
+ break;
+ }
+ /* WinNT4/2000/XP */
+ { BOOL (WINAPI *pfnInitiateSystemShutdownEx)(const TCHAR*,const TCHAR*,DWORD,BOOL,BOOL,DWORD);
+ BOOL (WINAPI *pfnInitiateSystemShutdown)(const TCHAR*,const TCHAR*,DWORD,BOOL,BOOL);
+ #if defined(_UNICODE)
+ *(PROC*)&pfnInitiateSystemShutdownEx=GetProcAddress(GetModuleHandleA("ADVAPI32"),"InitiateSystemShutdownExW");
+ *(PROC*)&pfnInitiateSystemShutdown=GetProcAddress(GetModuleHandleA("ADVAPI32"),"InitiateSystemShutdownW");
+ #else
+ *(PROC*)&pfnInitiateSystemShutdownEx=GetProcAddress(GetModuleHandleA("ADVAPI32"),"InitiateSystemShutdownExA");
+ *(PROC*)&pfnInitiateSystemShutdown=GetProcAddress(GetModuleHandleA("ADVAPI32"),"InitiateSystemShutdownA");
+ #endif
+ if(pfnInitiateSystemShutdownEx!=NULL || pfnInitiateSystemShutdown!=NULL) {
+ WinNT_SetPrivilege(SE_SHUTDOWN_NAME,TRUE);
+
+ /* does not send out WM_ENDSESSION messages, so we do it manually to
+ * give the applications the chance to save their data */
+ WinNT_SetPrivilege(SE_TCB_NAME,TRUE); /* for BSM_ALLDESKTOPS */
+ BroadcastEndSession(BSM_APPLICATIONS|BSM_ALLDESKTOPS,ENDSESSION_CLOSEAPP); /* app should close itself */
+ WinNT_SetPrivilege(SE_TCB_NAME,FALSE);
+
+ if(pfnInitiateSystemShutdownEx!=NULL) {
+ if(!pfnInitiateSystemShutdownEx(NULL,TranslateT("AutoShutdown"),0,TRUE,shutdownType==SDSDT_REBOOT,SHTDN_REASON_MAJOR_OTHER|SHTDN_REASON_MINOR_OTHER|SHTDN_REASON_FLAG_PLANNED))
+ dwErrCode=GetLastError();
+ } else if(!pfnInitiateSystemShutdown(NULL,TranslateT("AutoShutdown"),0,TRUE,shutdownType==SDSDT_REBOOT))
+ dwErrCode=GetLastError();
+
+ /* cleanly close Miranda */
+ if(!dwErrCode) ShutdownNow(SDSDT_CLOSEMIRANDA);
+ break;
+ }
+ }
+ /* fall through for Win9x */
+ case SDSDT_LOGOFF:
+ { UINT flags;
+ switch(shutdownType) {
+ case SDSDT_LOGOFF: flags=EWX_LOGOFF; break;
+ case SDSDT_REBOOT: flags=EWX_REBOOT; break;
+ default: flags=EWX_SHUTDOWN|EWX_POWEROFF;
+ }
+ if(shutdownType==SDSDT_LOGOFF && IsWinVer2000Plus() && !WinNT_IsWorkStationLocked())
+ flags|=EWX_FORCEIFHUNG; /* only considered for WM_ENDSESSION messages */
+ else flags|=EWX_FORCE; /* must be used when workstation locked */
+
+ if(flags&EWX_FORCE) {
+ /* EWX_FORCE does not send out WM_ENDSESSION messages, so we do it
+ * manually to give the applications the chance to save their data */
+ BroadcastEndSession(BSM_APPLICATIONS,(shutdownType==SDSDT_LOGOFF)?ENDSESSION_LOGOFF:0);
+
+ /* Windows Me/98/95 (msdn): Because of the design of the shell,
+ * calling ExitWindowsEx with EWX_FORCE fails to completely log off
+ * the user (the system terminates the applications and displays the
+ * Enter Windows Password dialog box, however, the user's desktop remains.)
+ * To log off the user forcibly, terminate the Explorer process before calling
+ * ExitWindowsEx with EWX_LOGOFF and EWX_FORCE. */
+ #if !defined(_UNICODE)
+ if(shutdownType==SDSDT_LOGOFF && !IsWinVerNT()) Win9x_TerminateExplorer();
+ #endif
+ }
+ if(!ExitWindowsEx(flags,SHTDN_REASON_MAJOR_OTHER|SHTDN_REASON_MINOR_OTHER|SHTDN_REASON_FLAG_PLANNED))
+ dwErrCode=GetLastError();
+ /* cleanly close Miranda */
+ if(!dwErrCode) ShutdownNow(SDSDT_CLOSEMIRANDA);
+ }
+ break;
+ }
+ return dwErrCode;
+}
+
+/************************* Shutdown Dialog ****************************/
+
+#define M_START_SHUTDOWN (WM_APP+111)
+#define M_UPDATE_COUNTDOWN (WM_APP+112)
+static BOOL CALLBACK ShutdownDlgProc(HWND hwndDlg,UINT msg,WPARAM wParam,LPARAM lParam)
+{
+ BYTE shutdownType=(BYTE)GetWindowLong(hwndDlg,DWL_USER);
+ WORD countdown=(WORD)GetWindowLong(GetDlgItem(hwndDlg,IDC_TEXT_HEADER),GWL_USERDATA);
+ static BOOL (WINAPI *pfnLockSetForegroundWindow)(UINT);
+
+ switch(msg) {
+ case WM_INITDIALOG:
+ hwndShutdownDlg=hwndDlg;
+ SetWindowLong(hwndDlg,DWL_USER,(LONG)lParam);
+ TranslateDialogDefault(hwndDlg);
+
+ if(lParam==SDSDT_SHUTDOWN || lParam==SDSDT_REBOOT || lParam==SDSDT_LOGOFF)
+ ShowWindow(GetDlgItem(hwndDlg,IDC_TEXT_UNSAVEDWARNING),SW_SHOW);
+ SendDlgItemMessage(hwndDlg,IDC_ICON_HEADER,STM_SETIMAGE,IMAGE_ICON,(LPARAM)IcoLib_GetIcon("AutoShutdown_Header"));
+ { HFONT hBoldFont;
+ LOGFONT lf;
+ if(GetObject((HFONT)SendDlgItemMessage(hwndDlg,IDC_TEXT_HEADER,WM_GETFONT,0,0),sizeof(lf),&lf)) {
+ lf.lfWeight=FW_BOLD;
+ hBoldFont=CreateFontIndirect(&lf);
+ }
+ else hBoldFont=NULL;
+ SendDlgItemMessage(hwndDlg,IDC_TEXT_HEADER,WM_SETFONT,(WPARAM)hBoldFont,FALSE);
+ SetWindowLong(GetDlgItem(hwndDlg,IDC_TEXT_HEADER),GWL_USERDATA,(LONG)hBoldFont);
+ }
+ { WORD countdown=DBGetContactSettingWord(NULL,"AutoShutdown","ConfirmDlgCountdown",SETTING_CONFIRMDLGCOUNTDOWN_DEFAULT);
+ if(countdown<3) countdown=SETTING_CONFIRMDLGCOUNTDOWN_DEFAULT;
+ SetWindowLong(GetDlgItem(hwndDlg,IDC_TEXT_HEADER),GWL_USERDATA,countdown);
+ SendMessage(hwndDlg,M_UPDATE_COUNTDOWN,0,countdown);
+ }
+ SkinPlaySound("AutoShutdown_Countdown");
+ if(!SetTimer(hwndDlg,1,1000,NULL)) PostMessage(hwndDlg,M_START_SHUTDOWN,0,0);
+ Utils_RestoreWindowPositionNoSize(hwndDlg,NULL,"AutoShutdown","ConfirmDlg_");
+
+ /* disallow foreground window changes (WinMe/2000+) */
+ SetForegroundWindow(hwndDlg);
+ *(PROC*)&pfnLockSetForegroundWindow=GetProcAddress(GetModuleHandleA("USER32"),"LockSetForegroundWindow");
+ if(pfnLockSetForegroundWindow!=NULL)
+ pfnLockSetForegroundWindow(LSFW_LOCK);
+
+ SendMessage(hwndDlg,WM_NEXTDLGCTL,(WPARAM)GetDlgItem(hwndDlg,IDCANCEL),TRUE);
+ return FALSE; /* focus set on cancel */
+ case WM_DESTROY:
+ { HFONT hFont;
+ HICON hIcon;
+ hwndShutdownDlg=NULL;
+ ShowWindow(hwndDlg,SW_HIDE);
+ /* reallow foreground window changes (WinMe/2000+) */
+ if(pfnLockSetForegroundWindow) pfnLockSetForegroundWindow(LSFW_UNLOCK);
+ Utils_SaveWindowPosition(hwndDlg,NULL,"AutoShutdown","ConfirmDlg_");
+ hIcon=(HICON)SendDlgItemMessage(hwndDlg,IDC_ICON_HEADER,STM_SETIMAGE,IMAGE_ICON,(LPARAM)NULL);
+ IcoLib_ReleaseIcon(hIcon); /* does NULL check */
+ hFont=(HFONT)SendDlgItemMessage(hwndDlg,IDC_TEXT_HEADER,WM_GETFONT,0,0);
+ SendDlgItemMessage(hwndDlg,IDC_TEXT_HEADER,WM_SETFONT,(WPARAM)NULL,FALSE); /* no return value */
+ if(hFont!=NULL) DeleteObject(hFont);
+ return TRUE;
+ }
+ case M_START_SHUTDOWN:
+ if(IsWindowEnabled(GetDlgItem(hwndDlg,IDC_BUTTON_SHUTDOWNNOW))) {
+ DWORD dwErrCode;
+ EnableWindow(GetDlgItem(hwndDlg,IDC_BUTTON_SHUTDOWNNOW),FALSE);
+ ShowWindow(hwndDlg,SW_HIDE); /* get rid of the dialog immediately */
+ dwErrCode=ShutdownNow(shutdownType);
+ if(dwErrCode!=ERROR_SUCCESS) {
+ char *pszErr;
+ pszErr=GetWinErrorDescription(dwErrCode);
+ ShowInfoMessage(NIIF_ERROR,Translate("Automatic Shutdown Error"),Translate("The shutdown process failed!\nReason: %s"),(pszErr!=NULL)?pszErr:Translate("Unknown"));
+ if(pszErr!=NULL) LocalFree(pszErr);
+ }
+ DestroyWindow(hwndDlg);
+ }
+ return TRUE;
+ case WM_TIMER:
+ if(countdown) {
+ --countdown;
+ SetWindowLong(GetDlgItem(hwndDlg,IDC_TEXT_HEADER),GWL_USERDATA,countdown);
+ if(countdown==27 || countdown==24 || countdown==21 || countdown==19 ||
+ countdown==17 || countdown==15 || countdown==13 || countdown==11 ||
+ countdown<=10)
+ SkinPlaySound("AutoShutdown_Countdown");
+ }
+ else KillTimer(hwndDlg,wParam); /* countdown finished */
+ PostMessage(hwndDlg,M_UPDATE_COUNTDOWN,0,countdown);
+ return TRUE;
+ case M_UPDATE_COUNTDOWN: /* lParam=(WORD)countdown */
+ { TCHAR szText[256];
+ TCHAR *desc[]={_T("Miranda IM is going to be automatically closed in %u second(s)."),
+ _T("All Miranda IM protocols are going to be set to offline in %u second(s)."),
+ _T("You will be logged off automatically in %u second(s)."),
+ _T("The computer will automatically be restarted in %u second(s)."),
+ _T("The computer will automatically be set to standby mode in %u second(s)."),
+ _T("The computer will automatically be set to hibernate mode in %u second(s)."),
+ _T("The workstation will automatically get locked in %u second(s)."),
+ _T("All dialup connections will be closed in %u second(s)."),
+ _T("The computer will automatically be shut down in %u second(s).")};
+ mir_sntprintf(szText,SIZEOF(szText),TranslateTS(desc[shutdownType-1]),lParam);
+ SetDlgItemText(hwndDlg,IDC_TEXT_HEADER,szText);
+ /* countdown finished */
+ if(!lParam) PostMessage(hwndDlg,M_START_SHUTDOWN,0,0);
+ return TRUE;
+ }
+ case WM_COMMAND:
+ switch(LOWORD(wParam)) {
+ case IDC_BUTTON_SHUTDOWNNOW:
+ KillTimer(hwndDlg,1);
+ SetWindowLong(GetDlgItem(hwndDlg,IDC_TEXT_HEADER),GWL_USERDATA,0);
+ SendMessage(hwndDlg,M_UPDATE_COUNTDOWN,0,(LONG)0);
+ PostMessage(hwndDlg,M_START_SHUTDOWN,0,0);
+ return TRUE;
+ case IDCANCEL: /* WM_CLOSE */
+ if(countdown) {
+ KillTimer(hwndDlg,1);
+ DestroyWindow(hwndDlg);
+ }
+ return TRUE;
+ }
+ break;
+ }
+ return FALSE;
+}
+
+/************************* Services ***********************************/
+
+int ServiceShutdown(WPARAM wParam,LPARAM lParam)
+{
+ /* passing 0 as wParam is only to be used internally, undocumented */
+ if(!wParam) wParam=DBGetContactSettingByte(NULL,"AutoShutdown","ShutdownType",SETTING_SHUTDOWNTYPE_DEFAULT);
+ if(!IsShutdownTypeEnabled((BYTE)wParam)) return 1; /* does shutdownType range check */
+ if((BOOL)lParam && hwndShutdownDlg!=NULL) return 2;
+
+ /* ask others if allowed */
+ if(NotifyEventHooks(hEventOkToShutdown,wParam,lParam)) {
+ OutputDebugStringA("automatic shutdown denied by event hook\n"); /* all ascii */
+ return 3;
+ }
+ /* tell others */
+ NotifyEventHooks(hEventShutdown,wParam,lParam);
+ /* show dialog */
+ if(lParam && DBGetContactSettingByte(NULL,"AutoShutdown","ShowConfirmDlg",SETTING_SHOWCONFIRMDLG_DEFAULT))
+ if(CreateDialogParam(hInst,MAKEINTRESOURCE(IDD_SHUTDOWNNOW),NULL,ShutdownDlgProc,(LPARAM)(BYTE)wParam)!=NULL)
+ return 0;
+ /* show error */
+ { DWORD dwErrCode;
+ dwErrCode=ShutdownNow((BYTE)wParam);
+ if(dwErrCode!=ERROR_SUCCESS) {
+ char *pszErr;
+ pszErr=GetWinErrorDescription(dwErrCode);
+ ShowInfoMessage(NIIF_ERROR,Translate("Automatic Shutdown Error"),Translate("Inititiating the shutdown process failed!\nReason: %s"),(pszErr!=NULL)?pszErr:Translate("Unknown"));
+ if(pszErr!=NULL) LocalFree(pszErr);
+ return 4;
+ }
+ }
+ return 0;
+}
+
+int ServiceIsTypeEnabled(WPARAM wParam,LPARAM lParam)
+{
+ UNREFERENCED_PARAMETER(lParam);
+ return IsShutdownTypeEnabled((BYTE)wParam); /* does shutdownType range check */
+}
+
+int ServiceGetTypeDescription(WPARAM wParam,LPARAM lParam)
+{
+ TCHAR *pszDesc;
+ const TCHAR *apszShort[]={_T("Close Miranda IM"),_T("Set Miranda IM offline"),_T("Log off user"),
+ _T("Restart computer"),_T("Shutdown computer"),_T("Standby mode"),_T("Hibernate mode"),
+ _T("Lock workstation"),_T("Hang up dialup connections"),_T("Close Miranda IM"),
+ _T("Set Miranda IM offline"),_T("Log off user"),_T("Restart computer"),_T("Shutdown computer"),
+ _T("Standby mode"),_T("Hibernate mode"),_T("Lock workstation"),_T("Hang up dialup connections")};
+ const TCHAR *apszLong[]={_T("Sets all Miranda IM protocols to offline and closes Miranda IM."),
+ _T("Sets all Miranda IM protocols to offline."),
+ _T("Logs the current Windows user off so that another user can log in."),
+ _T("Shuts down Windows and then restarts Windows."),
+ _T("Closes all running programs and shuts down Windows to a point at which it is safe to turn off the power."),
+ _T("Saves the current Windows session in memory and sets the system to suspend mode."),
+ _T("Saves the current Windows session on harddisc, so that the power can be turned off."),
+ _T("Locks the computer. To unlock the computer, you must log in."),
+ _T("Sets all protocols to offline and closes all RAS connections.")};
+ /* shutdownType range check */
+ if(!wParam || (BYTE)wParam>SDSDT_MAX) return (int)NULL;
+ /* select description */
+ pszDesc=(TCHAR*)((lParam&GSTDF_LONGDESC)?apszLong:apszShort)[wParam-1];
+ if(!(lParam&GSTDF_UNTRANSLATED)) pszDesc=TranslateTS(pszDesc);
+ /* convert as needed */
+ #if defined(_UNICODE)
+ if(!(lParam&GSTDF_UNICODE)) {
+ static char szConvBuf[128];
+ char *buf=u2a(pszDesc);
+ if(buf==NULL) return (int)NULL;
+ lstrcpynA(szConvBuf,buf,sizeof(szConvBuf));
+ mir_free(buf);
+ return (int)szConvBuf;
+ }
+ #else
+ if(lParam&GSTDF_UNICODE) {
+ static WCHAR szConvBuf[128];
+ WCHAR *buf=a2u(pszDesc);
+ if(buf==NULL) return (int)NULL;
+ lstrcpynW(szConvBuf,buf,SIZEOF(szConvBuf));
+ mir_free(buf);
+ return (int)szConvBuf;
+ }
+ #endif
+ return (int)pszDesc;
+}
+
+/************************* Misc ***************************************/
+
+void InitShutdownSvc(void)
+{
+ /* Shutdown Dialog */
+ hwndShutdownDlg=NULL;
+ SkinAddNewSoundBundled("AutoShutdown_Countdown",Translate("Alerts"),Translate("Automatic Shutdown Countdown"),"Sounds\\","countdown.wav");
+ /* Services */
+ hEventOkToShutdown=CreateHookableEvent(ME_AUTOSHUTDOWN_OKTOSHUTDOWN);
+ hEventShutdown=CreateHookableEvent(ME_AUTOSHUTDOWN_SHUTDOWN);
+ hServiceShutdown=CreateServiceFunction(MS_AUTOSHUTDOWN_SHUTDOWN,ServiceShutdown);
+ hServiceIsTypeEnabled=CreateServiceFunction(MS_AUTOSHUTDOWN_ISTYPEENABLED,ServiceIsTypeEnabled);
+ hServiceGetTypeDesc=CreateServiceFunction(MS_AUTOSHUTDOWN_GETTYPEDESCRIPTION,ServiceGetTypeDescription);
+}
+
+void UninitShutdownSvc(void)
+{
+ /* Shutdown Dialog */
+ if(hwndShutdownDlg!=NULL) DestroyWindow(hwndShutdownDlg);
+ /* Services */
+ DestroyServiceFunction(hServiceShutdown);
+ DestroyServiceFunction(hServiceIsTypeEnabled);
+ DestroyServiceFunction(hServiceGetTypeDesc);
+ DestroyHookableEvent(hEventOkToShutdown);
+ DestroyHookableEvent(hEventShutdown);
+}
diff --git a/plugins/AutoShutdown/shutdownsvc.h b/plugins/AutoShutdown/shutdownsvc.h
new file mode 100644
index 0000000000..412db18ee6
--- /dev/null
+++ b/plugins/AutoShutdown/shutdownsvc.h
@@ -0,0 +1,29 @@
+/*
+
+'AutoShutdown'-Plugin for Miranda IM
+
+Copyright 2004-2007 H. Herkenrath
+
+This program is free software; you can redistribute it and/or
+modify it under the terms of the GNU General Public License
+as published by the Free Software Foundation; either version 2
+of the License, or (at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program (Shutdown-License.txt); if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+*/
+
+/* Services */
+int ServiceShutdown(WPARAM wParam,LPARAM lParam);
+int ServiceIsTypeEnabled(WPARAM wParam,LPARAM lParam);
+int ServiceGetTypeDescription(WPARAM wParam,LPARAM lParam);
+
+/* Misc */
+void InitShutdownSvc(void);
+void UninitShutdownSvc(void);
diff --git a/plugins/AutoShutdown/utils.c b/plugins/AutoShutdown/utils.c
new file mode 100644
index 0000000000..b9bbddbc01
--- /dev/null
+++ b/plugins/AutoShutdown/utils.c
@@ -0,0 +1,458 @@
+/*
+
+'AutoShutdown'-Plugin for Miranda IM
+
+Copyright 2004-2007 H. Herkenrath
+
+This program is free software; you can redistribute it and/or
+modify it under the terms of the GNU General Public License
+as published by the Free Software Foundation; either version 2
+of the License, or (at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program (Shutdown-License.txt); if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+*/
+
+#include "common.h"
+
+/************************* String *********************************/
+
+// mir_free() the return value
+#if !defined(_UNICODE)
+WCHAR* a2u(const char *pszAnsi)
+{
+ int codepage,cch;
+ WCHAR *psz;
+
+ if(pszAnsi==NULL) return NULL;
+ codepage=CallService(MS_LANGPACK_GETCODEPAGE,0,0);
+ cch=MultiByteToWideChar(codepage,0,pszAnsi,-1,NULL,0);
+ if(!cch) return NULL;
+
+ psz=(WCHAR*)mir_alloc(cch*sizeof(WCHAR));
+ if(psz!=NULL && !MultiByteToWideChar(codepage,0,pszAnsi,-1,psz,cch)) {
+ mir_free(psz);
+ return NULL;
+ }
+ return psz;
+}
+#endif
+
+// mir_free() the return value
+#if defined(_UNICODE)
+char* u2a(const WCHAR *pszUnicode)
+{
+ int codepage,cch;
+ char *psz;
+ DWORD flags;
+
+ if(pszUnicode==NULL) return NULL;
+ codepage=CallService(MS_LANGPACK_GETCODEPAGE,0,0);
+ /* without WC_COMPOSITECHECK some characters might get out strange (see MS blog) */
+ cch=WideCharToMultiByte(codepage,flags=WC_COMPOSITECHECK,pszUnicode,-1,NULL,0,NULL,NULL);
+ if(!cch) cch=WideCharToMultiByte(codepage,flags=0,pszUnicode,-1,NULL,0,NULL,NULL);
+ if(!cch) return NULL;
+
+ psz=(char*)mir_alloc(cch);
+ if(psz!=NULL && !WideCharToMultiByte(codepage,flags,pszUnicode,-1,psz,cch,NULL,NULL)){
+ mir_free(psz);
+ return NULL;
+ }
+ return psz;
+}
+#endif
+
+void TrimString(TCHAR *pszStr)
+{
+ int i;
+ TCHAR *psz,szChars[]=_T(" \r\n\t");
+ for(i=0;i<SIZEOF(szChars);++i) {
+ /* trim end */
+ psz=&pszStr[lstrlen(pszStr)-1];
+ while(pszStr[0] && *psz==szChars[i]) {
+ *psz=0;
+ psz=CharPrev(pszStr,psz);
+ }
+ /* trim beginning */
+ for(psz=pszStr;(*psz && *psz==szChars[i]);psz=CharNext(psz));
+ MoveMemory(pszStr,psz,(lstrlen(psz)+1)*sizeof(TCHAR));
+ }
+}
+
+/************************* Error Output ***************************/
+
+static void MessageBoxIndirectFree(MSGBOXPARAMSA *mbp)
+{
+ MessageBoxIndirectA(mbp);
+ mir_free((char*)mbp->lpszCaption); /* does NULL check */
+ mir_free((char*)mbp->lpszText); /* does NULL check */
+ mir_free(mbp);
+}
+
+void ShowInfoMessage(BYTE flags,const char *pszTitle,const char *pszTextFmt,...)
+{
+ char szText[256]; /* max for systray */
+ MSGBOXPARAMSA *mbp;
+
+ va_list va;
+ va_start(va,pszTextFmt);
+ mir_vsnprintf(szText,SIZEOF(szText),pszTextFmt,va);
+ va_end(va);
+
+ if(ServiceExists(MS_CLIST_SYSTRAY_NOTIFY)) {
+ MIRANDASYSTRAYNOTIFY msn;
+ msn.cbSize=sizeof(msn);
+ msn.szProto=NULL;
+ msn.szInfoTitle=(char*)pszTitle;
+ msn.szInfo=(char*)szText;
+ msn.uTimeout=30000; /* max timeout */
+ msn.dwInfoFlags=flags;
+ if(!CallServiceSync(MS_CLIST_SYSTRAY_NOTIFY,0,(LPARAM)&msn))
+ return; /* success */
+ }
+
+ mbp=(MSGBOXPARAMSA*)mir_calloc(sizeof(*mbp));
+ if(mbp==NULL) return;
+ mbp->cbSize=sizeof(*mbp);
+ mbp->lpszCaption=mir_strdup(pszTitle);
+ mbp->lpszText=mir_strdup(szText);
+ mbp->dwStyle=MB_OK|MB_SETFOREGROUND|MB_TASKMODAL;
+ mbp->dwLanguageId=LANGIDFROMLCID((LCID)CallService(MS_LANGPACK_GETLOCALE,0,0));
+ switch(flags&NIIF_ICON_MASK) {
+ case NIIF_INFO: mbp->dwStyle|=MB_ICONINFORMATION; break;
+ case NIIF_WARNING: mbp->dwStyle|=MB_ICONWARNING; break;
+ case NIIF_ERROR: mbp->dwStyle|=MB_ICONERROR;
+ }
+ mir_forkthread(MessageBoxIndirectFree,mbp);
+}
+
+// LocalFree() the return value
+char* GetWinErrorDescription(DWORD dwLastError)
+{
+ char *buf=NULL;
+ DWORD flags=FORMAT_MESSAGE_ALLOCATE_BUFFER|FORMAT_MESSAGE_FROM_SYSTEM;
+ if(!FormatMessageA(flags,NULL,dwLastError,LANGIDFROMLCID((LCID)CallService(MS_LANGPACK_GETLOCALE,0,0)),(char*)&buf,0,NULL))
+ if(GetLastError()==ERROR_RESOURCE_LANG_NOT_FOUND)
+ FormatMessageA(flags,NULL,dwLastError,0,(char*)&buf,0,NULL);
+ return buf;
+}
+
+/************************* Time ***********************************/
+
+BOOL SystemTimeToTimeStamp(SYSTEMTIME *st,time_t *timestamp)
+{
+ struct tm ts;
+ ts.tm_isdst=-1; /* daylight saving time (-1=compute) */
+ ts.tm_sec=st->wSecond; /* 0-59 */
+ ts.tm_min=st->wMinute; /* 0-59 */
+ ts.tm_hour=st->wHour; /* 0-23 */
+ ts.tm_mday=st->wDay; /* 1-31 */
+ ts.tm_wday=st->wDayOfWeek; /* 0-6 (Sun-Sat) */
+ ts.tm_mon=st->wMonth-1; /* 0-11 (Jan-Dec) */
+ ts.tm_year=st->wYear-1900; /* current year minus 1900 */
+ ts.tm_yday=0; /* 0-365 (Jan1=0) */
+ *timestamp=mktime(&ts);
+ return (*timestamp!=-1);
+}
+
+BOOL TimeStampToSystemTime(time_t timestamp,SYSTEMTIME *st)
+{
+ struct tm *ts;
+ ts=localtime(&timestamp); /* statically alloced, local time correction */
+ if(ts==NULL) return FALSE;
+ st->wMilliseconds=0; /* 0-999 (not given in tm) */
+ st->wSecond=(WORD)ts->tm_sec; /* 0-59 */
+ st->wMinute=(WORD)ts->tm_min; /* 0-59 */
+ st->wHour=(WORD)ts->tm_hour; /* 0-23 */
+ st->wDay=(WORD)ts->tm_mday; /* 1-31 */
+ st->wDayOfWeek=(WORD)ts->tm_wday; /* 0-6 (Sun-Sat) */
+ st->wMonth=(WORD)(ts->tm_mon+1); /* 1-12 (Jan-Dec) */
+ st->wYear=(WORD)(ts->tm_year+1900); /* 1601-30827 */
+ return TRUE;
+}
+
+BOOL GetFormatedCountdown(TCHAR *pszOut,int nSize,time_t countdown)
+{
+ static BOOL fInited=FALSE;
+ static int (WINAPI *pfnStrFromTimeInterval)(TCHAR*,UINT,DWORD,int);
+ #if defined(_UNICODE)
+ static int (WINAPI *pfnGetDurationFormat)(LCID,DWORD,const SYSTEMTIME*,double,WCHAR*,WCHAR*,int);
+ #endif
+ /* Init */
+ if(!fInited) {
+ #if defined(_UNICODE)
+ *(PROC*)&pfnGetDurationFormat=GetProcAddress(GetModuleHandleA("KERNEL32"),"GetDurationFormat");
+ if(pfnGetDurationFormat==NULL) {
+ #endif
+ HMODULE hShlwDLL=LoadLibraryA("SHLWAPI"); /* all ascii */
+ #if defined(_UNICODE)
+ *(PROC*)&pfnStrFromTimeInterval=GetProcAddress(hShlwDLL,"StrFromTimeIntervalW");
+ #else
+ *(PROC*)&pfnStrFromTimeInterval=GetProcAddress(hShlwDLL,"StrFromTimeIntervalA");
+ #endif
+ #if defined(_UNICODE)
+ }
+ #endif
+ fInited=TRUE;
+ }
+ /* WinVista */
+ #if defined(_UNICODE)
+ if(pfnGetDurationFormat!=NULL) {
+ SYSTEMTIME st;
+ LCID locale;
+ locale=(LCID)CallService(MS_LANGPACK_GETLOCALE,0,0);
+ if(TimeStampToSystemTime(countdown,&st))
+ if(pfnGetDurationFormat(locale,0,&st,0,NULL,pszOut,nSize))
+ return TRUE;
+ return FALSE;
+ }
+ #endif
+ /* Win9x/NT/XP */
+ if(pfnStrFromTimeInterval!=NULL)
+ return pfnStrFromTimeInterval(pszOut,nSize,(countdown>(MAXDWORD/1000))?MAXDWORD:(countdown*1000),10)!=0;
+ return FALSE;
+}
+
+BOOL GetFormatedDateTime(TCHAR *pszOut,int nSize,time_t timestamp,BOOL fShowDateEvenToday)
+{
+ SYSTEMTIME st,stNow;
+ LCID locale;
+ locale=(LCID)CallService(MS_LANGPACK_GETLOCALE,0,0);
+ GetLocalTime(&stNow);
+ TimeStampToSystemTime(timestamp,&st);
+ /* today: no need to show the date */
+ if(!fShowDateEvenToday && st.wDay==stNow.wDay && st.wMonth==stNow.wMonth && st.wYear==stNow.wYear)
+ return GetTimeFormat(locale,((st.wSecond==0)?TIME_NOSECONDS:0)|TIME_FORCE24HOURFORMAT,&st,NULL,pszOut,nSize)!=0;
+ /* show both date and time */
+ { TCHAR szDate[128],szTime[128];
+ if(!GetTimeFormat(locale,((st.wSecond==0)?TIME_NOSECONDS:0)|TIME_FORCE24HOURFORMAT,&st,NULL,szTime,SIZEOF(szTime)))
+ return FALSE;
+ if(!GetDateFormat(locale,DATE_SHORTDATE,&st,NULL,szDate,SIZEOF(szDate)))
+ return FALSE;
+ mir_sntprintf(pszOut,nSize,_T("%s %s"),szTime,szDate);
+ return TRUE;
+ }
+}
+
+/************************* Fonts & Colors *************************/
+
+int FontService_RegisterFont(const char *pszDbModule,const char *pszDbName,const TCHAR *pszSection,const TCHAR *pszDescription,int position,BOOL bAllowEffects,LOGFONT *plfDefault,COLORREF clrDefault)
+{
+ FontIDT fid;
+ ZeroMemory(&fid,sizeof(fid));
+ fid.cbSize=sizeof(fid);
+ lstrcpynA(fid.dbSettingsGroup,pszDbModule,sizeof(fid.dbSettingsGroup)); /* buffer safe */
+ lstrcpynA(fid.prefix,pszDbName,sizeof(fid.prefix)); /* buffer safe */
+ lstrcpyn(fid.group,pszSection,SIZEOF(fid.group)); /* buffer safe */
+ lstrcpyn(fid.name,pszDescription,SIZEOF(fid.name)); /* buffer safe */
+ fid.flags=FIDF_ALLOWREREGISTER;
+ if(bAllowEffects) fid.flags|=FIDF_ALLOWEFFECTS;
+ fid.order=position;
+ if(plfDefault!=NULL) {
+ fid.flags|=FIDF_DEFAULTVALID;
+ fid.deffontsettings.colour=clrDefault;
+ fid.deffontsettings.size=(char)plfDefault->lfHeight;
+ if(plfDefault->lfItalic) fid.deffontsettings.style|=DBFONTF_ITALIC;
+ if(plfDefault->lfWeight!=FW_NORMAL) fid.deffontsettings.style|=DBFONTF_BOLD;
+ if(plfDefault->lfUnderline) fid.deffontsettings.style|=DBFONTF_UNDERLINE;
+ if(plfDefault->lfStrikeOut) fid.deffontsettings.style|=DBFONTF_STRIKEOUT;
+ fid.deffontsettings.charset=plfDefault->lfCharSet;
+ lstrcpyn(fid.deffontsettings.szFace,plfDefault->lfFaceName,SIZEOF(fid.deffontsettings.szFace)); /* buffer safe */
+ }
+ return CallService(MS_FONT_REGISTERT,(WPARAM)&fid,(LPARAM)&fid);
+}
+
+int FontService_GetFont(const TCHAR *pszSection,const TCHAR *pszDescription,COLORREF *pclr,LOGFONT *plf)
+{
+ FontIDT fid;
+ fid.cbSize=sizeof(fid);
+ lstrcpyn(fid.group,pszSection,SIZEOF(fid.group)); /* buffer sfae */
+ lstrcpyn(fid.name,pszDescription,SIZEOF(fid.name)); /* buffer safe */
+ *pclr=(COLORREF)CallService(MS_FONT_GETT,(WPARAM)&fid,(LPARAM)plf); /* uses fallback font on error */
+ return (int)*pclr==-1;
+}
+
+int FontService_RegisterColor(const char *pszDbModule,const char *pszDbName,const TCHAR *pszSection,const TCHAR *pszDescription,COLORREF clrDefault)
+{
+ ColourIDT cid;
+ ZeroMemory(&cid,sizeof(cid));
+ cid.cbSize=sizeof(cid);
+ cid.defcolour=clrDefault;
+ lstrcpynA(cid.dbSettingsGroup,pszDbModule,sizeof(cid.dbSettingsGroup)); /* buffer safe */
+ lstrcpynA(cid.setting,pszDbName,sizeof(cid.setting)); /* buffer safe */
+ lstrcpyn(cid.group,pszSection,SIZEOF(cid.group)); /* buffer safe */
+ lstrcpyn(cid.name,pszDescription,SIZEOF(cid.name)); /* buffer safe */
+ return CallService(MS_COLOUR_REGISTERT,(WPARAM)&cid,0);
+}
+
+int FontService_GetColor(const TCHAR *pszSection,const TCHAR *pszDescription,COLORREF *pclr)
+{
+ ColourIDT cid;
+ ZeroMemory(&cid,sizeof(cid));
+ cid.cbSize=sizeof(cid);
+ lstrcpyn(cid.group,pszSection,sizeof(cid.group)); /* buffer safe */
+ lstrcpyn(cid.name,pszDescription,sizeof(cid.name)); /* buffer safe */
+ *pclr=(COLORREF)CallService(MS_COLOUR_GETT,(WPARAM)&cid,0);
+ return (int)*pclr==-1;
+}
+
+/************************* Skin ***********************************/
+
+HANDLE IcoLib_AddIconRes(const char *pszDbName,const TCHAR *pszSection,const TCHAR *pszDesc,HINSTANCE hInst,WORD idRes,BOOL fLarge)
+{
+ SKINICONDESC sid;
+ TCHAR szFileName[MAX_PATH];
+ sid.cbSize=sizeof(SKINICONDESC);
+ sid.pszName=(char*)pszDbName;
+ sid.ptszSection=(TCHAR*)pszSection;
+ sid.ptszDescription=(TCHAR*)pszDesc;
+ sid.ptszDefaultFile=szFileName;
+ sid.iDefaultIndex=-idRes;
+ sid.cx=GetSystemMetrics(fLarge?SM_CXICON:SM_CXSMICON);
+ sid.cy=GetSystemMetrics(fLarge?SM_CYICON:SM_CYSMICON);
+ sid.hDefaultIcon=NULL;
+ sid.flags=SIDF_SORTED|SIDF_ALL_TCHAR;
+ if(!GetModuleFileName(hInst,szFileName,SIZEOF(szFileName)))
+ return NULL;
+ return (HANDLE)CallService(MS_SKIN2_ADDICON,0,(LPARAM)&sid);
+}
+
+HICON IcoLib_GetIcon(const char *pszDbName)
+{
+ return (HICON)CallService(MS_SKIN2_GETICON,0,(LPARAM)pszDbName);
+}
+
+int IcoLib_ReleaseIcon(HICON hIcon)
+{
+ return CallService(MS_SKIN2_RELEASEICON,(WPARAM)hIcon,0);
+}
+
+int SkinAddNewSoundBundled(const char *pszDbName,const char *pszSection,const char *pszDesc,const char *pszSubDir,const char *pszDefaultFile)
+{
+ SKINSOUNDDESCEX ssd;
+ char szFile[MAX_PATH],*p;
+ HANDLE hFile;
+
+ ssd.cbSize=sizeof(ssd);
+ ssd.pszName=pszDbName;
+ ssd.pszSection=pszSection;
+ ssd.pszDescription=pszDesc;
+ ssd.pszDefaultFile=NULL;
+ if(GetModuleFileNameA(NULL,szFile,SIZEOF(szFile)-lstrlenA(pszSubDir)-lstrlenA(pszDefaultFile))) {
+ p=strrchr(szFile,'\\');
+ if(p!=NULL) *(++p)=0;
+ lstrcatA(lstrcatA(szFile,pszSubDir),pszDefaultFile); /* buffer safe */
+ /* check if sound file exist */
+ hFile=CreateFileA(szFile,0,FILE_SHARE_READ,NULL,OPEN_EXISTING,0,NULL);
+ if(hFile!=INVALID_HANDLE_VALUE) {
+ ssd.pszDefaultFile=szFile; /* MS_UTILS_PATHTORELATIVET called automatically */
+ CloseHandle(hFile);
+ }
+ }
+ return CallService(MS_SKIN_ADDNEWSOUND,0,(LPARAM)&ssd);
+}
+
+/* workaround for 'Hotkey Service' plugin because it has needs an event catcher */
+static char szHotkeyService[MAXMODULELABELLENGTH];
+static int moduleId,itemId;
+static int HotkeysServiceHotkeyPressed(WPARAM wParam,LPARAM lParam)
+{
+ UNREFERENCED_PARAMETER(lParam);
+ if(((THKSEvent*)wParam)->moduleId==moduleId && ((THKSEvent*)wParam)->itemId==LOWORD(itemId))
+ CallService(szHotkeyService,0,0);
+ return 0;
+}
+
+/* defines for 'Hotkey Manager' */
+#define HK_ACT_OVERWRITE 0
+#define HKF_GLOBAL 0x00000001
+#define HKF_WPARNUM 0x00000008
+#define HKF_HEX 0x00000200
+#define HKF_LCURRENT 0x00001000
+#define HKT_SERVICE 2
+typedef struct {
+ void *reserved1;
+ void *reserved2;
+ int hotkey;
+ WCHAR* descr;
+ DWORD flags;
+ ATOM reserved3;
+ DWORD _type;
+ char* service;
+ WPARAM wparam;
+ LPARAM lparam;
+} HOTKEYREC;
+#define MS_HK_ADDHOTKEY "HotKey/AddHotkey"
+
+int SkinAddNewHotkey(const char *pszDbName,const char *pszSection,const char *pszDescription,UINT vk,UINT hotkeyfModifiers,const char *pszServiceName)
+{
+ if(ServiceExists(MS_SKIN_ADDHOTKEY)) { /* clist_mw, clist_modern */
+ SKINHOTKEYDESCEX shd;
+ ZeroMemory(&shd,sizeof(shd));
+ shd.cbSize=sizeof(shd);
+ shd.pszName=(char*)pszDbName;
+ shd.pszDescription=(char*)pszDescription;
+ shd.pszSection=(char*)pszSection;
+ shd.pszService=(char*)pszServiceName;
+ shd.DefHotKey=MAKEWORD(vk,hotkeyfModifiers);
+ CallService(MS_SKIN_ADDHOTKEY,0,(LPARAM)&shd);
+ /* no return */
+ }
+ if(ServiceExists(MS_HOTKEYSPLUS_ADDKEY)) /* 'Hotkeys Plus' */
+ return CallService(MS_HOTKEYSPLUS_ADDKEY,(WPARAM)pszServiceName,(LPARAM)pszDescription);
+ if(ServiceExists(HKS_REGISTERFUNCTION)) { /* mHotKey */
+ KEYHASH kh;
+ kh.isShift=(hotkeyfModifiers&HOTKEYF_SHIFT)!=0;
+ kh.isCtrl=(hotkeyfModifiers&HOTKEYF_CONTROL)!=0;
+ kh.isAlt=(hotkeyfModifiers&HOTKEYF_ALT)!=0;
+ kh.vkCode=vk;
+ return !CallService(HKS_REGISTERFUNCTION,(WPARAM)&kh,(LPARAM)pszServiceName);
+ }
+ if(ServiceExists(MS_HK_ADDHOTKEY)) { /* 'Hotkey Manager' */
+ HOTKEYREC hkr;
+ ZeroMemory(&hkr,sizeof(hkr));
+ hkr.hotkey=(int)MAKEWORD(vk,hotkeyfModifiers);
+ #if defined(_UNICODE)
+ hkr.descr=(WCHAR*)pszDescription;
+ #else
+ hkr.descr=(WCHAR*)a2u(pszDescription);
+ #endif
+ hkr.flags=HKF_GLOBAL|HKF_WPARNUM|HKF_LCURRENT|HKF_HEX;
+ hkr._type=HKT_SERVICE;
+ hkr.service=(char*)pszServiceName;
+ CallService(MS_HK_ADDHOTKEY,(WPARAM)&hkr,HK_ACT_OVERWRITE);
+ #if !defined(_UNICODE)
+ mir_free(hkr.descr);
+ #endif
+ return 0;
+ }
+ if(ServiceExists(MS_HKS_REGISTER_ITEM)) { /* 'Hotkeys Service' */
+ THKSItem item;
+ ZeroMemory(&item,sizeof(item));
+ item.name=(char*)pszSection;
+ item.itemType=HKS_ITEM_MODULE;
+ item.owner=LOWORD(CallService(MS_HKS_REGISTER_ITEM,(WPARAM)&item,0));
+ item.name=(char*)pszDescription;
+ item.itemType=HKS_ITEM_ACTION;
+ item.hotkey.key=(WORD)vk;
+ item.hotkey.modifiers=MOD_GLOBAL;
+ if(hotkeyfModifiers&HOTKEYF_ALT) item.hotkey.modifiers|=MOD_ALT;
+ if(hotkeyfModifiers&HOTKEYF_CONTROL) item.hotkey.modifiers|=MOD_CONTROL;
+ if(hotkeyfModifiers&HOTKEYF_SHIFT) item.hotkey.modifiers|=MOD_SHIFT;
+ if(hotkeyfModifiers&HOTKEYF_EXT) item.hotkey.modifiers|=MOD_WIN;
+ /* no possibility to specify a service to call,
+ * all processing needs to be done in the plugins */
+ moduleId=item.owner;
+ mir_snprintf(szHotkeyService,sizeof(szHotkeyService),"%s",pszServiceName); // only allows for one hotkey as a whole
+ HookEvent(ME_HKS_KEY_PRESSED,HotkeysServiceHotkeyPressed);
+ itemId=CallService(MS_HKS_REGISTER_ITEM,(WPARAM)&item,0);
+ return HIWORD(itemId);
+ }
+ return 1;
+}
diff --git a/plugins/AutoShutdown/utils.h b/plugins/AutoShutdown/utils.h
new file mode 100644
index 0000000000..98b4825ec0
--- /dev/null
+++ b/plugins/AutoShutdown/utils.h
@@ -0,0 +1,48 @@
+/*
+
+'AutoShutdown'-Plugin for Miranda IM
+
+Copyright 2004-2007 H. Herkenrath
+
+This program is free software; you can redistribute it and/or
+modify it under the terms of the GNU General Public License
+as published by the Free Software Foundation; either version 2
+of the License, or (at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program (Shutdown-License.txt); if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+*/
+
+/* String */
+WCHAR *a2u(const char *pszAnsi);
+char *u2a(const WCHAR *pszUnicode);
+void TrimString(TCHAR *pszStr);
+
+/* Error Output */
+void ShowInfoMessage(BYTE flags,const char *pszTitle,const char *pszTextFmt,...);
+char* GetWinErrorDescription(DWORD dwLastError);
+
+/* Time */
+BOOL SystemTimeToTimeStamp(SYSTEMTIME *st,time_t *timestamp);
+BOOL TimeStampToSystemTime(time_t timestamp,SYSTEMTIME *st);
+BOOL GetFormatedCountdown(TCHAR *pszOut,int nSize,time_t countdown);
+BOOL GetFormatedDateTime(TCHAR *pszOut,int nSize,time_t timestamp,BOOL fShowDateEvenToday);
+
+/* Fonts & Colors */
+int FontService_RegisterFont(const char *pszDbModule,const char *pszDbName,const TCHAR *pszSection,const TCHAR *pszDescription,int position,BOOL bAllowEffects,LOGFONT *plfDefault,COLORREF clrDefault);
+int FontService_GetFont(const TCHAR *pszSection,const TCHAR *pszDescription,COLORREF *pclr,LOGFONT *plf);
+int FontService_RegisterColor(const char *pszDbModule,const char *pszDbName,const TCHAR *pszSection,const TCHAR *pszDescription,COLORREF clrDefault);
+int FontService_GetColor(const TCHAR *pszSection,const TCHAR *pszDescription,COLORREF *pclr);
+
+/* Skin */
+HANDLE IcoLib_AddIconRes(const char *pszDbName,const TCHAR *pszSection,const TCHAR *pszDesc,HINSTANCE hInst,WORD idRes,BOOL fLarge);
+HICON IcoLib_GetIcon(const char *pszDbName);
+int IcoLib_ReleaseIcon(HICON hIcon);
+int SkinAddNewSoundBundled(const char *pszDbName,const char *pszSection,const char *pszDesc,const char *pszSubDir,const char *pszDefaultFile);
+int SkinAddNewHotkey(const char *pszDbName,const char* pszSection,const char *pszDescription,UINT vk,UINT hotkeyfModifiers,const char *pszServiceName);
diff --git a/plugins/AutoShutdown/version.h b/plugins/AutoShutdown/version.h
new file mode 100644
index 0000000000..cba1fe2c93
--- /dev/null
+++ b/plugins/AutoShutdown/version.h
@@ -0,0 +1,40 @@
+/*
+
+'AutoShutdown'-Plugin for Miranda IM
+
+Copyright 2004-2007 H. Herkenrath
+
+This program is free software; you can redistribute it and/or
+modify it under the terms of the GNU General Public License
+as published by the Free Software Foundation; either version 2
+of the License, or (at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program (Shutdown-License.txt); if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+*/
+
+#define NEEDED_MIRANDA_VERSION PLUGIN_MAKE_VERSION(0,7,0,16)
+#define NEEDED_MIRANDA_VERSION_STR "0.7 alpha build #16"
+#define PLUGIN_VERSION PLUGIN_MAKE_VERSION(1,4,0,2)
+#define FILE_VERSION 1,4,0,2
+
+#if defined(_DEBUG)
+ #define FILE_VERSION_STR "1.4.0.3 alpha"
+#else
+ #define FILE_VERSION_STR "1.4.0.2"
+#endif
+
+#define PLUGIN_EMAIL "hrathh users.sourceforge.net"
+#define PLUGIN_EMAIL_ATT_POS 7 /* position of the @-sign in the email adress above */
+
+#if defined(_UNICODE)
+ #define PLUGIN_WEBSITE "http://addons.miranda-im.org/details.php?action=viewfile&id=3056"
+#else
+ #define PLUGIN_WEBSITE "http://addons.miranda-im.org/details.php?action=viewfile&id=1086"
+#endif
diff --git a/plugins/AutoShutdown/version.rc b/plugins/AutoShutdown/version.rc
new file mode 100644
index 0000000000..97f35498c3
--- /dev/null
+++ b/plugins/AutoShutdown/version.rc
@@ -0,0 +1,51 @@
+#ifndef _MAC
+
+#include "version.h"
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// Version
+//
+
+VS_VERSION_INFO VERSIONINFO
+ FILEVERSION FILE_VERSION
+ PRODUCTVERSION FILE_VERSION
+ FILEFLAGSMASK 0x0L
+#ifdef _DEBUG
+ FILEFLAGS 0x1L
+#else
+ FILEFLAGS 0x0L
+#endif
+ FILEOS 0x40004L
+ FILETYPE 0x2L
+ FILESUBTYPE 0x0L
+BEGIN
+ BLOCK "StringFileInfo"
+ BEGIN
+ BLOCK "000004b0"
+ BEGIN
+ VALUE "Comments", "Licensed under the terms of the GNU General Public License"
+ VALUE "FileDescription", "AutoShutdown Plugin for Miranda IM"
+ VALUE "FileVersion", FILE_VERSION_STR
+#ifdef _UNICODE
+ VALUE "InternalName", "AutoShutdown (Unicode)"
+#else
+ VALUE "InternalName", "AutoShutdown"
+#endif
+ VALUE "LegalCopyright", "Copyright © 2004-2007 H. Herkenrath"
+ VALUE "OriginalFilename", "shutdown.dll"
+ VALUE "ProductName", "Automatic Shutdown"
+ VALUE "ProductVersion", FILE_VERSION_STR
+ END
+ END
+ BLOCK "VarFileInfo"
+ BEGIN
+ VALUE "Translation", 0x0, 1200
+ END
+END
+
+#endif // !_MAC
+
+
+
+
diff --git a/plugins/AutoShutdown/watcher.c b/plugins/AutoShutdown/watcher.c
new file mode 100644
index 0000000000..75a2881e98
--- /dev/null
+++ b/plugins/AutoShutdown/watcher.c
@@ -0,0 +1,408 @@
+/*
+
+'AutoShutdown'-Plugin for Miranda IM
+
+Copyright 2004-2007 H. Herkenrath
+
+This program is free software; you can redistribute it and/or
+modify it under the terms of the GNU General Public License
+as published by the Free Software Foundation; either version 2
+of the License, or (at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program (Shutdown-License.txt); if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+*/
+
+#include "common.h"
+
+/* Msg Shutdown */
+static HANDLE hHookEventAdded;
+/* Transfer Shutdown */
+static HANDLE hHookProtoAck;
+/* Idle Shutdown */
+static HANDLE hHookIdleChanged;
+/* Status Shutdown */
+static HANDLE hHookSettingChanged;
+/* Weather Shutdown */
+static HANDLE hHookWeatherUpdated;
+/* Overheat Shutdown */
+static HANDLE hHookHddOverheat;
+/* Services */
+static HANDLE hServiceStartWatcher,hServiceStopWatcher,hServiceIsEnabled;
+static HANDLE hEventWatcherChanged;
+/* Misc */
+static HANDLE hHookModulesLoaded;
+
+/************************* Shared *************************************/
+
+static WORD currentWatcherType;
+
+static void __stdcall MainThreadMapping(HANDLE *phDoneEvent)
+{
+ ServiceShutdown(0,TRUE); /* ensure main thread (for cpu usage shutdown) */
+ ServiceStopWatcher(0,0);
+ if(*phDoneEvent!=NULL) SetEvent(*phDoneEvent);
+}
+
+static void __inline ShutdownAndStopWatcher(void)
+{
+ HANDLE hDoneEvent;
+ hDoneEvent=CreateEvent(NULL,FALSE,FALSE,NULL);
+ if(CallFunctionAsync(MainThreadMapping,&hDoneEvent))
+ if(hDoneEvent!=NULL) WaitForSingleObject(hDoneEvent,INFINITE);
+ if(hDoneEvent!=NULL) CloseHandle(hDoneEvent);
+}
+
+/************************* Msg Shutdown *******************************/
+
+// ppBlob might get reallocated, must have been allocated using mir_alloc()
+static TCHAR* GetMessageText(BYTE **ppBlob,DWORD *pcbBlob)
+{
+#if defined(_UNICODE)
+ DWORD cb;
+ (*ppBlob)[*pcbBlob]=0;
+ cb=lstrlenA((char*)*ppBlob);
+ /* use Unicode data if present */
+ if(*pcbBlob>(cb+3)) {
+ (*ppBlob)[*pcbBlob-1]=0;
+ return (WCHAR*)&(*ppBlob)[cb];
+ }
+ /* no Unicode data present, convert from ANSI */
+ { int len;
+ BYTE *buf;
+ len=MultiByteToWideChar(CP_ACP,0,(char*)*ppBlob,-1,NULL,0);
+ if(!len) return NULL;
+ buf=(BYTE*)mir_realloc(*ppBlob,(*pcbBlob)+(len*sizeof(WCHAR)));
+ if(buf==NULL) return NULL;
+ *pcbBlob+=len*sizeof(WCHAR);
+ *ppBlob=buf;
+ buf=&(*ppBlob)[cb];
+ MultiByteToWideChar(CP_ACP,0,(char*)*ppBlob,-1,(WCHAR*)buf,len);
+ ((WCHAR*)buf)[len-1]=0;
+ return (WCHAR*)buf;
+ }
+#else
+ (*ppBlob)[*pcbBlob]=0;
+ return (char*)*ppBlob;
+#endif
+}
+
+static int MsgEventAdded(WPARAM wParam,LPARAM lParam)
+{
+ UNREFERENCED_PARAMETER(wParam);
+ if(currentWatcherType&SDWTF_MESSAGE) {
+ DBEVENTINFO dbe;
+ dbe.cbSize=sizeof(dbe);
+ dbe.cbBlob=(DWORD)CallService(MS_DB_EVENT_GETBLOBSIZE,(WPARAM)lParam,0);
+ dbe.pBlob=(BYTE*)mir_alloc(dbe.cbBlob+2); /* ensure term zero */
+ if(dbe.pBlob==NULL) return 0;
+ if(!CallService(MS_DB_EVENT_GET,(WPARAM)lParam,(LPARAM)&dbe))
+ if(dbe.eventType==EVENTTYPE_MESSAGE && !(dbe.flags&DBEF_SENT)) {
+ DBVARIANT dbv;
+ TCHAR *pszMsg;
+ if(!DBGetContactSettingTString(NULL,"AutoShutdown","Message",&dbv)) {
+ TrimString(dbv.ptszVal);
+ pszMsg=GetMessageText(&dbe.pBlob,&dbe.cbBlob);
+ if(pszMsg!=NULL && _tcsstr(pszMsg,dbv.ptszVal)!=NULL)
+ ShutdownAndStopWatcher(); /* msg with specified text recvd */
+ mir_free(dbv.ptszVal); /* does NULL check */
+ }
+ }
+ mir_free(dbe.pBlob);
+ }
+ return 0;
+}
+
+/************************* Transfer Shutdown **************************/
+
+static HANDLE *transfers;
+static int nTransfersCount;
+
+static int ProtoAck(WPARAM wParam,LPARAM lParam)
+{
+ ACKDATA *ack=(ACKDATA*)lParam;
+ UNREFERENCED_PARAMETER(wParam);
+ if(ack->type==ACKTYPE_FILE)
+ switch(ack->result) {
+ case ACKRESULT_DATA:
+ { int i;
+ for(i=0;i<nTransfersCount;++i)
+ if(transfers[i]==ack->hProcess)
+ break; /* already in list */
+ /* insert into list */
+ { HANDLE *buf=(HANDLE*)mir_realloc(transfers,(nTransfersCount+1)*sizeof(HANDLE)); if(buf!=NULL) {
+ transfers=buf;
+ transfers[nTransfersCount]=ack->hProcess;
+ ++nTransfersCount;
+ }
+ }
+ break;
+ }
+ case ACKRESULT_SUCCESS:
+ case ACKRESULT_FAILED:
+ case ACKRESULT_DENIED:
+ { int i;
+ for(i=0;i<nTransfersCount;++i)
+ if(transfers[i]==ack->hProcess) {
+ /* remove from list */
+ HANDLE *buf;
+ if(i<(nTransfersCount-1))
+ MoveMemory(&transfers[i],&transfers[i+1],(nTransfersCount-i-1)*sizeof(HANDLE));
+ --nTransfersCount;
+ buf=(HANDLE*)mir_realloc(transfers,nTransfersCount*sizeof(HANDLE));
+ if(buf!=NULL) transfers=buf;
+ else if(!nTransfersCount) transfers=NULL;
+ /* stop watcher */
+ if(!nTransfersCount && (currentWatcherType&SDWTF_FILETRANSFER))
+ ShutdownAndStopWatcher();
+ break;
+ }
+ break;
+ }
+ }
+ return 0;
+}
+
+/************************* Idle Shutdown ******************************/
+
+static int IdleChanged(WPARAM wParam,LPARAM lParam)
+{
+ UNREFERENCED_PARAMETER(wParam);
+ if(currentWatcherType&SDWTF_IDLE && lParam&IDF_ISIDLE)
+ ShutdownAndStopWatcher();
+ return 0;
+}
+
+/************************* Status Shutdown ****************************/
+
+static BOOL CheckAllContactsOffline(void)
+{
+ BOOL fSmartCheck,fAllOffline=TRUE; /* tentatively */
+ HANDLE hContact;
+ char *pszProto;
+ fSmartCheck=DBGetContactSettingByte(NULL,"AutoShutdown","SmartOfflineCheck",SETTING_SMARTOFFLINECHECK_DEFAULT);
+ hContact=(HANDLE)CallService(MS_DB_CONTACT_FINDFIRST,0,0);
+ while(hContact!=NULL) {
+ pszProto=(char*)CallService(MS_PROTO_GETCONTACTBASEPROTO,(WPARAM)hContact,0);
+ if(pszProto!=NULL && CallProtoService(pszProto,PS_GETSTATUS,0,0)!=ID_STATUS_OFFLINE)
+ if(DBGetContactSettingByte(hContact,pszProto,"ChatRoom",0)) continue;
+ if(DBGetContactSettingWord(hContact,pszProto,"Status",0)!=ID_STATUS_OFFLINE) {
+ if(fSmartCheck) {
+ if(DBGetContactSettingByte(hContact,"CList","Hidden",0)) continue;
+ if(DBGetContactSettingByte(hContact,"CList","NotOnList",0)) continue;
+ }
+ fAllOffline=FALSE;
+ break;
+ }
+ hContact=(HANDLE)CallService(MS_DB_CONTACT_FINDNEXT,(WPARAM)hContact,0);
+ }
+ return fAllOffline;
+}
+
+static int StatusSettingChanged(WPARAM wParam,LPARAM lParam)
+{
+ if(currentWatcherType&SDWTF_STATUS) {
+ DBCONTACTWRITESETTING *dbcws=(DBCONTACTWRITESETTING*)lParam;
+ if((HANDLE)wParam!=NULL && dbcws->value.wVal==ID_STATUS_OFFLINE && !lstrcmpA(dbcws->szSetting,"Status")) {
+ char *pszProto=(char*)CallService(MS_PROTO_GETCONTACTBASEPROTO,wParam,0);
+ if(pszProto!=NULL && !lstrcmpA(dbcws->szModule,pszProto))
+ if(CheckAllContactsOffline())
+ ShutdownAndStopWatcher();
+ }
+ }
+ return 0;
+}
+
+/************************* Cpu Shutdown *******************************/
+
+static DWORD idCpuUsageThread;
+
+static BOOL CALLBACK CpuUsageWatcherProc(BYTE nCpuUsage,LPARAM lParam)
+{
+ static BYTE nTimesBelow=0; /* only one watcher thread */
+ /* terminated? */
+ if(idCpuUsageThread!=GetCurrentThreadId()) {
+ nTimesBelow=0;
+ return FALSE; /* stop poll thread */
+ }
+ /* ignore random peaks */
+ if(nCpuUsage<(BYTE)lParam) ++nTimesBelow;
+ else nTimesBelow=0;
+ if(nTimesBelow==3) {
+ nTimesBelow=0;
+ ShutdownAndStopWatcher();
+ return FALSE; /* stop poll thread */
+ }
+ return TRUE;
+}
+
+/************************* Weather Shutdown ***************************/
+
+static int WeatherUpdated(WPARAM wParam,LPARAM lParam)
+{
+ char *pszProto=(char*)CallService(MS_PROTO_GETCONTACTBASEPROTO,wParam,0);
+ if((BOOL)lParam && pszProto!=NULL && CallProtoService(pszProto,PS_GETSTATUS,0,0)==THUNDER)
+ if(DBGetContactSettingByte(NULL,"AutoShutdown","WeatherShutdown",SETTING_WEATHERSHUTDOWN_DEFAULT))
+ ServiceShutdown(SDSDT_SHUTDOWN,TRUE);
+ return 0;
+}
+
+/************************* Overheat Shutdown **************************/
+
+static int HddOverheat(WPARAM wParam,LPARAM lParam)
+{
+ UNREFERENCED_PARAMETER(wParam);
+ UNREFERENCED_PARAMETER(lParam);
+ if(DBGetContactSettingByte(NULL,"AutoShutdown","HddOverheatShutdown",SETTING_HDDOVERHEATSHUTDOWN_DEFAULT))
+ ServiceShutdown(SDSDT_SHUTDOWN,TRUE);
+ return 0;
+}
+
+/************************* Services ***********************************/
+
+int ServiceStartWatcher(WPARAM wParam,LPARAM lParam)
+{
+ UNREFERENCED_PARAMETER(wParam);
+
+ /* passing watcherType as lParam is only to be used internally, undocumented */
+ if(lParam==0) lParam=(LPARAM)DBGetContactSettingWord(NULL,"AutoShutdown","WatcherFlags",0);
+
+ if(!(lParam&SDWTF_MASK)) return 1; /* invalid flags or empty? */
+ if(lParam&SDWTF_SPECIFICTIME && !(lParam&SDWTF_ST_MASK)) return 2; /* no specific time choice? */
+ if(currentWatcherType==(WORD)lParam) return 3;
+
+ if(currentWatcherType!=0) {
+ /* Time Shutdown */
+ CloseCountdownFrame(); /* fails if not opened */
+ /* Cpu Shutdown */
+ idCpuUsageThread=0;
+ }
+ SetShutdownMenuItem(TRUE);
+ SetShutdownToolbarButton(TRUE);
+ currentWatcherType=(WORD)lParam;
+ NotifyEventHooks(hEventWatcherChanged,TRUE,0);
+
+ /* Time Shutdown */
+ if(currentWatcherType&SDWTF_SPECIFICTIME)
+ ShowCountdownFrame(currentWatcherType); /* after modules loaded */
+ /* Cpu Shutdown */
+ if(currentWatcherType&SDWTF_CPUUSAGE)
+ idCpuUsageThread=PollCpuUsage(CpuUsageWatcherProc,(LPARAM)DBGetContactSettingRangedByte(NULL,"AutoShutdown","CpuUsageThreshold",SETTING_CPUUSAGETHRESHOLD_DEFAULT,1,100),1500);
+ /* Transfer Shutdown */
+ if(currentWatcherType&SDWTF_FILETRANSFER && !nTransfersCount)
+ ShutdownAndStopWatcher();
+ /* Status Shutdown */
+ if(currentWatcherType&SDWTF_STATUS && CheckAllContactsOffline())
+ ShutdownAndStopWatcher();
+ return 0;
+}
+
+int ServiceStopWatcher(WPARAM wParam,LPARAM lParam)
+{
+ UNREFERENCED_PARAMETER(wParam);
+ UNREFERENCED_PARAMETER(lParam);
+ if(currentWatcherType==0) return 1;
+
+ /* Time Shutdown */
+ if(currentWatcherType&SDWTF_SPECIFICTIME)
+ CloseCountdownFrame();
+ /* Cpu Shutdown */
+ idCpuUsageThread=0;
+
+ currentWatcherType=0;
+ SetShutdownMenuItem(FALSE);
+ SetShutdownToolbarButton(FALSE);
+ NotifyEventHooks(hEventWatcherChanged,FALSE,0);
+ return 0;
+}
+
+int ServiceIsWatcherEnabled(WPARAM wParam,LPARAM lParam)
+{
+ UNREFERENCED_PARAMETER(wParam);
+ UNREFERENCED_PARAMETER(lParam);
+ return currentWatcherType!=0;
+}
+
+/************************* Misc ***********************************/
+
+static int WatcherModulesLoaded(WPARAM wParam,LPARAM lParam)
+{
+ UNREFERENCED_PARAMETER(wParam);
+ UNREFERENCED_PARAMETER(lParam);
+
+ /* Weather Shutdown */
+ if(ServiceExists(MS_WEATHER_UPDATE))
+ hHookWeatherUpdated=HookEvent(ME_WEATHER_UPDATED,WeatherUpdated);
+ /* Overheat Shutdown */
+ if(ServiceExists(MS_SYSINFO_HDDTEMP))
+ hHookHddOverheat=HookEvent(ME_SYSINFO_HDDOVERHEAT,HddOverheat);
+
+ /* restore watcher if it was running on last exit */
+ if(DBGetContactSettingByte(NULL,"AutoShutdown","RememberOnRestart",0)==SDROR_RUNNING) {
+ DBWriteContactSettingByte(NULL,"AutoShutdown","RememberOnRestart",1);
+ ServiceStartWatcher(0,0); /* after modules loaded */
+ }
+ return 0;
+}
+
+void InitWatcher(void)
+{
+ /* Shared */
+ currentWatcherType=0;
+ /* Message Shutdown */
+ hHookEventAdded=HookEvent(ME_DB_EVENT_ADDED,MsgEventAdded);
+ /* Status Shutdown*/
+ hHookSettingChanged=HookEvent(ME_DB_CONTACT_SETTINGCHANGED,StatusSettingChanged);
+ /* Idle Shutdown */
+ hHookIdleChanged=HookEvent(ME_IDLE_CHANGED,IdleChanged);
+ /* Transfer Shutdown */
+ transfers=NULL;
+ nTransfersCount=0;
+ hHookProtoAck=HookEvent(ME_PROTO_ACK,ProtoAck);
+ /* Weather Shutdown */
+ hHookWeatherUpdated=NULL;
+ /* Overheat Shutdown */
+ hHookHddOverheat=NULL;
+ /* Services */
+ hEventWatcherChanged=CreateHookableEvent(ME_AUTOSHUTDOWN_WATCHERCHANGED);
+ hServiceStartWatcher=CreateServiceFunction(MS_AUTOSHUTDOWN_STARTWATCHER,ServiceStartWatcher);
+ hServiceStopWatcher=CreateServiceFunction(MS_AUTOSHUTDOWN_STOPWATCHER,ServiceStopWatcher);
+ hServiceIsEnabled=CreateServiceFunction(MS_AUTOSHUTDOWN_ISWATCHERENABLED,ServiceIsWatcherEnabled);
+ /* Misc */
+ hHookModulesLoaded=HookEvent(ME_SYSTEM_MODULESLOADED,WatcherModulesLoaded);
+}
+
+void UninitWatcher(void)
+{
+ /* remember watcher if running */
+ if(!ServiceStopWatcher(0,0))
+ if(DBGetContactSettingByte(NULL,"AutoShutdown","RememberOnRestart",SETTING_REMEMBERONRESTART_DEFAULT))
+ DBWriteContactSettingByte(NULL,"AutoShutdown","RememberOnRestart",SDROR_RUNNING);
+
+ /* Message Shutdown */
+ UnhookEvent(hHookEventAdded);
+ /* Status Shutdown*/
+ UnhookEvent(hHookSettingChanged);
+ /* Idle Shutdown */
+ UnhookEvent(hHookIdleChanged);
+ /* Transfer Shutdown */
+ UnhookEvent(hHookProtoAck);
+ mir_free(transfers); /* does NULL check */
+ /* Weather Shutdown */
+ UnhookEvent(hHookWeatherUpdated); /* does NULL check */
+ /* Overheat Shutdown */
+ UnhookEvent(hHookHddOverheat); /* does NULL check */
+ /* Services */
+ DestroyServiceFunction(hServiceStartWatcher);
+ DestroyServiceFunction(hServiceStopWatcher);
+ DestroyServiceFunction(hServiceIsEnabled);
+ DestroyHookableEvent(hEventWatcherChanged);
+ /* Misc */
+ UnhookEvent(hHookModulesLoaded);
+}
diff --git a/plugins/AutoShutdown/watcher.h b/plugins/AutoShutdown/watcher.h
new file mode 100644
index 0000000000..20f4e431c3
--- /dev/null
+++ b/plugins/AutoShutdown/watcher.h
@@ -0,0 +1,29 @@
+/*
+
+'AutoShutdown'-Plugin for Miranda IM
+
+Copyright 2004-2007 H. Herkenrath
+
+This program is free software; you can redistribute it and/or
+modify it under the terms of the GNU General Public License
+as published by the Free Software Foundation; either version 2
+of the License, or (at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program (Shutdown-License.txt); if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+*/
+
+/* Services */
+int ServiceStartWatcher(WPARAM wParam,LPARAM lParam);
+int ServiceStopWatcher(WPARAM wParam,LPARAM lParam);
+int ServiceIsWatcherEnabled(WPARAM wParam,LPARAM lParam);
+
+/* Misc */
+void InitWatcher(void);
+void UninitWatcher(void);