summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--random_message_changer/RMC_Dialog.rc121
-rw-r--r--random_message_changer/RandomMessageChanger.sln19
-rw-r--r--random_message_changer/RandomMessageChanger.vcproj364
-rw-r--r--random_message_changer/common.h33
-rw-r--r--random_message_changer/main.cpp184
-rw-r--r--random_message_changer/options.cpp168
-rw-r--r--random_message_changer/options.h26
-rw-r--r--random_message_changer/resource.h31
-rw-r--r--random_message_changer/rmc.mdsp96
9 files changed, 1042 insertions, 0 deletions
diff --git a/random_message_changer/RMC_Dialog.rc b/random_message_changer/RMC_Dialog.rc
new file mode 100644
index 0000000..c68f5b1
--- /dev/null
+++ b/random_message_changer/RMC_Dialog.rc
@@ -0,0 +1,121 @@
+// Microsoft Visual C++ generated resource script.
+//
+#include "resource.h"
+
+#define APSTUDIO_READONLY_SYMBOLS
+/////////////////////////////////////////////////////////////////////////////
+//
+// Generated from the TEXTINCLUDE 2 resource.
+//
+#include "afxres.h"
+
+/////////////////////////////////////////////////////////////////////////////
+#undef APSTUDIO_READONLY_SYMBOLS
+
+/////////////////////////////////////////////////////////////////////////////
+// Neutral resources
+
+#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_NEU)
+#ifdef _WIN32
+LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL
+#pragma code_page(1252)
+#endif //_WIN32
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// Dialog
+//
+
+IDD_RMC DIALOGEX 0, 0, 316, 223
+STYLE DS_SETFONT | DS_FIXEDSYS | WS_CHILD | WS_VISIBLE | WS_SYSMENU
+FONT 8, "MS Shell Dlg", 400, 0, 0x1
+BEGIN
+ LTEXT "minutes",IDC_STATIC,141,64,75,10
+ EDITTEXT IDC_Timer,109,62,25,14,ES_RIGHT | ES_AUTOHSCROLL | ES_NUMBER
+ CONTROL "change on status-change",IDC_cStatus,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,45,46,134,10
+ CONTROL "change every",IDC_cTime,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,45,64,63,10
+ CONTROL "change while away",IDC_cAway,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,27,82,95,15
+ CONTROL "change while n/a",IDC_cNA,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,27,100,95,15
+ CONTROL "change while occ",IDC_cOcc,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,27,118,95,15
+ CONTROL "change while dnd",IDC_cDnd,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,27,136,95,15
+ CONTROL "change while ffc",IDC_cFfc,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,27,154,95,15
+ EDITTEXT IDC_file_away,129,82,153,15,ES_AUTOHSCROLL,WS_EX_ACCEPTFILES
+ EDITTEXT IDC_file_na,129,100,153,15,ES_AUTOHSCROLL,WS_EX_ACCEPTFILES
+ EDITTEXT IDC_file_ffc,129,154,153,15,ES_AUTOHSCROLL,WS_EX_ACCEPTFILES
+ EDITTEXT IDC_file_dnd,129,136,153,15,ES_AUTOHSCROLL,WS_EX_ACCEPTFILES
+ EDITTEXT IDC_file_occ,129,118,153,15,ES_AUTOHSCROLL,WS_EX_ACCEPTFILES
+ GROUPBOX "Random Messages",IDC_STATIC,15,28,286,155
+END
+
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// DESIGNINFO
+//
+
+#ifdef APSTUDIO_INVOKED
+GUIDELINES DESIGNINFO
+BEGIN
+ IDD_RMC, DIALOG
+ BEGIN
+ LEFTMARGIN, 7
+ RIGHTMARGIN, 309
+ TOPMARGIN, 7
+ BOTTOMMARGIN, 216
+ END
+END
+#endif // APSTUDIO_INVOKED
+
+#endif // Neutral resources
+/////////////////////////////////////////////////////////////////////////////
+
+
+/////////////////////////////////////////////////////////////////////////////
+// English (U.S.) resources
+
+#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
+#ifdef _WIN32
+LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
+#pragma code_page(1252)
+#endif //_WIN32
+
+#ifdef APSTUDIO_INVOKED
+/////////////////////////////////////////////////////////////////////////////
+//
+// TEXTINCLUDE
+//
+
+1 TEXTINCLUDE
+BEGIN
+ "resource.h\0"
+END
+
+2 TEXTINCLUDE
+BEGIN
+ "#include ""afxres.h""\r\n"
+ "\0"
+END
+
+3 TEXTINCLUDE
+BEGIN
+ "\r\n"
+ "\0"
+END
+
+#endif // APSTUDIO_INVOKED
+
+#endif // English (U.S.) resources
+/////////////////////////////////////////////////////////////////////////////
+
+
+
+#ifndef APSTUDIO_INVOKED
+/////////////////////////////////////////////////////////////////////////////
+//
+// Generated from the TEXTINCLUDE 3 resource.
+//
+
+
+/////////////////////////////////////////////////////////////////////////////
+#endif // not APSTUDIO_INVOKED
+
diff --git a/random_message_changer/RandomMessageChanger.sln b/random_message_changer/RandomMessageChanger.sln
new file mode 100644
index 0000000..7149f3b
--- /dev/null
+++ b/random_message_changer/RandomMessageChanger.sln
@@ -0,0 +1,19 @@
+Microsoft Visual Studio Solution File, Format Version 9.00
+# Visual Studio 2005
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "RandomMessageChanger", "RandomMessageChanger.vcproj", "{CCF6D3F2-132C-4A7A-B342-27577DFBA73A}"
+EndProject
+Global
+ GlobalSection(SolutionConfigurationPlatforms) = preSolution
+ Debug|Win32 = Debug|Win32
+ Release|Win32 = Release|Win32
+ EndGlobalSection
+ GlobalSection(ProjectConfigurationPlatforms) = postSolution
+ {CCF6D3F2-132C-4A7A-B342-27577DFBA73A}.Debug|Win32.ActiveCfg = Debug|Win32
+ {CCF6D3F2-132C-4A7A-B342-27577DFBA73A}.Debug|Win32.Build.0 = Debug|Win32
+ {CCF6D3F2-132C-4A7A-B342-27577DFBA73A}.Release|Win32.ActiveCfg = Release|Win32
+ {CCF6D3F2-132C-4A7A-B342-27577DFBA73A}.Release|Win32.Build.0 = Release|Win32
+ EndGlobalSection
+ GlobalSection(SolutionProperties) = preSolution
+ HideSolutionNode = FALSE
+ EndGlobalSection
+EndGlobal
diff --git a/random_message_changer/RandomMessageChanger.vcproj b/random_message_changer/RandomMessageChanger.vcproj
new file mode 100644
index 0000000..29a85b8
--- /dev/null
+++ b/random_message_changer/RandomMessageChanger.vcproj
@@ -0,0 +1,364 @@
+<?xml version="1.0" encoding="Windows-1252"?>
+<VisualStudioProject
+ ProjectType="Visual C++"
+ Version="8.00"
+ Name="RandomMessageChanger"
+ ProjectGUID="{CCF6D3F2-132C-4A7A-B342-27577DFBA73A}"
+ RootNamespace="RandomMessageChanger"
+ >
+ <Platforms>
+ <Platform
+ Name="Win32"
+ />
+ </Platforms>
+ <ToolFiles>
+ </ToolFiles>
+ <Configurations>
+ <Configuration
+ Name="Debug|Win32"
+ OutputDirectory="$(SolutionDir)$(ConfigurationName)"
+ IntermediateDirectory="$(ConfigurationName)"
+ ConfigurationType="2"
+ InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC70.vsprops"
+ UseOfMFC="0"
+ ATLMinimizesCRunTimeLibraryUsage="false"
+ CharacterSet="2"
+ >
+ <Tool
+ Name="VCPreBuildEventTool"
+ />
+ <Tool
+ Name="VCCustomBuildTool"
+ />
+ <Tool
+ Name="VCXMLDataGeneratorTool"
+ />
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"
+ />
+ <Tool
+ Name="VCMIDLTool"
+ PreprocessorDefinitions="_DEBUG"
+ MkTypLibCompatible="true"
+ SuppressStartupBanner="true"
+ TargetEnvironment="1"
+ TypeLibraryName="d:\RandomMessageChanger\Debug/RandomMessageChanger.tlb"
+ />
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ AdditionalIncludeDirectories="../../include"
+ PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL"
+ BasicRuntimeChecks="3"
+ RuntimeLibrary="1"
+ UsePrecompiledHeader="0"
+ WarningLevel="3"
+ SuppressStartupBanner="true"
+ DebugInformationFormat="4"
+ DisableSpecificWarnings="4996"
+ />
+ <Tool
+ Name="VCManagedResourceCompilerTool"
+ />
+ <Tool
+ Name="VCResourceCompilerTool"
+ PreprocessorDefinitions="_DEBUG"
+ Culture="1033"
+ />
+ <Tool
+ Name="VCPreLinkEventTool"
+ />
+ <Tool
+ Name="VCLinkerTool"
+ AdditionalOptions="/MACHINE:I386"
+ AdditionalDependencies="odbc32.lib odbccp32.lib"
+ OutputFile="../../bin/$(ConfigurationName)/plugins/rmc.dll"
+ LinkIncremental="2"
+ SuppressStartupBanner="true"
+ GenerateDebugInformation="true"
+ SubSystem="2"
+ />
+ <Tool
+ Name="VCALinkTool"
+ />
+ <Tool
+ Name="VCManifestTool"
+ />
+ <Tool
+ Name="VCXDCMakeTool"
+ />
+ <Tool
+ Name="VCBscMakeTool"
+ />
+ <Tool
+ Name="VCFxCopTool"
+ />
+ <Tool
+ Name="VCAppVerifierTool"
+ />
+ <Tool
+ Name="VCWebDeploymentTool"
+ />
+ <Tool
+ Name="VCPostBuildEventTool"
+ />
+ </Configuration>
+ <Configuration
+ Name="Release|Win32"
+ OutputDirectory="$(SolutionDir)$(ConfigurationName)"
+ IntermediateDirectory="$(ConfigurationName)"
+ ConfigurationType="2"
+ InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC70.vsprops"
+ UseOfMFC="0"
+ ATLMinimizesCRunTimeLibraryUsage="false"
+ CharacterSet="2"
+ WholeProgramOptimization="1"
+ >
+ <Tool
+ Name="VCPreBuildEventTool"
+ />
+ <Tool
+ Name="VCCustomBuildTool"
+ />
+ <Tool
+ Name="VCXMLDataGeneratorTool"
+ />
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"
+ />
+ <Tool
+ Name="VCMIDLTool"
+ PreprocessorDefinitions="NDEBUG"
+ MkTypLibCompatible="true"
+ SuppressStartupBanner="true"
+ TargetEnvironment="1"
+ GenerateTypeLibrary="false"
+ TypeLibraryName="d:\RandomMessageChanger/RandomMessageChanger.tlb"
+ />
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="1"
+ InlineFunctionExpansion="0"
+ FavorSizeOrSpeed="2"
+ WholeProgramOptimization="true"
+ AdditionalIncludeDirectories="../../include"
+ PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL"
+ StructMemberAlignment="0"
+ UsePrecompiledHeader="2"
+ PrecompiledHeaderThrough="common.h"
+ WarningLevel="3"
+ SuppressStartupBanner="true"
+ DebugInformationFormat="3"
+ DisableSpecificWarnings="4996"
+ />
+ <Tool
+ Name="VCManagedResourceCompilerTool"
+ />
+ <Tool
+ Name="VCResourceCompilerTool"
+ PreprocessorDefinitions="NDEBUG"
+ Culture="1033"
+ />
+ <Tool
+ Name="VCPreLinkEventTool"
+ />
+ <Tool
+ Name="VCLinkerTool"
+ AdditionalOptions="/MACHINE:I386"
+ AdditionalDependencies="odbc32.lib odbccp32.lib"
+ OutputFile="../../bin/$(ConfigurationName)/plugins/rmc.dll"
+ LinkIncremental="1"
+ SuppressStartupBanner="true"
+ IgnoreAllDefaultLibraries="false"
+ SubSystem="2"
+ OptimizeReferences="2"
+ EnableCOMDATFolding="2"
+ OptimizeForWindows98="1"
+ TargetMachine="0"
+ />
+ <Tool
+ Name="VCALinkTool"
+ />
+ <Tool
+ Name="VCManifestTool"
+ />
+ <Tool
+ Name="VCXDCMakeTool"
+ />
+ <Tool
+ Name="VCBscMakeTool"
+ />
+ <Tool
+ Name="VCFxCopTool"
+ />
+ <Tool
+ Name="VCAppVerifierTool"
+ />
+ <Tool
+ Name="VCWebDeploymentTool"
+ />
+ <Tool
+ Name="VCPostBuildEventTool"
+ />
+ </Configuration>
+ <Configuration
+ Name="MyConfig|Win32"
+ OutputDirectory="$(SolutionDir)$(ConfigurationName)"
+ IntermediateDirectory="$(ConfigurationName)"
+ ConfigurationType="2"
+ InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC70.vsprops"
+ UseOfMFC="0"
+ ATLMinimizesCRunTimeLibraryUsage="false"
+ CharacterSet="0"
+ >
+ <Tool
+ Name="VCPreBuildEventTool"
+ />
+ <Tool
+ Name="VCCustomBuildTool"
+ />
+ <Tool
+ Name="VCXMLDataGeneratorTool"
+ />
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"
+ />
+ <Tool
+ Name="VCMIDLTool"
+ />
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="1"
+ FavorSizeOrSpeed="2"
+ AdditionalIncludeDirectories="../../include"
+ GeneratePreprocessedFile="0"
+ StringPooling="true"
+ StructMemberAlignment="0"
+ DisableLanguageExtensions="false"
+ DisableSpecificWarnings="4996"
+ ShowIncludes="false"
+ UndefineAllPreprocessorDefinitions="false"
+ />
+ <Tool
+ Name="VCManagedResourceCompilerTool"
+ />
+ <Tool
+ Name="VCResourceCompilerTool"
+ />
+ <Tool
+ Name="VCPreLinkEventTool"
+ />
+ <Tool
+ Name="VCLinkerTool"
+ IgnoreImportLibrary="true"
+ OutputFile="../../bin/$(ConfigurationName)/plugins/rmc.dll"
+ Version="0.0.1.0"
+ LinkIncremental="1"
+ SuppressStartupBanner="true"
+ IgnoreAllDefaultLibraries="false"
+ IgnoreEmbeddedIDL="false"
+ SubSystem="2"
+ OptimizeReferences="2"
+ EnableCOMDATFolding="2"
+ OptimizeForWindows98="1"
+ ResourceOnlyDLL="false"
+ TurnOffAssemblyGeneration="true"
+ />
+ <Tool
+ Name="VCALinkTool"
+ />
+ <Tool
+ Name="VCManifestTool"
+ />
+ <Tool
+ Name="VCXDCMakeTool"
+ />
+ <Tool
+ Name="VCBscMakeTool"
+ />
+ <Tool
+ Name="VCFxCopTool"
+ />
+ <Tool
+ Name="VCAppVerifierTool"
+ />
+ <Tool
+ Name="VCWebDeploymentTool"
+ />
+ <Tool
+ Name="VCPostBuildEventTool"
+ />
+ </Configuration>
+ </Configurations>
+ <References>
+ </References>
+ <Files>
+ <Filter
+ Name="Source Files"
+ Filter="cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
+ >
+ <File
+ RelativePath=".\main.cpp"
+ >
+ <FileConfiguration
+ Name="Debug|Win32"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ UsePrecompiledHeader="1"
+ PrecompiledHeaderThrough="common.h"
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Release|Win32"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ UsePrecompiledHeader="1"
+ />
+ </FileConfiguration>
+ </File>
+ <File
+ RelativePath=".\options.cpp"
+ >
+ <FileConfiguration
+ Name="Debug|Win32"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ UsePrecompiledHeader="2"
+ PrecompiledHeaderThrough="common.h"
+ />
+ </FileConfiguration>
+ </File>
+ <File
+ RelativePath="RMC_Dialog.rc"
+ >
+ </File>
+ </Filter>
+ <Filter
+ Name="Header Files"
+ Filter="h;hpp;hxx;hm;inl"
+ >
+ <File
+ RelativePath=".\common.h"
+ >
+ </File>
+ <File
+ RelativePath=".\options.h"
+ >
+ </File>
+ <File
+ RelativePath="resource.h"
+ >
+ </File>
+ </Filter>
+ <Filter
+ Name="Resource Files"
+ Filter="ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe"
+ >
+ </Filter>
+ </Files>
+ <Globals>
+ </Globals>
+</VisualStudioProject>
diff --git a/random_message_changer/common.h b/random_message_changer/common.h
new file mode 100644
index 0000000..c42c22c
--- /dev/null
+++ b/random_message_changer/common.h
@@ -0,0 +1,33 @@
+#ifndef _COMMON_INC
+#define _COMMON_INC
+
+//---------------------------------------------------------------------------
+#include <windows.h>
+#include <prsht.h>
+#include <newpluginapi.h>
+#include <m_database.h>
+#include <m_langpack.h>
+#include <m_clist.h>
+#include <m_protosvc.h>
+#include <m_skin.h>
+#include <m_options.h>
+#include "resource.h"
+
+//#include <iostream>
+//#include <fstream>
+#include <stdio.h>
+#include <time.h>
+
+#define RMC "RandomMessageChanger"
+//---------------------------------------------------------------------------
+extern PLUGINLINK *pluginLink;
+extern HINSTANCE hInst;
+
+//---------------------------------------------------------------------------
+
+#define STRING_LENGTH 265
+
+void SetChangingTime();
+
+//---------------------------------------------------------------------------
+#endif
diff --git a/random_message_changer/main.cpp b/random_message_changer/main.cpp
new file mode 100644
index 0000000..d07c891
--- /dev/null
+++ b/random_message_changer/main.cpp
@@ -0,0 +1,184 @@
+//---------------------------------------------------------------------------
+#include "common.h"
+#include "options.h"
+
+PLUGINLINK *pluginLink;
+HINSTANCE hInst;
+
+PLUGININFO pluginInfo={
+ sizeof(PLUGININFO),
+ "Random Message Changer",
+ PLUGIN_MAKE_VERSION(0,0,2,2),
+ "Loads a random Status-Message from a file.",
+ "Christian Weihs & Scott Ellis",
+ "mail@scottellis.com.au",
+ "2003 Christian Weihs, 2006 Scott Ellis",
+ "http://www.scottellis.com.au",
+ 0,
+ 0
+};
+
+//---------------------------------------------------------------------------
+extern "C" BOOL APIENTRY DllMain(HMODULE hinstDLL, DWORD fdwReason, LPVOID lpvReserved) {
+ hInst=hinstDLL;
+ return TRUE;
+}
+
+//---------------------------------------------------------------------------
+extern "C" __declspec(dllexport) PLUGININFO* MirandaPluginInfo(DWORD mirandaVersion) {
+ return &pluginInfo;
+}
+
+UINT TimerId;
+
+void ChangeAllProtoMessages(int statusMode, char *msg) {
+ int protoCount,i;
+ PROTOCOLDESCRIPTOR **proto;
+
+ CallService(MS_PROTO_ENUMPROTOCOLS,(WPARAM)&protoCount,(LPARAM)&proto);
+ for(i=0;i<protoCount;i++)
+ CallProtoService(proto[i]->szName,PS_SETAWAYMSG,statusMode,(LPARAM)msg);
+}
+
+// sucht eine neue Message heraus.
+char *GetRandomLine(char *file, char *buff, int bufflen) {
+ if (file == 0 || file[0] == 0 || file[0] == ':') return 0;
+
+ FILE *inFile = fopen(file, "rt");
+ if (!inFile){
+ KillTimer(NULL, TimerId);
+ MessageBox(NULL, Translate("Can't open file!"), Translate("RMC Error"), MB_OK | MB_ICONERROR);
+ return 0;
+ }
+
+ char *line[1000];
+ char zeile[2048];
+ int i=0;
+ while( i < 1000 && !feof(inFile)) {
+ fgets(zeile, sizeof(zeile), inFile);
+
+ unsigned int x=0;
+ bool test=false;
+
+ while(x < sizeof(zeile) && zeile[x]!=0) {
+ if(zeile[x] == '#' || zeile[x] == '\r' || zeile[x] == '\n') {
+ zeile[x] = 0;
+ x = sizeof(zeile);
+ } else {
+ if(zeile[x]!= ' ') test=true;
+
+ if (zeile[x] == '\\' && zeile[x+1] == 'n') {
+ zeile[x+1]= '\n';
+ zeile[x]= '\r';
+ }
+ }
+ x++;
+ }
+
+ if(test) line[i++]=strdup(zeile);
+ }
+ fclose(inFile);
+
+ if(i != 0) {
+ int num = rand()%i;
+ strncpy(buff,line[num],bufflen);
+ for(int x=0;x<i;x++)
+ free(line[x]);
+ return buff;
+ }
+
+ return 0;
+}
+
+void CALLBACK TimerCall(HWND hwnd, UINT message, UINT idEvent, DWORD dwTime) {
+ char *file;
+ char *mode;
+ char *mode2;
+ bool enabled;
+ int mirandaStatus=CallService(MS_CLIST_GETSTATUSMODE,0,0);
+
+ switch(mirandaStatus) {
+ case ID_STATUS_AWAY:
+ file = options.file_away;
+ enabled = options.cAway;
+ mode="AwayDefault";
+ mode2="AwayMsg";
+ break;
+ case ID_STATUS_NA:
+ file = options.file_na;
+ enabled = options.cNa;
+ mode="NaDefault";
+ mode2="NaMsg";
+ break;
+ case ID_STATUS_OCCUPIED:
+ file = options.file_occ;
+ enabled = options.cOcc;
+ mode="OccupiedDefault";
+ mode2="OccupiedMsg";
+ break;
+ case ID_STATUS_DND:
+ file = options.file_dnd;
+ enabled = options.cDnd;
+ mode="DndDefault";
+ mode2="DndMsg";
+ break;
+ case ID_STATUS_FREECHAT:
+ file = options.file_ffc;
+ enabled = options.cFfc;
+ mode="FreeChatDefault";
+ mode2="FreeChatMsg";
+ break;
+ default:
+ enabled=false;
+ }
+
+ if (enabled) {
+ char msg[2048];
+ GetRandomLine(file, msg, sizeof(msg));
+ if (msg!=0) {
+ ChangeAllProtoMessages(mirandaStatus, msg);
+ DBWriteContactSettingString(NULL, "SRAway", mode, msg);
+ DBWriteContactSettingString(NULL, "SRAway", mode2, msg);
+ }
+ }
+}
+
+//setzt den Timer neu
+void SetChangingTime() {
+ if(TimerId) KillTimer(NULL, TimerId);
+ if(options.cTime) TimerId = SetTimer(0, 0, (UINT)(options.iTimeOut*1000*60), TimerCall);
+}
+
+// Was tun, wenn der Status sich ändert?
+int StatusChanged(WPARAM wParam,LPARAM lParam) {
+ SetChangingTime();
+ if(options.cStatus) TimerCall(0, 0, 0, 0);
+ return 0;
+}
+
+//---------------------------------------------------------------------------
+HANDLE hEventStsChange = 0;
+extern "C" int __declspec(dllexport) Load(PLUGINLINK *link) {
+ pluginLink=link;
+
+ // Events verbinden
+ hEventStsChange = HookEvent(ME_CLIST_STATUSMODECHANGE,StatusChanged);
+
+ srand((unsigned int)time(0));
+ //Die Werte aus der Datenbank laden
+ LoadOptions();
+
+ // test crash for attache
+ //int *i = 0;
+ //*i = 0;
+
+ return 0;
+}
+
+//---------------------------------------------------------------------------
+extern "C" int __declspec(dllexport) Unload() {
+ UnhookEvent(hEventStsChange);
+ KillTimer(NULL, TimerId);
+ return 0;
+}
+//---------------------------------------------------------------------------
diff --git a/random_message_changer/options.cpp b/random_message_changer/options.cpp
new file mode 100644
index 0000000..9efb259
--- /dev/null
+++ b/random_message_changer/options.cpp
@@ -0,0 +1,168 @@
+#include "common.h"
+#include "options.h"
+
+Options options;
+
+#define WMU_SETBUTTONS (WM_USER + 0x100)
+
+void GetDBString(char *buff, int buffsize, char *setting, char *def) {
+ DBVARIANT dbv;
+ if(!DBGetContactSetting(NULL,RMC,setting,&dbv)) {
+ strncpy(buff, dbv.pszVal, buffsize);
+ DBFreeVariant(&dbv);
+ } else
+ strncpy(buff, def, STRING_LENGTH);
+}
+
+//Methode für den Optionsdialog
+int CALLBACK MainDlgProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam){
+ switch (uMsg){
+ case WM_INITDIALOG:
+ // Die Dialogfelder vorbereiten:
+ TranslateDialogDefault(hwndDlg);
+ SetDlgItemInt(hwndDlg, IDC_Timer, options.iTimeOut, TRUE);
+ CheckDlgButton(hwndDlg,IDC_cStatus,options.cStatus);
+ CheckDlgButton(hwndDlg,IDC_cTime,options.cTime);
+
+ CheckDlgButton(hwndDlg,IDC_cAway,options.cAway);
+ CheckDlgButton(hwndDlg,IDC_cNA,options.cNa);
+ CheckDlgButton(hwndDlg,IDC_cOcc,options.cOcc);
+ CheckDlgButton(hwndDlg,IDC_cDnd,options.cDnd);
+ CheckDlgButton(hwndDlg,IDC_cFfc,options.cFfc);
+
+ SetDlgItemText(hwndDlg,IDC_file_away, options.file_away);
+ SetDlgItemText(hwndDlg,IDC_file_na, options.file_na);
+ SetDlgItemText(hwndDlg,IDC_file_occ, options.file_occ);
+ SetDlgItemText(hwndDlg,IDC_file_dnd, options.file_dnd);
+ SetDlgItemText(hwndDlg,IDC_file_ffc, options.file_ffc);
+
+ SendMessage(hwndDlg, WMU_SETBUTTONS, 0, 0);
+ return TRUE;
+ case WMU_SETBUTTONS:
+ {
+ bool en=(IsDlgButtonChecked(hwndDlg,IDC_cTime)==1)||(IsDlgButtonChecked(hwndDlg,IDC_cStatus)==1);
+ EnableWindow(GetDlgItem(hwndDlg, IDC_file_away),(IsDlgButtonChecked(hwndDlg,IDC_cAway)==1)&&en);
+ EnableWindow(GetDlgItem(hwndDlg, IDC_file_na),(IsDlgButtonChecked(hwndDlg,IDC_cNA)==1)&&en);
+ EnableWindow(GetDlgItem(hwndDlg, IDC_file_occ),(IsDlgButtonChecked(hwndDlg,IDC_cOcc)==1)&&en);
+ EnableWindow(GetDlgItem(hwndDlg, IDC_file_dnd),(IsDlgButtonChecked(hwndDlg,IDC_cDnd)==1)&&en);
+ EnableWindow(GetDlgItem(hwndDlg, IDC_file_ffc),(IsDlgButtonChecked(hwndDlg,IDC_cFfc)==1)&&en);
+ EnableWindow(GetDlgItem(hwndDlg, IDC_Timer),IsDlgButtonChecked(hwndDlg,IDC_cTime)==1);
+
+ EnableWindow(GetDlgItem(hwndDlg, IDC_cAway),en);
+ EnableWindow(GetDlgItem(hwndDlg, IDC_cNA),en);
+ EnableWindow(GetDlgItem(hwndDlg, IDC_cOcc),en);
+ EnableWindow(GetDlgItem(hwndDlg, IDC_cDnd),en);
+ EnableWindow(GetDlgItem(hwndDlg, IDC_cFfc),en);
+ }
+ return TRUE;
+ case WM_COMMAND:
+ if ( HIWORD( wParam ) == BN_CLICKED ) {
+ SendMessage(hwndDlg, WMU_SETBUTTONS, 0, 0);
+ SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
+ } else if ( HIWORD( wParam ) == EN_CHANGE && ( HWND )lParam == GetFocus()) {
+ SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
+ }
+
+ break;
+ case WM_NOTIFY:{
+ NMHDR* nmhdr = (NMHDR*)lParam;
+ switch (nmhdr->code){
+ case PSN_APPLY:
+ // DIe DIalogfelder auslesen, in die Variablen speichern und in die Datenbank schreiben
+ options.iTimeOut = GetDlgItemInt(hwndDlg, IDC_Timer, NULL, TRUE);
+ if (options.iTimeOut<1) {
+ options.iTimeOut=1;
+ SetDlgItemInt(hwndDlg, IDC_Timer, 1, TRUE);
+ }
+ DBWriteContactSettingDword(NULL, RMC, "TimeOut", options.iTimeOut);
+
+ options.cStatus = IsDlgButtonChecked(hwndDlg,IDC_cStatus)==1;
+ DBWriteContactSettingByte(NULL,RMC,"enable_status",(BYTE)options.cStatus);
+
+ options.cTime = IsDlgButtonChecked(hwndDlg,IDC_cTime)==1;
+ DBWriteContactSettingByte(NULL,RMC,"enable_time",(BYTE)options.cTime);
+
+ options.cAway = IsDlgButtonChecked(hwndDlg,IDC_cAway)==1;
+ DBWriteContactSettingByte(NULL,RMC,"enable_away",(BYTE)options.cAway);
+
+ options.cNa = IsDlgButtonChecked(hwndDlg,IDC_cNA)==1;
+ DBWriteContactSettingByte(NULL,RMC,"enable_na",(BYTE)options.cNa);
+
+ options.cOcc = IsDlgButtonChecked(hwndDlg,IDC_cOcc)==1;
+ DBWriteContactSettingByte(NULL,RMC,"enable_occ",(BYTE)options.cOcc);
+
+ options.cDnd = IsDlgButtonChecked(hwndDlg,IDC_cDnd)==1;
+ DBWriteContactSettingByte(NULL,RMC,"enable_dnd",(BYTE)options.cDnd);
+
+ options.cFfc = IsDlgButtonChecked(hwndDlg,IDC_cFfc)==1;
+ DBWriteContactSettingByte(NULL,RMC,"enable_ffc",(BYTE)options.cFfc);
+
+
+
+ GetDlgItemText(hwndDlg,IDC_file_away,options.file_away,STRING_LENGTH);
+ DBWriteContactSettingString(NULL,RMC,"file_away",options.file_away);
+
+ GetDlgItemText(hwndDlg,IDC_file_na,options.file_na,STRING_LENGTH);
+ DBWriteContactSettingString(NULL,RMC,"file_na",options.file_na);
+
+ GetDlgItemText(hwndDlg,IDC_file_occ,options.file_occ,STRING_LENGTH);
+ DBWriteContactSettingString(NULL,RMC,"file_occ",options.file_occ);
+
+ GetDlgItemText(hwndDlg,IDC_file_dnd,options.file_dnd,STRING_LENGTH);
+ DBWriteContactSettingString(NULL,RMC,"file_dnd",options.file_dnd);
+
+ GetDlgItemText(hwndDlg,IDC_file_ffc,options.file_ffc,STRING_LENGTH);
+ DBWriteContactSettingString(NULL,RMC,"file_ffc",options.file_ffc);
+
+ //Timer starten
+ SetChangingTime();
+ return TRUE;
+
+ }
+ break;
+
+ }
+ }
+
+ return 0;
+}
+
+//Initialisierung des Options-Dialogs
+int MessageOptInit(WPARAM wParam, LPARAM lParam){
+ OPTIONSDIALOGPAGE odp;
+ ZeroMemory(&odp, sizeof(odp));
+ odp.cbSize = sizeof(odp);
+ odp.position = 910000000;
+ odp.hInstance = hInst;
+ odp.pszTemplate = MAKEINTRESOURCE(IDD_RMC);
+ odp.pszTitle = "Random Messages";
+ odp.pszGroup = "Status";
+ odp.pfnDlgProc = MainDlgProc;
+
+ CallService(MS_OPT_ADDPAGE, wParam, (LPARAM)&odp);
+
+ return 0;
+}
+
+
+HANDLE hEventOptInitialise = 0;
+void LoadOptions() {
+ options.iTimeOut = DBGetContactSettingDword(NULL, RMC, "TimeOut", 10);
+ options.cStatus = DBGetContactSettingByte(NULL, RMC, "enable_status", 0)==1;
+ options.cTime = DBGetContactSettingByte(NULL, RMC, "enable_time", 0)==1;
+
+ options.cAway = DBGetContactSettingByte(NULL, RMC, "enable_away", 0)==1;
+ options.cNa = DBGetContactSettingByte(NULL, RMC, "enable_na", 0)==1;
+ options.cOcc = DBGetContactSettingByte(NULL, RMC, "enable_occ", 0)==1;
+ options.cDnd = DBGetContactSettingByte(NULL, RMC, "enable_dnd", 0)==1;
+ options.cFfc = DBGetContactSettingByte(NULL, RMC, "enable_ffc", 0)==1;
+
+ GetDBString(options.file_away, STRING_LENGTH, "file_away", "plugins\\sample.txt");
+ GetDBString(options.file_na, STRING_LENGTH, "file_na", "plugins\\sample.txt");
+ GetDBString(options.file_occ, STRING_LENGTH, "file_occ", "plugins\\sample.txt");
+ GetDBString(options.file_dnd, STRING_LENGTH, "file_dnd", "plugins\\sample.txt");
+ GetDBString(options.file_ffc, STRING_LENGTH, "file_ffc", "plugins\\sample.txt");
+
+ hEventOptInitialise = HookEvent(ME_OPT_INITIALISE, MessageOptInit);
+}
+
diff --git a/random_message_changer/options.h b/random_message_changer/options.h
new file mode 100644
index 0000000..9fe6a0a
--- /dev/null
+++ b/random_message_changer/options.h
@@ -0,0 +1,26 @@
+#ifndef _OPTIONS_INC
+#define _OPTIONS_INC
+
+typedef struct {
+ int iTimeOut;
+ bool cStatus;
+ bool cTime;
+ bool cAway;
+ bool cNa;
+ bool cOcc;
+ bool cDnd;
+ bool cFfc;
+
+ char file_away[STRING_LENGTH];
+ char file_na[STRING_LENGTH];
+ char file_occ[STRING_LENGTH];
+ char file_dnd[STRING_LENGTH];
+ char file_ffc[STRING_LENGTH];
+} Options;
+
+extern Options options;
+
+void LoadOptions();
+void SaveOptions();
+
+#endif
diff --git a/random_message_changer/resource.h b/random_message_changer/resource.h
new file mode 100644
index 0000000..73280dc
--- /dev/null
+++ b/random_message_changer/resource.h
@@ -0,0 +1,31 @@
+//{{NO_DEPENDENCIES}}
+// Microsoft Visual C++ generated include file.
+// Used by RMC_Dialog.rc
+//
+#define IDD_RMC 101
+#define IDC_EDIT1 1001
+#define IDC_Timer 1001
+#define IDC_cStatus 1002
+#define IDC_cTime 1003
+#define IDC_cAway 1004
+#define IDC_cNA 1005
+#define IDC_cOcc 1006
+#define IDC_cDnd 1007
+#define IDC_cFfc 1008
+#define IDC_file_away 1009
+#define IDC_file_na 1010
+#define IDC_file_away3 1011
+#define IDC_file_ffc 1011
+#define IDC_file_dnd 1012
+#define IDC_file_occ 1013
+
+// Next default values for new objects
+//
+#ifdef APSTUDIO_INVOKED
+#ifndef APSTUDIO_READONLY_SYMBOLS
+#define _APS_NEXT_RESOURCE_VALUE 102
+#define _APS_NEXT_COMMAND_VALUE 40001
+#define _APS_NEXT_CONTROL_VALUE 1010
+#define _APS_NEXT_SYMED_VALUE 101
+#endif
+#endif
diff --git a/random_message_changer/rmc.mdsp b/random_message_changer/rmc.mdsp
new file mode 100644
index 0000000..d3e332b
--- /dev/null
+++ b/random_message_changer/rmc.mdsp
@@ -0,0 +1,96 @@
+[Project]
+name=rmc
+type=2
+defaultConfig=0
+
+
+[Debug]
+// compiler
+workingDirectory=
+arguments=
+intermediateFilesDirectory=Debug
+outputFilesDirectory=Debug
+compilerPreprocessor=
+extraCompilerOptions=
+compilerIncludeDirectory=..\..\include
+noWarning=0
+defaultWarning=0
+allWarning=1
+extraWarning=0
+isoWarning=0
+warningsAsErrors=0
+debugType=1
+debugLevel=2
+exceptionEnabled=1
+runtimeTypeEnabled=1
+optimizeLevel=0
+
+// linker
+libraryPath=
+outputFilename=Debug\rmc.dll
+libraries=
+extraLinkerOptions=
+ignoreStartupFile=0
+ignoreDefaultLibs=0
+stripExecutableFile=0
+
+// archive
+extraArchiveOptions=
+
+//resource
+resourcePreprocessor=
+resourceIncludeDirectory=
+extraResourceOptions=
+
+[Release]
+// compiler
+workingDirectory=
+arguments=
+intermediateFilesDirectory=Release
+outputFilesDirectory=Release
+compilerPreprocessor=
+extraCompilerOptions=
+compilerIncludeDirectory=..\..\include
+noWarning=0
+defaultWarning=0
+allWarning=1
+extraWarning=0
+isoWarning=0
+warningAsErrors=0
+debugType=0
+debugLevel=1
+exceptionEnabled=0
+runtimeTypeEnabled=0
+optimizeLevel=3
+
+// linker
+libraryPath=
+outputFilename=Release\rmc.dll
+libraries=
+extraLinkerOptions=
+ignoreStartupFile=0
+ignoreDefaultLibs=0
+stripExecutableFile=1
+
+// archive
+extraArchiveOptions=
+
+//resource
+resourcePreprocessor=
+resourceIncludeDirectory=
+extraResourceOptions=
+
+[Source]
+1=main.cpp
+2=options.cpp
+[Header]
+1=common.h
+2=options.h
+3=resource.h
+[Resource]
+1=RMC_Dialog.rc
+[Other]
+[History]
+options.cpp,2533
+common.h,404
+main.cpp,666