diff options
Diffstat (limited to 'plugins/Pascal_Headers/reserve/helpers')
9 files changed, 2273 insertions, 0 deletions
diff --git a/plugins/Pascal_Headers/reserve/helpers/m_DataAsMessage.inc b/plugins/Pascal_Headers/reserve/helpers/m_DataAsMessage.inc new file mode 100644 index 0000000000..b7a60ca080 --- /dev/null +++ b/plugins/Pascal_Headers/reserve/helpers/m_DataAsMessage.inc @@ -0,0 +1,155 @@ +{
+ DataAsMessage plugin for Miranda IM
+ Copyright (c) 2006 Chervov Dmitry
+
+ 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+}
+
+{$IFNDEF M_DATAASMESSAGE}
+{$DEFINE M_DATAASMESSAGE}
+
+const
+// DAM_SENDRESULTINFO::iResult values
+ DAM_SR_SUCCESS = 0;
+ DAM_SR_TIMEOUT = 1; // timeout period expired; this value is returned
+ // also if the contact went offline for a time
+ // longer than a timeout period
+ DAM_SR_NOTSUPPORTED = 2; // means this szDataType is not supported by the
+ // remote side
+ DAM_SR_NODAM = 3; // means there is no DataAsMessage plugin on the
+ // remote side; keep in mind that this error may
+ // also appear accidentally because of a bad
+ // connectivity during the handshake (if there
+ // was a timeout when waiting for a response)
+ DAM_SR_CANCELLEDLOCAL = 4; // cancelled from the local(sending) side
+ DAM_SR_CANCELLEDREMOTE = 5; // cancelled from the remote(receiving) side
+ DAM_SR_BADCRC = 6; // bad CRC; we can't do anything with this error. presumably, it will happen rarely, and the most probable cause is the protocol that filters some of characters in our messages OR it may be a bug in DataAsMessage plugin (hopefully not ;) ).
+ DAM_SR_UNKNOWN = 7; // unknown error
+
+// Return values for DAM_SENDRESULTPROC
+ DAM_SRA_RETRY = 1;
+
+type
+// hContact, szDataType and SessionID fields correspond to the fields of the
+// DAM_SENDDATAINFO structure
+ PDAM_SENDRESULTINFO = ^TDAM_SENDRESULTINFO;
+ TDAM_SENDRESULTINFO = record
+ cbSize :int; // sizeof(DAM_SENDRESULTINFO)
+ hContact :THANDLE;
+ szDataType:PAnsiChar;
+ SessionID :dword;
+ iResult :int; // transmission result code
+ end;
+
+type
+ TDAM_SENDRESULTPROC = function(sri:PDAM_SENDRESULTINFO):int; cdecl;
+// this procedure receives the result of the transmission. it's called when the
+// session closes (either the data was sent successfully or there was an error)
+// you can return DAM_SRA_RETRY when iResult is DAM_SR_TIMEOUT if you want to
+// retry sending
+
+const
+// DAM_SENDDATAINFO::Flags constants
+ DAM_SDF_DONTPACK = 1; // don't pack the data (by default all the data is packed)
+ DAM_SDF_NOTIMEOUT = 2; // don't generate a timeout error ever, keep trying to
+ // send the data. If the contact is offline, the data
+ // is saved in the memory until the contact goes online.
+ // Loss of the data occurs only if the sender's miranda
+ // closes (this may change in future to allow fully
+ // functional offline sending that will guarantee the
+ // data to be sent in any case, but of course the
+ // sending starts only when the both contacts are
+ // online). other errors than the timeout error can be
+ // still generated though.
+
+type
+ TDAM_SENDDATAINFO = record
+ cbSize :int; // sizeof(DAM_SENDDATAINFO)
+ hContact :THANDLE;
+ szDataType:PAnsiChar; // zero-terminated string, containing data type,
+ // preferably in format "YourPluginName" or
+ // "YourPluginName/Something" (make sure this string
+ // won't coincide by an accident with someone else's
+ // string!). you can identify your data by this ID later
+ nDataLen :int; // keep in mind that if the length is too big (more than
+ // about 8 KB), it's more preferable to split your data
+ // into several chunks, as you won't be able to "pick
+ // up" your data at the other end until all the data is
+ // transferred
+ cData :PAnsiChar;
+ Flags :int; // combination of the DAM_SDF_ constants
+ SendAfterSessionID:dword; // may be NULL; otherwise it's guaranteed that the
+ // sending starts only after successful completion
+ // of SendAfterSessionID session
+ SendResultProc:TDAM_SENDRESULTPROC; // pointer to a procedure that receives
+ // the result; can be NULL
+ SessionID :dword; // OUT; receives the session ID
+ end;
+
+const
+// MS_DAM_SENDDATA return values
+ DAM_SDA_NOERROR = 0;
+ DAM_SDA_NOTSUPPORTED = -1; // contact's protocol doesn't support sending/
+ // receiving messages
+ DAM_SDA_TOOMANYSESSIONS = -2; // too many sessions
+
+// MS_DAM_SENDDATA
+// sends the data
+// wParam = (WPARAM)(DAM_SENDDATAINFO*)sdi;
+// lParam = 0
+// Returns 0 (DAM_SDA_NOERROR) and fills SessionID if the session was queued for sending successfully; returns one of the DAM_SDA_ values on failure
+ MS_DAM_SENDDATA = 'DataAsMessage/SendData';
+
+function DAMSendData(hContact:THANDLE; szDataType:PAnsiChar; nDataLen:int;
+ cData:PAnsiChar; Flags:int; SendAfterSessionID:dword;
+ SendResultProc:TDAM_SENDRESULTPROC;pSessionID:pdword):int;
+var
+ sdi:TDAM_SENDDATAINFO;
+begin
+ FillChar(sdi,SizeOf(sdi),0);
+ sdi.cbSize :=SizeOf(sdi);
+ sdi.hContact :=hContact;
+ sdi.szDataType:=szDataType;
+ sdi.nDataLen :=nDataLen;
+ sdi.cData :=cData;
+ sdi.Flags :=Flags;
+ sdi.SendAfterSessionID:=SendAfterSessionID;
+ sdi.SendResultProc :=SendResultProc;
+ Result:=CallService(MS_DAM_SENDDATA,dword(@sdi),0);
+ if pSessionID<>nil then
+ pSessionID^:=sdi.SessionID;
+end;
+
+type
+ TDAM_RECVDATAINFO = record
+ cbSize :int; // sizeof(DAM_RECVDATAINFO)
+ hContact :THANDLE;
+ szDataType:PAnsiChar;
+ nDataLen :int;
+ cData :PAnsiChar;
+ end;
+
+const
+// ME_DAM_RECVDATA
+// hook up to this event to check for incoming data
+// make sure rdi->szDataType is yours before doing anything!
+// The important thing here is that your plugin will receive TWO ME_DAM_RECVDATA notifications on every single MS_DAM_SENDDATA call from a remote side:
+// The first notification arrives when the remote side starts to transmit the data. In this case DAM_RECVDATAINFO::cData = NULL (and DAM_RECVDATAINFO::nDataLen = -1) as we didn't receive any data yet. Return 1 to indicate that your plugin recognized the DAM_RECVDATAINFO::szDataType, otherwise return 0. If there are no any plugin that recognized the data, DAM cancels the transfer and there won't be any second notification for it.
+// The second notification is when the data is transmitted successfully. nDataLen contains the usual data size and cData points to the data buffer. cData is guaranteed to be valid only during the ME_DAM_RECVDATA call. You must copy the data to your own plugin's memory if you need it later. again, return 1 to indicate that your plugin recognized the data, otherwise return 0
+// wParam = (WPARAM)(DAM_RECVDATAINFO*)rdi;
+// lParam = 0
+ ME_DAM_RECVDATA = 'DataAsMessage/RecvData';
+
+{$ENDIF}
diff --git a/plugins/Pascal_Headers/reserve/helpers/m_contactdir.inc b/plugins/Pascal_Headers/reserve/helpers/m_contactdir.inc new file mode 100644 index 0000000000..1b21717753 --- /dev/null +++ b/plugins/Pascal_Headers/reserve/helpers/m_contactdir.inc @@ -0,0 +1,164 @@ +{
+Miranda IM: the free IM client for Microsoft* Windows*
+
+Copyright 2000-2005 Miranda ICQ/IM project,
+all portions of this codebase are copyrighted to the people
+listed in contributors.txt.
+
+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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+}
+
+{$IFNDEF M_CONTACTDIR}
+{$DEFINE M_CONTACTDIR}
+
+{ Contactdir module was created on 2005/05/17, 0.4.0.1
+
+ -- How you use this module as a protocol --
+
+ On Load() Register your protocol with the setting name that stores unique IDs, example:
+
+ if ( ContactDir_SupportExists() ) g_Atom=ContactDir_Register("ICQ", "UIN");
+
+ This will register your protocol and walk the database looking for all contacts on PROTOCOL_NAME which have
+ a "UIN" setting and store it in memory (converting to a string as needed) You of course have to
+ provide fallback if the services don't exist, it's an idea to keep existing code for that.
+
+ -
+
+ When you add a new contact via MS_DB_CONTACT_ADD, you must register it with your protocol atom too, via
+ ContactDir_AddContact(atom, "UIN #", hContact) and when it is deleted ContactDir_RemoveContact(atom, "UIN #")
+
+ -
+
+ To find a contact, use ContactDir_Lookup(atom, "ICQ #") which will return the hContact.
+}
+
+type
+ PCONTACTDIRECTORYDESCRIPTOR = ^TCONTACTDIRECTORYDESCRIPTOR;
+ TCONTACTDIRECTORYDESCRIPTOR = record
+ cbSize :int;
+ szProto :PAnsiChar;
+ szSetting:PAnsiChar;
+ atom :THANDLE; // out arg
+ end;
+
+{
+ wParam: 0
+ lParam: (LPARAM) &CONTACTDIRECTORYDESCRIPTOR;
+ Affect: Register a given protocol and it's setting name which contains the unique key entry. e.g. ("ICQ", "UIN")
+ and return a HANDLE for use with other lookup services.
+ Returns: 0 on success, non zero on failure -- a returned handle is in .atom
+ Note: The directory will convert dword values into string representations but will not do this for bytes or words
+ used as IDs -- the protocol has to convert the IDs itself (:
+ Note: See ContactDir_Register() for a quicker way.
+ *** WARNING ***: This service does not expect the given module name to have registered as a protocol module, it
+ completely bypasses this information.
+ Version: 0.4.0.1 (2005/05/17+)
+}
+const
+ MS_CONTACTDIR_REGISTER = 'ContactDir/Register';
+
+type
+ PCONTACTDIRECTORYLOOKUP = ^TCONTACTDIRECTORYLOOKUP;
+ TCONTACTDIRECTORYLOOKUP = record
+ cbSize :int;
+ atom :THANDLE; // Atom handle from MS_CONTACTDIR_REGISTER
+ szID :PAnsiChar; // in: value you wish to find (makes its own copy if needed)
+ hContact:THANDLE; // out: hContact associated with szID, if any.
+ end;
+
+{
+ wParam: 0
+ lParam: (LPARAM) &CONTACTDIRECTORYLOOKUP;
+ Affect: Given an atom and string ID, will find the associated DB hContact value
+ Returns: 0 on success, non zero on failure
+ Version: 0.4.0.1 (2005/05/17+)
+ Note: ContactDir_Lookup() helper macro might be of use.
+}
+const
+ MS_CONTACTDIR_LOOKUP = 'ContactDir/Lookup';
+
+{
+ wParam: 0
+ lParam: (LPARAM)&CONTACTDIRECTORYLOOKUP;
+ Affect: Add a contact to a protocol atom association.
+ Returns: 0 on success, non zero on failure
+ Version: 0.4.0.1 (2005/05/17+)
+ Note: You must call this when you create a contact with MS_DB_CONTACT_ADD, see ContactDir_AddContact()
+}
+ MS_CONTACTDIR_ADDCONTACT = 'ContactDir/AddContact';
+
+{
+ wParam: 0
+ lParam: (LPARAM)&CONTACTDIRECTORYLOOKUP;
+ Affect: Remove a contact to a protocol atom association.
+ Returns: 0 on success, non zero on failure
+ Version: 0.4.0.1 (2005/05/17+)
+ Note: see ContactDir_RemoveContact()
+}
+ MS_CONTACTDIR_REMOVECONTACT = 'ContactDir/RemoveContact';
+
+(*
+/* -- Helper functions -- */
+
+static int ContactDir_SupportExists(void)
+{
+ return ServiceExists(MS_CONTACTDIR_REGISTER);
+}
+
+// Only take as valid if ContactDir_SupportExists() returns true.
+static HANDLE ContactDir_Register(AnsiChar * szProto, AnsiChar * szSetting)
+{
+ CONTACTDIRECTORYDESCRIPTOR cd;
+ cd.cbSize=sizeof(CONTACTDIRECTORYDESCRIPTOR);
+ cd.szProto=szProto;
+ cd.szSetting=szSetting;
+ cd.atom=NULL;
+ CallService(MS_CONTACTDIR_REGISTER, 0, (LPARAM)&cd);
+ return cd.atom;
+}
+
+static __inline HANDLE ContactDir_Lookup(HANDLE atom, AnsiChar * szID)
+{
+ CONTACTDIRECTORYLOOKUP f;
+ f.cbSize=sizeof(f);
+ f.atom=atom;
+ f.szID=szID;
+ f.hContact=NULL;
+ CallService(MS_CONTACTDIR_LOOKUP, 0, (LPARAM)&f);
+ return f.hContact;
+}
+
+static __inline void ContactDir_AddContact(HANDLE atom, AnsiChar * szID, HANDLE hContact)
+{
+ CONTACTDIRECTORYLOOKUP c = {0};
+ c.cbSize=sizeof(CONTACTDIRECTORYLOOKUP);
+ c.atom=atom;
+ c.szID=szID;
+ c.hContact=hContact;
+ CallService(MS_CONTACTDIR_ADDCONTACT, 0, (LPARAM)&c);
+}
+
+static __inline void ContactDir_RemoveContact(HANDLE atom, AnsiChar * szID)
+{
+ CONTACTDIRECTORYLOOKUP c = {0};
+ c.cbSize=sizeof(CONTACTDIRECTORYLOOKUP);
+ c.atom=atom;
+ c.szID=szID;
+ c.hContact=NULL;
+ CallService(MS_CONTACTDIR_REMOVECONTACT, 0, (LPARAM)&c);
+}
+*)
+{$ENDIF}
\ No newline at end of file diff --git a/plugins/Pascal_Headers/reserve/helpers/m_folders.inc b/plugins/Pascal_Headers/reserve/helpers/m_folders.inc new file mode 100644 index 0000000000..3cb3cbc294 --- /dev/null +++ b/plugins/Pascal_Headers/reserve/helpers/m_folders.inc @@ -0,0 +1,272 @@ +{
+Custom profile folders plugin for Miranda IM
+
+Copyright © 2005 Cristian Libotean
+
+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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+}
+
+{$IFNDEF M_FOLDERS}
+{$DEFINE M_FOLDERS}
+
+const
+ FOLDERS_API = 501; //dunno why it's here but it is :)
+
+ PROFILE_PATH = '%profile_path%';
+ CURRENT_PROFILE = '%current_profile%';
+ MIRANDA_PATH = '%miranda_path%';
+ PLUGINS_PATH = '%miranda_path%\plugins';
+ MIRANDA_USERDATA = '%miranda_userdata%';
+
+ PROFILE_PATHW = '%profile_path%';
+ CURRENT_PROFILEW = '%current_profile%';
+ MIRANDA_PATHW = '%miranda_path%';
+ MIRANDA_USERDATAW = '%miranda_userdata%';
+
+ FOLDER_AVATARS = PROFILE_PATH+'\'+CURRENT_PROFILE+'\avatars';
+ FOLDER_VCARDS = PROFILE_PATH+'\'+CURRENT_PROFILE+'\vcards';
+ FOLDER_LOGS = PROFILE_PATH+'\'+CURRENT_PROFILE+'\logs';
+ FOLDER_RECEIVED_FILES = PROFILE_PATH+'\'+CURRENT_PROFILE+'\received files';
+ FOLDER_DOCS = MIRANDA_PATH+'\'+'docs';
+
+ FOLDER_CONFIG = PLUGINS_PATH+'\config';
+ FOLDER_SCRIPTS = MIRANDA_PATH+'\scripts';
+ FOLDER_UPDATES = MIRANDA_PATH+'\updates';
+
+ FOLDER_CUSTOMIZE = MIRANDA_PATH+'\customize';
+ FOLDER_CUSTOMIZE_SOUNDS = FOLDER_CUSTOMIZE+'\sounds';
+ FOLDER_CUSTOMIZE_ICONS = FOLDER_CUSTOMIZE+'\icons';
+ FOLDER_CUSTOMIZE_SMILEYS = FOLDER_CUSTOMIZE+'\smileys';
+ FOLDER_CUSTOMIZE_SKINS = FOLDER_CUSTOMIZE+'\skins';
+ FOLDER_CUSTOMIZE_THEMES = FOLDER_CUSTOMIZE+'\themes';
+
+ FOLDERS_NAME_MAX_SIZE = 64; //maximum name and section size
+
+ FF_UNICODE = $00000001;
+
+type
+ TFOLDERSDATA = record
+ cbSize:integer; //size of struct
+ //section name, if it doesn't exist it will be created otherwise it will just add this entry to it
+ szSection:array [0..FOLDERS_NAME_MAX_SIZE-1] of AnsiChar;
+ szName :array [0..FOLDERS_NAME_MAX_SIZE-1] of AnsiChar; //entry name - will be shown in options
+ szFormat :TCHAR; // default string format. Fallback string in case
+ // there's no entry in the database for this
+ // folder. This should be the initial value for
+ // the path, users will be able to change it later.
+ flags :DWORD; // FF_* flags
+ end;
+
+const
+{
+ Folders/Register/Path service
+ wParam - not used, must be 0
+ lParam - (LPARAM) (const FOLDERDATA *) - Data structure filled with
+ the necessary information.
+ Returns a handle to the registered path or 0 on error.
+ You need to use this to call the other services.
+}
+ MS_FOLDERS_REGISTER_PATH = 'Folders/Register/Path';
+
+{
+ Folders/Get/PathSize service
+ wParam - (WPARAM) (int) - handle to registered path
+ lParam - (LPARAM) (int *) - pointer to the variable that receives the size of the path
+ string (not including the null character). Depending on the flags set when creating the path
+ it will either call strlen() or wcslen() to get the length of the string.
+ Returns the size of the buffer.
+}
+ MS_FOLDERS_GET_SIZE = 'Folders/Get/PathSize';
+
+type
+ TFOLDERSGETDATA = record
+ cbSize:integer;
+ nMaxPathSize:integer; // maximum size of buffer. This represents the number
+ // of characters that can be copied to it (so for
+ // unicode strings you don't send the number of
+ // bytes but the length of the string).
+ szPath:TChar; //pointer to the buffer that receives the path without the last "\\"
+ end;
+
+const
+{
+ Folders/Get/Path service
+ wParam - (WPARAM) (int) - handle to registered path
+ lParam - (LPARAM) (FOLDERSGETDATA *) pointer to a FOLDERSGETDATA that has all the relevant fields filled.
+ Should return 0 on success, or nonzero otherwise.
+}
+ MS_FOLDERS_GET_PATH = 'Folders/Get/Path';
+
+type
+ TFOLDERSGETALLOCDATA = record
+ cbSize:integer;
+ szPath:^TCHAR; // address of a string variable where the path should be
+ // stored (the last \ won't be copied).
+ end;
+
+const
+{
+ Folders/GetRelativePath/Alloc service
+ wParam - (WPARAM) (int) - Handle to registered path
+ lParam - (LPARAM) (FOLDERSALLOCDATA *) data
+ This service is the same as MS_FOLDERS_GET_PATH with the difference that this service
+ allocates the needed space for the buffer. It uses miranda's memory functions for that and you need
+ to use those to free the resulting buffer.
+ Should return 0 on success, or nonzero otherwise. Currently it only returns 0.
+}
+ MS_FOLDERS_GET_PATH_ALLOC = 'Folders/Get/Path/Alloc';
+
+{
+ Folders/On/Path/Changed
+ wParam - (WPARAM) 0
+ lParam - (LPARAM) 0
+ Triggered when the folders change, you should reget the paths you registered.
+}
+ ME_FOLDERS_PATH_CHANGED = 'Folders/On/Path/Changed';
+
+(*
+#ifndef FOLDERS_NO_HELPER_FUNCTIONS
+
+#ifndef M_UTILS_H__
+#error The helper functions require that m_utils.h be included in the project. Please include that file if you want to use the helper functions. If you don't want to use the functions just define FOLDERS_NO_HELPER_FUNCTIONS.
+#endif
+
+//#include "../../../include/newpluginapi.h"
+
+__inline static HANDLE FoldersRegisterCustomPath(const AnsiChar *section, const AnsiChar *name, const AnsiChar *defaultPath)
+{
+ FOLDERSDATA fd = {0};
+ if (!ServiceExists(MS_FOLDERS_REGISTER_PATH)) return 0;
+ fd.cbSize = sizeof(FOLDERSDATA);
+ strncpy(fd.szSection, section, FOLDERS_NAME_MAX_SIZE);
+ fd.szSection[FOLDERS_NAME_MAX_SIZE - 1] = '\0';
+ strncpy(fd.szName, name, FOLDERS_NAME_MAX_SIZE);
+ fd.szName[FOLDERS_NAME_MAX_SIZE - 1] = '\0';
+ fd.szFormat = defaultPath;
+ return (HANDLE) CallService(MS_FOLDERS_REGISTER_PATH, 0, (LPARAM) &fd);
+}
+
+__inline static HANDLE FoldersRegisterCustomPathW(const AnsiChar *section, const AnsiChar *name, const wchar_t *defaultPathW)
+{
+ FOLDERSDATA fd = {0};
+ if (!ServiceExists(MS_FOLDERS_REGISTER_PATH)) return 0;
+ fd.cbSize = sizeof(FOLDERSDATA);
+ strncpy(fd.szSection, section, FOLDERS_NAME_MAX_SIZE);
+ fd.szSection[FOLDERS_NAME_MAX_SIZE - 1] = '\0'; //make sure it's NULL terminated
+ strncpy(fd.szName, name, FOLDERS_NAME_MAX_SIZE);
+ fd.szName[FOLDERS_NAME_MAX_SIZE - 1] = '\0'; //make sure it's NULL terminated
+ fd.szFormatW = defaultPathW;
+ fd.flags = FF_UNICODE;
+ return (HANDLE) CallService(MS_FOLDERS_REGISTER_PATH, 0, (LPARAM) &fd);
+}
+
+__inline static int FoldersGetCustomPath(HANDLE hFolderEntry, AnsiChar *path, const int size, AnsiChar *notFound)
+{
+ FOLDERSGETDATA fgd = {0};
+ int res;
+ fgd.cbSize = sizeof(FOLDERSGETDATA);
+ fgd.nMaxPathSize = size;
+ fgd.szPath = path;
+ res = CallService(MS_FOLDERS_GET_PATH, (WPARAM) hFolderEntry, (LPARAM) &fgd);
+ if (res)
+ {
+ AnsiChar buffer[MAX_PATH];
+ CallService(MS_UTILS_PATHTOABSOLUTE, (WPARAM) notFound, (LPARAM) buffer);
+ mir_snprintf(path, size, "%s", buffer);
+ }
+
+ return res;
+}
+
+__inline static int FoldersGetCustomPathW(HANDLE hFolderEntry, wchar_t *pathW, const int count, wchar_t *notFoundW)
+{
+ FOLDERSGETDATA fgd = {0};
+ int res;
+ fgd.cbSize = sizeof(FOLDERSGETDATA);
+ fgd.nMaxPathSize = count;
+ fgd.szPathW = pathW;
+ res = CallService(MS_FOLDERS_GET_PATH, (WPARAM) hFolderEntry, (LPARAM) &fgd);
+ if (res)
+ {
+ wcsncpy(pathW, notFoundW, count);
+ pathW[count - 1] = '\0';
+ }
+
+ return res;
+}
+
+__inline static int FoldersGetCustomPathEx(HANDLE hFolderEntry, AnsiChar *path, const int size, AnsiChar *notFound, AnsiChar *fileName)
+{
+ FOLDERSGETDATA fgd = {0};
+ int res;
+ fgd.cbSize = sizeof(FOLDERSGETDATA);
+ fgd.nMaxPathSize = size;
+ fgd.szPath = path;
+ res = CallService(MS_FOLDERS_GET_PATH, (WPARAM) hFolderEntry, (LPARAM) &fgd);
+ if (res)
+ {
+ AnsiChar buffer[MAX_PATH];
+ CallService(MS_UTILS_PATHTOABSOLUTE, (WPARAM) notFound, (LPARAM) buffer);
+ mir_snprintf(path, size, "%s", buffer);
+ }
+ if (strlen(path) > 0)
+ {
+ strcat(path, "\\");
+ }
+ else{
+ path[0] = '\0';
+ }
+
+ if (fileName)
+ {
+ strcat(path, fileName);
+ }
+
+ return res;
+}
+
+__inline static int FoldersGetCustomPathExW(HANDLE hFolderEntry, wchar_t *pathW, const int count, wchar_t *notFoundW, wchar_t *fileNameW)
+{
+ FOLDERSGETDATA fgd = {0};
+ int res;
+ fgd.cbSize = sizeof(FOLDERSGETDATA);
+ fgd.nMaxPathSize = count;
+ fgd.szPathW = pathW;
+ res = CallService(MS_FOLDERS_GET_PATH, (WPARAM) hFolderEntry, (LPARAM) &fgd);
+ if (res)
+ {
+ wcsncpy(pathW, notFoundW, count);
+ pathW[count - 1] = '\0';
+ }
+
+ if (wcslen(pathW) > 0)
+ {
+ wcscat(pathW, L"\\");
+ }
+ else{
+ pathW[0] = L'\0';
+ }
+
+ if (fileNameW)
+ {
+ wcscat(pathW, fileNameW);
+ }
+
+ return res;
+}
+
+#endif
+*)
+{$ENDIF}
diff --git a/plugins/Pascal_Headers/reserve/helpers/m_magneticWindows.inc b/plugins/Pascal_Headers/reserve/helpers/m_magneticWindows.inc new file mode 100644 index 0000000000..885760f629 --- /dev/null +++ b/plugins/Pascal_Headers/reserve/helpers/m_magneticWindows.inc @@ -0,0 +1,72 @@ +{$IFNDEF M_MAGNETICWINDOWS}
+{$DEFINE M_MAGNETICWINDOWS}
+
+const
+// For other Plugins to start snapping for their windows
+// wparam: hwnd of window
+// lparam: 0
+// return: 0 on success, 1 on error
+ MS_MW_ADDWINDOW = 'Utils/MagneticWindows/Add';
+
+// For other Plugins to stop snapping for their windows
+// wparam: hwnd of window
+// lparam: 0
+// return: 0 on success, 1 on error
+ MS_MW_REMWINDOW = 'Utils/MagneticWindows/Rem';
+
+//decide where to align on the list:
+ MS_MW_STL_List_Left = $00000001; //Snaps the window to the left border of the list
+ MS_MW_STL_List_Top = $00000002; //Snaps the window to the top border of the list
+ MS_MW_STL_List_Right = $00000004; //Snaps the window to the right border of the list
+ MS_MW_STL_List_Bottom = $00000008; //Snaps the window to the bottom border of the list
+//decide with what side (of the window you want to snap) to snap to the list
+ MS_MW_STL_Wnd_Left = $00000010; //Snaps the window with the left border to the left/right side of the list
+ MS_MW_STL_Wnd_Top = $00000020; //Snaps the window with the top border to the top/bottom side of the list
+ MS_MW_STL_Wnd_Right = $00000040; //Snaps the window with the right border to the left/right side of the list
+ MS_MW_STL_Wnd_Bottom = $00000080; //Snaps the window with the bottom border to the top/bottom side of the list
+
+ MS_MW_STL_Wnd_FullWidth = (MS_MW_STL_Wnd_Left or MS_MW_STL_Wnd_Right);
+ //Snaps to the top/bottom of the list and spans over the full width
+
+ MS_MW_STL_Wnd_FullHeight = (MS_MW_STL_Wnd_Top or MS_MW_STL_Wnd_Bottom);
+ //Snaps to the left/right of the list and spans over the full height
+
+// to place the window in the list combine f.e.
+// MS_MW_STL_List_Left | MS_MW_STL_Wnd_Right | *vetical alignment*
+
+//For other Plugins to snap a window to the list for other Plugins
+// wparam: hwnd of window
+// lparam: combination of the above constants MS_MW_STL_*
+// return: 0 on success, 1 on error
+ MS_MW_SNAPTOLIST = 'Utils/MagneticWindows/SnapToList';
+
+// Helper functions
+{$IFNDEF MW_NO_HELPPER_FUNCTIONS}
+
+function MagneticWindows_AddWindow(hWnd:HWND):integer;
+begin
+ if ServiceExists(MS_MW_ADDWINDOW)<>0 then
+ result:=CallService(MS_MW_ADDWINDOW,hWnd,0);
+ else
+ result:=-1;
+end;
+
+function MagneticWindows_RemoveWindow(hWnd:HWND):integer;
+begin
+ if ServiceExists(MS_MW_REMWINDOW)<>0 then
+ result:=CallService(MS_MW_REMWINDOW,hWnd,0);
+ else
+ result:=-1;
+end;
+
+function MagneticWindows_SnapWindowToList(hWnd:HWND;MS_MW_STL_Options:integer):integer;
+begin
+ if (ServiceExists(MS_MW_SNAPTOLIST))
+ result:=CallService(MS_MW_SNAPTOLIST,hWnd,MS_MW_STL_Options);
+ else
+ result:=-1;
+end;
+
+{$ENDIF}
+
+{$ENDIF}
diff --git a/plugins/Pascal_Headers/reserve/helpers/m_notify.inc b/plugins/Pascal_Headers/reserve/helpers/m_notify.inc new file mode 100644 index 0000000000..572adc029e --- /dev/null +++ b/plugins/Pascal_Headers/reserve/helpers/m_notify.inc @@ -0,0 +1,266 @@ +{$IFNDEF M_NOTIFY}
+{$DEFINE M_NOTIFY}
+
+{** Miranda Notify Dispatcher ************************************************
+Notify Dispatcher provides common interface to different notification plugins
+like osd, popup, ticker etc.
+******************************************************************************}
+
+const
+{ Options UI event and service. The same as for miranda options }
+ ME_NOTIFY_OPT_INITIALISE = 'Notify/Opt/Initialise';
+ MS_NOTIFY_OPT_ADDPAGE = 'Notify/Opt/AddPage';
+
+type
+ tagMNOTIFYACTIONINFO = record
+ icon :HICON;
+ name :array [0..MAXMODULELABELLENGTH-1] of AnsiChar;
+ service:array [0..MAXMODULELABELLENGTH-1] of AnsiChar;
+ cookie :DWORD;
+ end;
+ MNOTIFYACTIONINFO = tagMNOTIFYACTIONINFO;
+
+// Just like miranda pluginLink... This should work faster then services,
+// we need some reactivity in notifications.
+type
+ tagMNNOTIFYLINK = record
+ // Create a new notification type
+ function Register(name:PAnsiChar;icon:HICON):THANDLE;cdecl;
+
+ // Create a new notification object
+ function Create(atype:THANDLE):THANDLE;cdecl;
+
+ // Check is handle is a valid notification object
+ function IsValid(notify:THANDLE):integer;cdecl;
+
+ // Set/get information about object, or type defaults
+ function Set(notifyORtype:THANDLE;name:PAnsiChar;val:TDBVARIANT):integer;cdecl;
+ function Get(notifyORtype:THANDLE;name:PAnsiChar;val:PDBVARIANT):integer;cdecl;
+
+ // Set/get actions
+ function AddAction (notifyORtype:THANDLE;icon:HICON;name:PAnsiChar;service:PAnsiChar;cookie:DWORD):integer;cdecl;
+ function GetActions(notifyORtype:THANDLE;actions:PMNOTIFYACTIONINFO):integer;cdecl;
+
+ // Increment/decrement refer count of notification object. Unreferred objects are destroyed
+ function AddRef (notify:THANDLE):integer;cdecl;
+ function Release(notify:THANDLE):integer;cdecl;
+
+ // Notify user
+ procedure Show (notify:THANDLE);cdecl;
+ procedure Update(notify:THANDLE);cdecl;
+ procedure Remove(notify:THANDLE);cdecl;
+ end;
+ PMNOTIFYLINK = ^TMNOTIFYLINK;
+ TMNOTIFYLINK = tagMNOTIFYLINK;
+
+const
+// Get the MNOTIFYLINK struct
+// result = (LRESULT)(MNOTIFYLINK* )notifyLink
+ MS_NOTIFY_GETLINK = 'Notify/GetLink';
+
+// Hook this to process corresponding actions
+ ME_NOTIFY_SHOW = 'Notify/Show';
+ ME_NOTIFY_UPDATE = 'Notify/Update';
+ ME_NOTIFY_REMOVE = 'Notify/Remove';
+
+var
+ notifyLink:PMNOTIFYLINK;
+(*
+function MNotifyRegister(name:PAnsiChar;icon:HICON):THANDLE;
+begin
+ if notifyLink<>nil then
+ result:=notifyLink^.Register(name,icon)
+ else
+ result:=0;
+end;
+function MNotifyCreate(atype:THANDLE):THANDLE;
+begin
+ if notifyLink<>nil then
+ result:=notifyLink^.Create(atype)
+ else
+ result:=0;
+end;
+function MNotifyIsValid(notify:THANDLE):int;
+begin
+ if notifyLink<>nil then
+ result:=notifyLink^.IsValid(notify)
+ else
+ result:=0;
+end;
+function MNotifySet(notifyORtype:THANDLE,name:PAnsiChar;val:TDBVARIANT):int;
+begin
+ if notifyLink<>nil then
+ result:=notifyLink^.Set(notifyORtype,name,val)
+ else
+ result:=0;
+end;
+function MNotifyGet(notifyORtype:THANDLE,name:PAnsiChar;val:PDBVARIANT):int;
+begin
+ if notifyLink<>nil then
+ result:=notifyLink^.Get(notifyORtype,name,val)
+ else
+ result:=0;
+end;
+function MNotifyAddAction(notifyORtype:THANDLE;icon:HICON;name:PAnsiChar;service:PAnsiChar=nil;cookie:DWORD=0):int;
+begin
+ if notifyLink<>nil then
+ result:=notifyLink^.AddAction(notifyORtype,icon,name)
+ else
+ result:=0;
+end;
+function MNotifyGetActions(notifyORtype:THANDLE;actions:PMNOTIFYACTIONINFO):int;
+begin
+ if notifyLink<>nil then
+ result:=notifyLink^.GetActions(notifyORtype,actions)
+ else
+ result:=0;
+end;
+function MNotifyAddRef(notify:THANDLE):int;
+begin
+ if notifyLink<>nil then
+ result:=notifyLink^.AddRef(notify)
+ else
+ result:=0;
+end;
+function MNotifyRelease(notify:THANDLE):int;
+begin
+ if notifyLink<>nil then
+ result:=notifyLink^.Release(notify)
+ else
+ result:=0;
+end;
+procedure MNotifyShow(notify:THANDLE);
+begin
+ if notifyLink<>nil then
+ notifyLink^.Show(notify)
+end;
+procedure MNotifyUpdate(notify:THANDLE);
+begin
+ if notifyLink<>nil then
+ notifyLink^.Update(notify)
+end;
+procedure MNotifyRemove(notify:THANDLE);
+begin
+ if notifyLink<>nil then
+ notifyLink^.Remove(notify)
+end;
+
+procedure MNotifyGetLink;
+begin
+ if PluginLink^.ServiceExists(MS_NOTIFY_GETLINK)<>0 then
+ notifyLink:=PMNOTIFYLINK(CallService(MS_NOTIFY_GETLINK,0,0))
+ else
+ notifyLink:=nil;
+end;
+
+// get helpers
+function MNotifyGetByte(notifyORtype:THANDLE;name:PAnsiChar;defValue:byte):byte;
+var
+ dbv:TDBVARIANT;
+begin
+ MNotifyGet(notifyORtype,name,dbv);
+ if dbv._type<>DBVT_BYTE then
+ result:=defValue
+ else
+ result:=dbv.bVal;
+end;
+function MNotifyGetWord(notifyORtype:THANDLE;name:PAnsiChar;defValue:word):word;
+var
+ dbv:TDBVARIANT;
+begin
+ MNotifyGet(notifyORtype,name,dbv);
+ if dbv._type<>DBVT_WORD then
+ result:=defValue
+ else
+ result:=dbv.wVal;
+end;
+function MNotifyGetDWord(notifyORtype:THANDLE;name:PAnsiChar;defValue:dword):dword;
+var
+ dbv:TDBVARIANT;
+begin
+ MNotifyGet(notifyORtype,name,dbv);
+ if dbv._type<>DBVT_DWORD then
+ result:=defValue
+ else
+ result:=dbv.dVal;
+end;
+function MNotifyGetString(notifyORtype:THANDLE;name:PAnsiChar;defValue:PAnsiChar):PAnsiChar;
+var
+ dbv:TDBVARIANT;
+begin
+ MNotifyGet(notifyORtype,name,dbv);
+ if dbv._type<>DBVT_ASCIIZ then
+ result:=defValue
+ else
+ result:=dbv.szVal.a;
+end;
+function MNotifyGetWString(notifyORtype:THANDLE;name:PAnsiChar;defValue:PWideChar):PWideChar;
+var
+ dbv:TDBVARIANT;
+begin
+ MNotifyGet(notifyORtype,name,dbv);
+ if dbv._type<>DBVT_WCHAR then
+ result:=defValue
+ else
+ result:=dbv.szVal.w;
+end;
+
+// set helpers
+procedure MNotifySetByte(notifyORtype:THANDLE;name:PAnsiChar;value:byte);
+var
+ dbv:TDBVARIANT;
+begin
+ dbv._type:=DBVT_BYTE;
+ dbv.bVal :=value;
+ MNotifySet(notifyORtype,name,dbv);
+end;
+procedure MNotifySetWord(notifyORtype:THANDLE;name:PAnsiChar;value:word);
+var
+ dbv:TDBVARIANT;
+begin
+ dbv._type:=DBVT_WORD;
+ dbv.wVal :=value;
+ MNotifySet(notifyORtype,name,dbv);
+end;
+procedure MNotifySetDWord(notifyORtype:THANDLE;name:PAnsiChar;value:dword);
+var
+ dbv:TDBVARIANT;
+begin
+ dbv._type:=DBVT_DWORD;
+ dbv.dVal :=value;
+ MNotifySet(notifyORtype,name,dbv);
+end;
+procedure MNotifySetString(notifyORtype:THANDLE;name:PAnsiChar;value:PAnsiChar);
+var
+ dbv:TDBVARIANT;
+begin
+ dbv._type :=DBVT_ASCIIZ;
+ dbv.szVal.a:=value;
+ MNotifySet(notifyORtype,name,dbv);
+end;
+procedure MNotifySetWString(notifyORtype:THANDLE;name:PAnsiChar;value:PWideChar);
+var
+ dbv:TDBVARIANT;
+begin
+ dbv._type :=DBVT_WCHAR;
+ dbv.szVal.w:=value;
+ MNotifySet(notifyORtype,name,dbv);
+end;
+*)
+
+const
+// Common options for Get/Set actions
+ NFOPT_TYPENAME = 'General/TypeName';
+ NFOPT_ICON = 'General/Icon';
+ NFOPT_CONTACT = 'General/Contact';
+ NFOPT_EVENT = 'General/Event';
+ NFOPT_TEXT = 'General/Text';
+ NFOPT_TEXTW = 'General/TextW';
+ NFOPT_TITLE = 'General/Title';
+ NFOPT_TITLEW = 'General/TitleW';
+ NFOPT_BACKCOLOR = 'General/BackColor';
+ NFOPT_TEXTCOLOR = 'General/TextColor';
+ NFOPT_TIMEOUT = 'General/Timeout';
+// NFOPT_ONDESTROY = 'General/OnDestroy';
+
+{$ENDIF}
diff --git a/plugins/Pascal_Headers/reserve/helpers/m_snapping_windows.inc b/plugins/Pascal_Headers/reserve/helpers/m_snapping_windows.inc new file mode 100644 index 0000000000..e3c513482a --- /dev/null +++ b/plugins/Pascal_Headers/reserve/helpers/m_snapping_windows.inc @@ -0,0 +1,35 @@ +{$IFNDEF SNAPPING_WINDOWS}
+{$DEFINE SNAPPING_WINDOWS}
+
+type
+ PSnapWindowProc = ^TSnapWindowProc;
+ TSnapWindowProc = record
+ hWnd : THWND;
+ m_szMoveOffset : TSIZE;
+ wParam : WPARAM;
+ lParam : LPARAM;
+ Reserved1 : int;
+ Reserved2 : int;
+ Reserved3 : int;
+ end;
+
+const
+ MS_SNAPWINDOWPROC = 'Utils/SnapWindowProc';
+
+function CallSnappingWindowProc(hwnd:hwnd; nMessage:int;
+ wParam:WPARAM;lParam:LPARAM):int;// cdecl;
+const
+ SnapInfo:TSnapWindowProc=();
+begin
+ result:=0;
+ if (nMessage=WM_MOVING) or (nMessage=WM_NCLBUTTONDOWN) or
+ (nMessage=WM_SYSCOMMAND) or (nMessage=WM_SIZING) then
+ begin
+ SnapInfo.hWnd := hwnd;
+ SnapInfo.wParam := wParam;
+ SnapInfo.lParam := lParam;
+ CallService(MS_SNAPWINDOWPROC,WPARAM(@SnapInfo),nMessage);
+ if nMessage=WM_SIZING then result:=1;
+ end;
+end;
+{$ENDIF}
diff --git a/plugins/Pascal_Headers/reserve/helpers/m_statusplugins.inc b/plugins/Pascal_Headers/reserve/helpers/m_statusplugins.inc new file mode 100644 index 0000000000..a638dd1f24 --- /dev/null +++ b/plugins/Pascal_Headers/reserve/helpers/m_statusplugins.inc @@ -0,0 +1,181 @@ +{
+ AdvancedAutoAway Plugin for Miranda-IM (www.miranda-im.org)
+ KeepStatus Plugin for Miranda-IM (www.miranda-im.org)
+ StartupStatus Plugin for Miranda-IM (www.miranda-im.org)
+ Copyright 2003-2006 P. Boon
+
+ 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+}
+{$IFNDEF M_STATUSPLUGINS}
+{$DEFINE M_STATUSPLUGINS}
+
+// -- common status -- (all three plugins)
+type
+ PROTOCOLSETTINGEX = record
+ cbSize :integer;
+ szName :PAnsiChar; // pointer to protocol modulename
+ szMsg :PAnsiChar; // pointer to the status message (may be NULL)
+ status :word; // the status
+ lastStatus:word; // last status
+ tszAccName:TChar;
+ end;
+
+const
+// wParam = PROTOCOLSETTINGEX*** (keep it like this for compatibility)
+// lParam = 0
+// returns 0 on success
+ MS_CS_SETSTATUSEX:PAnsiChar = 'CommonStatus/SetStatusEx';
+
+// wParam = PROTOCOLSETTINGEX*** (keep it like this for compatibility)
+// lParam = timeout
+// returns hwnd
+ MS_CS_SHOWCONFIRMDLGEX:PAnsiChar = 'CommonStatus/ShowConfirmDialogEx';
+
+// wParam = 0
+// lParam = 0
+// returns the number of protocols registerd
+ MS_CS_GETPROTOCOUNT:PAnsiChar = 'CommonStatus/GetProtocolCount'; // added dec '04
+
+// wParam = PROTOCOLSETTINGEX*** (keep it like this for compatibility)
+// lParam = 0
+ ME_CS_STATUSCHANGEEX:PAnsiChar = 'CommonStatus/StatusChangeEx';
+{
+// wParam = protoCount
+// lParam = 0
+ ME_CS_CSMODULELOADED:PAnsiChar = 'CommonStatus/CommonStatusLoaded';
+}
+// -- startup status --
+// wParam = profile number (set to -1 to get default profile)
+// lParam = PROTOCOLSETTINGEX*** (keep for... )(memory must be allocated protoCount*PROTOCOLSETTINGEX* and protoCount*PROTOCOLSETTINGEX)
+// szMsg member does not have to be freed
+// returns 0 on success
+ MS_SS_GETPROFILE:PAnsiChar = 'StartupStatus/GetProfile'; // don't use this > jan '05, internal use only
+
+// wParam = profile number
+// lParam = 0
+// return 0 on success
+ MS_SS_LOADANDSETPROFILE:PAnsiChar = 'StartupStatus/LoadAndSetProfile'; // you can use this
+
+// wParam = int*, maybe NULL sets this int to the default profile number
+// lParam = 0
+// returns profile count
+ MS_SS_GETPROFILECOUNT:PAnsiChar = 'StartupStatus/GetProfileCount';
+
+// wParam = profile number
+// lParam = AnsiChar* (must be allocated, size = 128)
+// returns 0 on success
+ MS_SS_GETPROFILENAME:PAnsiChar = 'StartupStatus/GetProfileName';
+
+// -- AdvancedAutoAway --
+type
+ STATES = [
+ ACTIVE, // user is active
+ STATUS1_SET, // first status change happened
+ STATUS2_SET, // second status change happened
+ SET_ORGSTATUS, // user was active again, original status will be restored
+
+ HIDDEN_ACTIVE, // user is active, but this is not shown to the outside world
+
+// STATUS1_SET2, // first status change happened, but user may be active ('on inactive only was disabled')
+// STATUS2_SET2 // second status change happened, but user may be active ('on inactive only was disabled')
+ ];
+
+type
+ AUTOAWAYSETTING = record
+ protocolSetting :^PROTOCOLSETTINGEX;
+ originalStatusMode:int; // this is set only when going from ACTIVE to
+ // STATUS1_SET (or to STATUS2_SET)
+ // (note: this is therefore not always valid)
+ oldState :STATES; // state before the call
+ curState :STATES; // current state
+ bstatusChanged :bool; // the status of the protocol will actually be changed
+ // (note: unlike the name suggests, the status is
+ // changed AFTER this hook is called)
+ bManual :bool; // state changed becuase status was changed manually
+ end;
+
+// wParam = 0;
+// lParam = AUTOAWAYSETTING*
+// Called when a protocol's state in AAA is changed this does NOT necessary means the status was changed
+// note: this hook is called for each protocol seperately
+const
+ ME_AAA_STATECHANGED:PAnsiChar = 'AdvancedAutoAway/StateChanged';
+{
+type
+ AAAOPTPAGE = record
+ cbSize :int;
+ pszText :PAnsiChar;
+ hInst :HINSTANCE;
+ pfnDlgProc :DLGPROC;
+ pszTemplate:PAnsiChar;
+ end;
+
+const
+// lParam=(LPARAM)(AAAOPTPAGE)&aop
+ MS_AAA_REGISTEROPTIONPAGE:PAnsiChar = 'AdvancedAutoAway/RegisterOptionPage';
+}
+// -- KeepStatus --
+ KS_CONN_STATE_LOST = 1; // lParam = protocol
+ KS_CONN_STATE_OTHERLOCATION = 2; // lParam = protocol
+ KS_CONN_STATE_RETRY = 3; // lParam = nth retry
+ KS_CONN_STATE_STOPPEDCHECKING = 4; // lParam = TRUE if success, FALSE if failed
+ KS_CONN_STATE_LOGINERROR = 5; // lParam = protocol, only if selected in options
+ KS_CONN_STATE_RETRYNOCONN = 6; // lParam = nth try, a connection attempt will not be made
+// wParam = one of above
+// lParam depends on wParam
+ ME_KS_CONNECTIONEVENT:PAnsiChar = 'KeepStatus/ConnectionEvent';
+
+// wParam = 0
+// lParam = 0
+// returns 0 on succes, nonzero on failure, probably keepstatus wasn't reconnecting
+ MS_KS_STOPRECONNECTING:PAnsiChar = 'KeepStatus/StopReconnecting';
+
+// wParam = TRUE to enable checking a protocol, FALSE to disable checking a protocol
+// lParam = protocol
+// return 0 on success, nonzero on failure, probably the protocol is 'hard' disabled or not found
+// note: you cannot enable a protocol that is disabled in the options screen, you can disable a protocol
+// if it's enabled in the option screen.
+ MS_KS_ENABLEPROTOCOL:PAnsiChar = 'KeepStatus/EnableProtocol';
+
+// wParam = 0
+// lParam = protocol
+// returns TRUE if protocol is enabled for checked, FALSE otherwise
+ MS_KS_ISPROTOCOLENABLED:PAnsiChar = 'KeepStatus/IsProtocolEnabled';
+
+// Indicate the status will be changed which will not be regarded as a connection failure.
+// wParam = 0
+// lParam = PROTOCOLSETTINGEX* of the new situation
+// returns 0
+ MS_KS_ANNOUNCESTATUSCHANGE:PAnsiChar = 'KeepStatus/AnnounceStatusChange';
+
+function announce_status_change(szProto:PAnsiChar;newstatus:integer;szMsg:PAnsiChar):integer;// cdecl;
+var
+ ps:PROTOCOLSETTINGEX;
+begin
+ FillChar(ps,SizeOf(PROTOCOLSETTINGEX),0);
+ ps.cbSize:=SizeOf(PROTOCOLSETTINGEX);
+ if szProto<>NIL then
+ ps.lastStatus:=CallProtoService(szProto, PS_GETSTATUS, 0, 0);
+ else
+ ps.lastStatus:=CallService(MS_CLIST_GETSTATUSMODE, 0, 0);
+
+ ps.status:=newstatus;
+ ps.szMsg :=szMsg;
+ ps.szName:=szProto;
+
+ result:=CallService(MS_KS_ANNOUNCESTATUSCHANGE, 0,dword(@ps));
+end;
+
+{$ENDIF}
diff --git a/plugins/Pascal_Headers/reserve/helpers/m_trigger.inc b/plugins/Pascal_Headers/reserve/helpers/m_trigger.inc new file mode 100644 index 0000000000..7f40d161e2 --- /dev/null +++ b/plugins/Pascal_Headers/reserve/helpers/m_trigger.inc @@ -0,0 +1,986 @@ +{$IFNDEF M_TRIGGER}
+{$DEFINE M_TRIGGER}
+
+// --------------------------------------------------------------------------
+// Triggers
+// --------------------------------------------------------------------------
+
+// This section explains how to create your own trigger. A trigger can be seen
+// as an event which can result in a set of actions that will be performed.
+// Implementing a trigger consists of two parts. First, you register a trigger
+// with MS_TRIGGER_REGISTERTRIGGER to allow a user to configure it in the
+// options dialog. Second, when the event occurs belonging to your registered
+// trigger, you inform the trigger plugin with MS_TRIGGER_REPORTEVENT. You can
+// send a 'payload' together with this notification. This payload, called
+// 'TriggerData', can consist of a certain contact, protocol, status and/or a
+// piece of text.
+
+// --------------------------------------------------------------------------
+// Triggers: Register a trigger
+// --------------------------------------------------------------------------
+const
+ MS_TRIGGER_REGISTERTRIGGER = '/TriggerPlugin/RegisterTrigger';
+
+// Parameters:
+// ------------------------
+// wParam = (WPARAM)0
+// lParam = (LPARAM)(TRIGGERREGISTER *)&tr
+// Pointer to a structure describing the trigger to add (see below).
+
+// Return Value:
+// ------------------------
+// Returns 0 on success, nozero otherwise. Registering an already existing
+// trigger will replace this previously registered trigger.
+
+type
+ TTRIGGERREGISTER = record
+ cbSize :int; // Set to sizeof(TRIGGERREGISTER).
+ pszName :PAnsiChar; // Used as identifier and shown in the options dialog,
+ // must be unique.
+ hInstance :HINSTANCE; // Only needed when options screen is available.
+ pfnDlgProc :DLGPROC; // Optional, the callback procedure for the options page.
+ pszTemplate:PAnsiChar; // Optional, template for the options page; must be
+ // WS_CHILD.
+ flags :int; // Flags, see below.
+ dFlags :int; // Specify the default DF_* flags which your trigger can
+ // send (see below).
+ end;
+
+const
+// Flags
+ TRF_NOEXPORT = 01; // This trigger cannot be exported. Set this flag
+ // in case you stored settings not using the helper
+ // functions at the end of this header. On export,
+ // TriggerPlugin will search for these settings
+ // and export them automatically. Contact-specific
+ // settings are never exported.
+
+// Please specify the dFlags to indicate what kind of data your trigger is
+// able to send as TriggerData. Please specify the maximum set, if your trigger
+// does not always send a certain data, please specify it anyway.
+
+ DF_CONTACT = $01; // The trigger might send a contact handle with the
+ // TriggerData.
+ DF_PROTO = $02; // The trigger might send a protocol ID with the
+ // TriggerData.
+ DF_STATUS = $04; // The trigger might send a status code with the
+ // TriggerData.
+ DF_TEXT = $08; // The trigger might send a string with the
+ // TriggerData.
+ DF_LPARAM = $10; // The trigger might send a custom parameter with the
+ // TriggerData.
+ DF_UNICODE = $20; // The trigger processes WCHAR strings.
+
+// Dialog Messages
+// The following message should be processed by your options dialog procedure,
+// if available. You can create an options dialog to give the user the
+// possibility to report your event only under certain circumstances. Each
+// trigger is assigned a certain ID. This ID can be used to store the settings
+// for your trigger.
+
+// WM_INITDIALOG
+
+// Parameters:
+// ------------------------
+// lParam = (LPARAM)(DWORD)triggerID
+// The trigger ID for which the options are to be set. This can be a new ID
+// or an ID of a trigger which is being edited. Initialize your options
+// dialog accordingly. There are helper function at the end of this header
+// file to read your settings for a certain trigger ID.
+
+ TM_ADDTRIGGER = WM_APP+10;
+
+// TM_ADDTRIGGER
+// 'OK' is pressed and a new trigger will be added. Save your settings using
+// the given trigger ID.
+
+// Parameters:
+// ------------------------
+// wParam = (WPARAM)(DWORD)triggerID
+// The trigger ID for which the settings are to be stored. There are helper
+// function at the end of this header file to store your settings with a
+// certain trigger ID.
+// lParam = 0
+
+ TM_DELTRIGGER = WM_APP+11;
+
+// TM_DELTRIGGER
+// The trigger addociated with the given trigger ID will be removed.
+
+// Parameters:
+// ------------------------
+// wParam = (WPARAM)(DWORD)triggerID
+// The trigger ID for which the settings are to be removed. There is a
+// helper service at the end of this header file to easily cleanup settings
+// for a certain trigger ID.
+// lParam = 0
+
+// --------------------------------------------------------------------------
+// Triggers: Report the Event
+// --------------------------------------------------------------------------
+
+// When the event occurs, you report it with MS_TRIGGER_REPORTEVENT. If your
+// trigger is configurable, so it has an options screen, you might want to
+// report your trigger for certain trigger ID's only. Please use the
+// MS_TRIGGER_FINDNEXTTRIGGERID to enumerate over the trigger ID's associated
+// with your trigger in the correct order as specified by the user. It's up
+// to you to found out whether or not the trigger is to be reported for a
+// certain ID.
+
+ MS_TRIGGER_FINDNEXTTRIGGERID = '/TriggerPlugin/FindNextTriggerID';
+
+// Enumerate over the associated trigger ID's for your trigger in the correct
+// order.
+
+// Parameters:
+// ------------------------
+// wParam = (WPARAM)(DWORD)triggerID
+// 0 to retrieve the first trigger ID for your trigger or the previous ID
+// returned by this service to get the next one.
+// lParam = 0
+
+// Return Value:
+// ------------------------
+// Returns the next trigger ID given the parameter or 0 if no more trigger IDs
+// are available.
+
+ MS_TRIGGER_REPORTEVENT = '/TriggerPlugin/ReportEvent';
+
+// Report your event for further processing. This can be a general event for
+// which no individual settings exist, or a specific event for a given
+// trigger ID.
+
+// Parameters:
+// ------------------------
+// wParam = 0
+// lParam = (LPARAM)(REPORTINFO *)&ri
+// See below.
+
+// Return Value:
+// ------------------------
+// Returns CRV_TRUE if all conditions specific to this trigger hold and the
+// chain was executed. Returns CRV_FALSE if these conditions did not hold and
+// the chain were not processed.
+
+// The structure below can be used to send TriggerData with your trigger. This
+// can be used by the associated conditions and actions.
+
+type
+ PTRIGGERDATA = ^TTRIGGERDATA;
+ TTRIGGERDATA = record
+ cbSize :int; // Set to sizeof(TRIGGERDATA)
+ dFlags :int; // Indicate which members are valid using the DF_* flags
+ hContact:THANDLE; // Associate a contact handle to this event.
+ szProto :PAnsiChar; // Associate a protocol ID to this event.
+ status :int; // Associcate a status code to this event.
+ szText :TChar; // Associate a string to this event.
+ lParam :LPARAM; // Associate custom data to this trigger.
+ end;
+
+type
+ PREPORTINFO = ^TREPORTINFO;
+ TREPORTINFO = record
+ cbSize :int; // Set to sizeof(REPORTINFO).
+ triggerID:DWORD; // The trigger ID of the event to trigger or 0 if
+ // this does not apply.
+ pszName :PAnsiChar; // The name of the trigger (this may be NULL if
+ // triggerID is not 0).
+ flags :int; // On of the TRG_* flags, see below.
+ td :PTRIGGERDATA; // Optional, the associated TriggerData, see above.
+ end;
+
+const
+ TRG_PERFORM = $01; // Indicates the event for this trigger actually
+ // occured and needs to be processed accordingly.
+ TRG_CLEANUP = $02; // Indicates the trigger instructs to remove the
+ // itself and all associated information. This can
+ // be used for "one time triggers". Remove your own
+ // settings by yourself.
+
+// --------------------------------------------------------------------------
+// Actions
+// --------------------------------------------------------------------------
+
+// An actions might be performed as a reaction to a reported event by a
+// trigger. You first register your action so it can be associated to a
+// trigger in the options screen. Next, your provided service or function
+// will be called when necessary.
+
+ MS_TRIGGER_REGISTERACTION = '/TriggerPlugin/RegisterAction';
+
+// Parameters:
+// ------------------------
+// wParam = (WPARAM)0
+// lParam = (LPARAM)(ACTIONREGISTER *)&ar
+// Pointer to a structure describing the action to add (see below).
+
+// Return Value:
+// ------------------------
+// Returns 0 on success, nozero otherwise. Registering an already existing
+// action will replace this previously registered action.
+
+type
+ TACTIONREGISTER = record
+ cbSize :int; // Set to sizeof(ACTIONREGISTER).
+ pszName :PAnsiChar; // The name of this action, it must be a unique string.
+ pszService :PAnsiChar; // A service (called with wParam =
+ // (WPARAM)(DWORD)actionID, lParam =
+ // (LPARAM)(REPORTINFO *)&ri) or function to be called
+ // when the action has to be performed.
+// or actionFunction: function (actionID:dword; ri:PREPORTINFO):int;
+ hInstance :HINSTANCE;// Only needed when an options screen is available.
+ pfnDlgProc :DLGPROC; // Optional, the callback procedure for the options
+ // dialog.
+ pszTemplate:PAnsiChar; // Optional, template for the options dialog, must be
+ // WS_CHILD.
+ flags :int; // One of the ARF_* flags, see below.
+ end;
+
+const
+ ARF_UNICODE = $01; // This action processes unicode strings.
+ ARF_FUNCTION = $02; // The actionFunction will be called instead of the service.
+ ARF_NOEXPORT = $04; // This action cannot be exported. Set this flag in
+ // case you stored settings not using the helper
+ // functions at the end of this header. On export,
+ // TriggerPlugin will search for these settings
+ // and export them automatically. Contact-specific
+ // settings are never exported.
+
+// The service or actionFunction will be called with a pointer to a REPORTINFO
+// struct, containing information about the trigger event. If you can use
+// TriggerData from this struct, always check the ri->td->dFlags before using
+// it. It's up to you to deal with an action in case the expected TriggerData
+// is not available. It's recommened though, to cancel your action. The
+// ri->flags is a combination of the ACT_* flags, indicating how to process the
+// call, see below.
+
+ ACT_PERFORM = $01; // Your action is to be performed.
+ ACT_CLEANUP = $02; // The settings associated to this action should be removed.
+
+// Dialog Messages
+// The following messages are to be processed by the options dialog, if there
+// is one.
+
+// WM_INITDIALOG
+
+// Parameters:
+// ------------------------
+// lParam = (LPARAM)(DWORD)actionID
+// The action ID for which the options are to be set. This can be a new ID
+// or an ID of an action which is being edited. Initialize your options
+// dialog accordingly. There are helper function at the end of this header
+// file to read your settings for a certain action ID.
+
+ TM_ADDACTION = WM_APP+12;
+
+// TM_ADDACTION
+// 'OK' is pressed and a new action will be added. Save your settings using
+// the given action ID. Helper functions can be found at the end of this
+// header file.
+
+// Parameters:
+// ------------------------
+// wParam = (WPARAM)(DWORD)actionID
+// The action ID for which the settings are to be saved. There are helper
+// functions at the end of this header file to store settings with a certain
+// action ID.
+// lParam = 0
+
+// Dialog Messages
+// You can send the following messages to the parent window of your dialog.
+// When initalizing your dialog, you might be interested in the TriggerData
+// the associated trigger is able to provide, you can do so by sending the
+// folowing message to the parent of your dialog.
+
+ TM_GETTRIGGERINFO = WM_APP+13;
+
+// Parameters:
+// ------------------------
+// wParam = 0
+// lParam = (LPARAM)(TRIGGERINFO *)&ti
+
+// Return Value:
+// ------------------------
+// Returns 0 on success, the struct given will be filled with the requested
+// information. Returns any other value on error.
+
+type
+ PTRIGGERINFO = ^TTRIGGERINFO;
+ TTRIGGERINFO = record
+ cbSize:int; // (in) Set to sizeof(TRIGGERINFO).
+ dFlags:int; // (out) The default DF_* flags used by the trigger (as indicated
+ // by its TRIGGERREGISTER).
+ end;
+
+// --------------------------------------------------------------------------
+// Conditions
+// --------------------------------------------------------------------------
+
+// Depending on the configuration of the user, a condition may need to hold
+// for an action to be performed. A condition function is called and its
+// return value specifies whether or not the condition holds. A condition
+// needs to be registered. After its registered, the condition function might
+// be called to check whether or not the condition holds.
+const
+ MS_TRIGGER_REGISTERCONDITION = '/TriggerPlugin/RegisterCondition';
+
+// Parameters:
+// ------------------------
+// wParam = (WPARAM)0
+// lParam = (LPARAM)(CONDITIONREGISTER *)&cr
+// Pointer to a structure describing the condition to add (see below).
+
+// Return Value:
+// ------------------------
+// Returns 0 on success, nozero otherwise. Registering an already existing
+// condition will replace this previously registered condition.
+
+type
+ PCONDITIONREGISTER = ^TCONDITIONREGISTER;
+ TCONDITIONREGISTER = record
+ cbSize :int; // Set to sizeof(CONDITIONREGISTER).
+ pszName :PAnsiChar; // The name identifying this condition, must be unique.
+ pszService :PAnsiChar; // The service (wParam = (WPARAM)(DWORD)conditionID,
+ // lParam = (LPARAM)(REPORTINFO *)&ri) or function which
+ // is called to see whether the condition holds. Must
+ // return CRV_TRUE if the condition holds, CRV_FALSE
+ // otherwise.
+// or conditionFunction:function(conditionID:dword; ri:PREPORTINFO):int;
+ hInstance :HINSTANCE; // Only needed when an options dialog is available.
+ pfnDlgProc :DLGPROC; // Optional, the dialog procedure for the options
+ // dialog.
+ pszTemplate:PAnsiChar; // Optional, template for the options dialog, must be
+ // WS_CHILD.
+ flags :int; // CRF_* flags, see below.
+ end;
+
+// The flags that can be used to register the condition.
+
+const
+ CRF_UNICODE = $01; // The condition function or service processes
+ // unicode strings.
+ CRF_FUNCTION = $02; // The conditionFunction will be called instead of
+ // the service.
+ CRF_NOEXPORT = $04; // This condition cannot be exported. Set this flag
+ // in case you stored settings not using the helper
+ // functions at the end of this header. On export,
+ // TriggerPlugin will search for these settings
+ // and export them automatically. Contact-specific
+ // settings are never exported.
+
+// The service or conditionFunction will be called with a pointer to a
+// REPORTINFO struct, containing information about the trigger event. If you
+// can use TriggerData from this struct, always check the ri->td->dFlags before
+// using it. It's up to you to deal with an condition in case the expected
+// TriggerData is not available. It's recommened though, to return CRV_FALSE in
+// those cases. The ri->flags is a combination of the CND_* flags, indicating
+// how to process the call, see below.
+
+// Return values for the condition function or service. The condition service
+// or function is expected to return one of the following.
+
+ CRV_FALSE = 0; // The condition does not hold.
+ CRV_TRUE = 1; // The condition does hold.
+
+// REPORTINFO flags, received by the condition function or service. These
+// indicate how to process the call.
+
+ CND_PERFORM = 01; // Perform your condition and return either
+ // CRV_TRUE or CRV_FALSE to indicate whether or not
+ // your condition holds at this moment.
+ CND_CLEANUP = 02; // The condition is deleted. Remove your settings
+ // from the DB. There is a helper service below to
+ // easily remove settings given a condition ID.
+
+// Dialog Messages
+// The following messages are to be processed by the options dialog, if there
+// is one.
+
+// WM_INITDIALOG
+
+// Parameters:
+// ------------------------
+// lParam = (LPARAM)(DWORD)conditionID
+// The condition ID for which the options are to be set. This can be a new ID
+// or an ID of a condition which is being edited. Initialize your options
+// dialog accordingly. There are helper function at the end of this header
+// file to read your settings for a certain condition ID.
+
+ TM_ADDCONDITION = WM_APP+14;
+
+// TM_ADDCONDITION
+// 'OK' is pressed and a new condition will be added. Save your settings using
+// the given condition ID. Helper functions can be found at the end of this
+// header file.
+
+// Parameters:
+// ------------------------
+// wParam = (WPARAM)(DWORD)conditionID
+// The condition ID for which the settings are to be saved. There are helper
+// functions at the end of this header file to store settings with a certain
+// condition ID.
+// lParam = 0
+
+// When initalizing your dialog, you might be interested in the TriggerData the
+// associated trigger is able to provide, you can find out by sending a
+// TM_GETTRIGGERINFO message to the parent of your dialog. See the section on
+// dialog messages for actions for more information (above).
+
+// --------------------------------------------------------------------------
+// Misc. Services
+// --------------------------------------------------------------------------
+
+ MS_TRIGGER_ENABLETRIGGER = '/TriggerPlugin/EnableTrigger';
+
+// Parameters:
+// ------------------------
+// wParam = (WPARAM)(DWORD)triggerID
+// The triggerID to set or get the state from or 0 for the global state.
+// lParam = (LPARAM)(int)type
+// One of ETT_* (see below).
+// Pointer to a structure describing the settings to remove (see below).
+
+// Return Value:
+// ------------------------
+// Returns the state (0=disabled) if ETT_GETSTATE is given as lParam.
+// Otherwise, it returns 0 if setting the state was succesful or any other on
+// failure. The global state must be enabled if a single state is to be
+// changed.
+
+ ETT_DISABLE = 0; // Disable the trigger(s).
+ ETT_ENABLE = 1; // Enable the trigger(s).
+ ETT_TOGGLE = 2; // Toggle the state of the trigger(s).
+ ETT_GETSTATE = 3; // Retrieve the state of the trigger (0=disabled).
+
+// --------------------------------------------------------------------------
+// Database Helper Services
+// --------------------------------------------------------------------------
+
+// The rest of this header file defines helper services and functions to easily
+// store and retrieve settings for a certain trigger, action or condition.
+
+ MS_TRIGGER_REMOVESETTINGS = '/TriggerPlugin/RemoveSettings';
+
+// Parameters:
+// ------------------------
+// wParam = (WPARAM)0
+// lParam = (LPARAM)(REMOVETRIGGERSETTINGS *)&rts
+// Pointer to a structure describing the settings to remove (see below).
+
+// Return Value:
+// ------------------------
+// Returns the number of settings removed from the database.
+
+// This service helps you remove all settings you have written with the DB
+// helper functions, defined at the end of this header file.
+
+type
+ PREMOVETRIGGERSETTINGS = ^TREMOVETRIGGERSETTINGS;
+ TREMOVETRIGGERSETTINGS = record
+ cbSize :int; // Set to sizeof(REMOVETRIGGERSETTINGS).
+ prefix :PAnsiChar; // A string indicating what kind of setting are to be
+ // removed, see below.
+ id :DWORD; // The ID of the set of settings to be removed.
+ szModule:PAnsiChar; // The module where the settings are stored.
+ hContact:THANDLE; // The contact for which the setting are to be removed. Can
+ // be INVALID_HANDLE_VALUE to remove the settings for all
+ // contacts and NULL.
+ end;
+
+// The following prefixes indicate what kind of settings are to be removed from
+// the database.
+const
+ PREFIX_ACTIONID = 'aid'; // The prefix for a DB setting associated to
+ // an action.
+ PREFIX_TRIGGERID = 'tid'; // The prefix for a DB setting associated to
+ // a trigger.
+ PREFIX_CONDITIONID = 'cid'; // The prefix for a DB setting associated
+ // to a condition.
+
+(* TRIGGER HELPER
+
+// Helper #1: RemoveAllTriggerSettings
+// ------------------------
+// Remove all settings from the DB given the triggerID and module.
+
+static __inline int RemoveAllTriggerSettings(DWORD triggerID, AnsiChar *szModule) {
+
+ REMOVETRIGGERSETTINGS rts;
+
+ rts.cbSize = sizeof(REMOVETRIGGERSETTINGS);
+ rts.prefix = PREFIX_TRIGGERID;
+ rts.id = triggerID;
+ rts.szModule = szModule;
+ rts.hContact = INVALID_HANDLE_VALUE;
+
+ return CallService(MS_TRIGGER_REMOVESETTINGS, 0, (LPARAM)&rts);
+}
+
+// Helper #2: RemoveAllActionSettings
+// ------------------------
+// Remove all settings from the DB given the actionID and module.
+
+static __inline int RemoveAllActionSettings(DWORD actionID, AnsiChar *szModule) {
+
+ REMOVETRIGGERSETTINGS rts;
+
+ rts.cbSize = sizeof(REMOVETRIGGERSETTINGS);
+ rts.prefix = PREFIX_ACTIONID;
+ rts.id = actionID;
+ rts.szModule = szModule;
+ rts.hContact = INVALID_HANDLE_VALUE;
+
+ return CallService(MS_TRIGGER_REMOVESETTINGS, 0, (LPARAM)&rts);
+}
+
+// Helper #1: RemoveAllConditionSettings
+// ------------------------
+// Remove all settings from the DB given the conditionID and module.
+
+static __inline int RemoveAllConditionSettings(DWORD conditionID, AnsiChar *szModule) {
+
+ REMOVETRIGGERSETTINGS rts;
+
+ rts.cbSize = sizeof(REMOVETRIGGERSETTINGS);
+ rts.prefix = PREFIX_CONDITIONID;
+ rts.id = conditionID;
+ rts.szModule = szModule;
+ rts.hContact = INVALID_HANDLE_VALUE;
+
+ return CallService(MS_TRIGGER_REMOVESETTINGS, 0, (LPARAM)&rts);
+}
+
+// --------------------------------------------------------------------------
+// Database Helper Functions
+// --------------------------------------------------------------------------
+
+// Basically, these function work the same as Miranda's helper functions for
+// getting/setting DB settings. There is one extra parameter, the ID for the
+// trigger/action/condition. The settings are named as follows:
+
+// DBWriteTriggerSetting*(DWORD triggerID, ...) to write a setting given a
+// trigger ID.
+// DBGetTriggerSetting*(DWORD triggerID, ...) to read a setting given a
+// trigger ID.
+// DBWriteActionSetting*(DWORD actionID, ...) to write a setting given an
+// action ID.
+// DBGetActionSetting*(DWORD actionID, ...) to read a setting given an
+// action ID.
+// DBWriteConditionSetting*(DWORD conditionID, ...) to write a setting given a
+// condition ID.
+// DBGetConditionSetting*(DWORD conditionID, ...) to read a setting given a
+// condition ID.
+
+#define MAX_SETTING_LEN 255 // Max. length of a DB setting including the
+ // prefix and ID.
+
+// --------------------------------------------------------------------------
+// Database Helper Functions: Triggers
+// --------------------------------------------------------------------------
+
+static int __inline DBWriteTriggerSettingByte(DWORD triggerID, HANDLE hContact,const AnsiChar *szModule,const AnsiChar *szSetting,BYTE val) {
+
+ AnsiChar dbSetting[MAX_SETTING_LEN];
+
+ mir_snprintf(dbSetting, sizeof(dbSetting), "%s%u_%s", PREFIX_TRIGGERID, triggerID, szSetting);
+ return DBWriteContactSettingByte(hContact, szModule, dbSetting, val);
+}
+
+static int __inline DBWriteTriggerSettingWord(DWORD triggerID, HANDLE hContact,const AnsiChar *szModule,const AnsiChar *szSetting,WORD val) {
+
+ AnsiChar dbSetting[MAX_SETTING_LEN];
+
+ mir_snprintf(dbSetting, sizeof(dbSetting), "%s%u_%s", PREFIX_TRIGGERID, triggerID, szSetting);
+ return DBWriteContactSettingWord(hContact, szModule, dbSetting, val);
+}
+
+static int __inline DBWriteTriggerSettingDword(DWORD triggerID, HANDLE hContact,const AnsiChar *szModule,const AnsiChar *szSetting,DWORD val) {
+
+ AnsiChar dbSetting[MAX_SETTING_LEN];
+
+ mir_snprintf(dbSetting, sizeof(dbSetting), "%s%u_%s", PREFIX_TRIGGERID, triggerID, szSetting);
+ return DBWriteContactSettingDword(hContact, szModule, dbSetting, val);
+}
+
+static int __inline DBWriteTriggerSettingString(DWORD triggerID, HANDLE hContact,const AnsiChar *szModule,const AnsiChar *szSetting,const AnsiChar *val) {
+
+ AnsiChar dbSetting[MAX_SETTING_LEN];
+
+ mir_snprintf(dbSetting, sizeof(dbSetting), "%s%u_%s", PREFIX_TRIGGERID, triggerID, szSetting);
+ return DBWriteContactSettingString(hContact, szModule, dbSetting, val);
+}
+
+static int __inline DBWriteTriggerSettingTString(DWORD triggerID, HANDLE hContact,const AnsiChar *szModule,const AnsiChar *szSetting,const TCHAR *val) {
+
+ AnsiChar dbSetting[MAX_SETTING_LEN];
+
+ mir_snprintf(dbSetting, sizeof(dbSetting), "%s%u_%s", PREFIX_TRIGGERID, triggerID, szSetting);
+ return DBWriteContactSettingTString(hContact, szModule, dbSetting, val);
+}
+
+static int __inline DBWriteTriggerSettingWString(DWORD triggerID, HANDLE hContact,const AnsiChar *szModule,const AnsiChar *szSetting,const WCHAR *val) {
+
+ AnsiChar dbSetting[MAX_SETTING_LEN];
+
+ mir_snprintf(dbSetting, sizeof(dbSetting), "%s%u_%s", PREFIX_TRIGGERID, triggerID, szSetting);
+ return DBWriteContactSettingWString(hContact, szModule, dbSetting, val);
+}
+
+static int __inline DBWriteTriggerSettingStringUtf(DWORD triggerID, HANDLE hContact,const AnsiChar *szModule,const AnsiChar *szSetting,const AnsiChar *val) {
+
+ AnsiChar dbSetting[MAX_SETTING_LEN];
+
+ mir_snprintf(dbSetting, sizeof(dbSetting), "%s%u_%s", PREFIX_TRIGGERID, triggerID, szSetting);
+ return DBWriteContactSettingStringUtf(hContact, szModule, dbSetting, val);
+}
+
+static int __inline DBGetTriggerSettingByte(DWORD triggerID, HANDLE hContact, const AnsiChar *szModule, const AnsiChar *szSetting, int errorValue) {
+
+
+ AnsiChar dbSetting[MAX_SETTING_LEN];
+
+ mir_snprintf(dbSetting, sizeof(dbSetting), "%s%u_%s", PREFIX_TRIGGERID, triggerID, szSetting);
+ return DBGetContactSettingByte(hContact, szModule, dbSetting, errorValue);
+}
+
+static WORD __inline DBGetTriggerSettingWord(DWORD triggerID, HANDLE hContact, const AnsiChar *szModule, const AnsiChar *szSetting, int errorValue) {
+
+
+ AnsiChar dbSetting[MAX_SETTING_LEN];
+
+ mir_snprintf(dbSetting, sizeof(dbSetting), "%s%u_%s", PREFIX_TRIGGERID, triggerID, szSetting);
+ return DBGetContactSettingWord(hContact, szModule, dbSetting, errorValue);
+}
+
+static DWORD __inline DBGetTriggerSettingDword(DWORD triggerID, HANDLE hContact, const AnsiChar *szModule, const AnsiChar *szSetting, int errorValue) {
+
+
+ AnsiChar dbSetting[MAX_SETTING_LEN];
+
+ mir_snprintf(dbSetting, sizeof(dbSetting), "%s%u_%s", PREFIX_TRIGGERID, triggerID, szSetting);
+ return DBGetContactSettingDword(hContact, szModule, dbSetting, errorValue);
+}
+
+static int __inline DBGetTriggerSetting(DWORD triggerID, HANDLE hContact, const AnsiChar *szModule, const AnsiChar *szSetting, DBVARIANT *dbv) {
+
+
+ AnsiChar dbSetting[MAX_SETTING_LEN];
+
+ mir_snprintf(dbSetting, sizeof(dbSetting), "%s%u_%s", PREFIX_TRIGGERID, triggerID, szSetting);
+ return DBGetContactSetting(hContact, szModule, dbSetting, dbv);
+}
+
+static int __inline DBGetTriggerSettingW(DWORD triggerID, HANDLE hContact,const AnsiChar *szModule, const AnsiChar *szSetting,DBVARIANT *dbv) {
+
+ AnsiChar dbSetting[MAX_SETTING_LEN];
+
+ mir_snprintf(dbSetting, sizeof(dbSetting), "%s%u_%s", PREFIX_TRIGGERID, triggerID, szSetting);
+ return DBGetContactSettingW(hContact, szModule, dbSetting, dbv);
+}
+
+static int __inline DBGetTriggerSettingTString(DWORD triggerID, HANDLE hContact,const AnsiChar *szModule, const AnsiChar *szSetting,DBVARIANT *dbv) {
+
+ AnsiChar dbSetting[MAX_SETTING_LEN];
+
+ mir_snprintf(dbSetting, sizeof(dbSetting), "%s%u_%s", PREFIX_TRIGGERID, triggerID, szSetting);
+ return DBGetContactSettingTString(hContact, szModule, dbSetting, dbv);
+}
+
+static int __inline DBGetTriggerSettingWString(DWORD triggerID, HANDLE hContact,const AnsiChar *szModule, const AnsiChar *szSetting,DBVARIANT *dbv) {
+
+ AnsiChar dbSetting[MAX_SETTING_LEN];
+
+ mir_snprintf(dbSetting, sizeof(dbSetting), "%s%u_%s", PREFIX_TRIGGERID, triggerID, szSetting);
+ return DBGetContactSettingWString(hContact, szModule, dbSetting, dbv);
+}
+
+static int __inline DBGetTriggerSettingStringUtf(DWORD triggerID, HANDLE hContact,const AnsiChar *szModule, const AnsiChar *szSetting,DBVARIANT *dbv) {
+
+ AnsiChar dbSetting[MAX_SETTING_LEN];
+
+ mir_snprintf(dbSetting, sizeof(dbSetting), "%s%u_%s", PREFIX_TRIGGERID, triggerID, szSetting);
+ return DBGetContactSettingStringUtf(hContact, szModule, dbSetting, dbv);
+}
+
+static int __inline DBDeleteTriggerSetting(DWORD triggerID, HANDLE hContact,const AnsiChar *szModule,const AnsiChar *szSetting) {
+
+ AnsiChar dbSetting[MAX_SETTING_LEN];
+
+ mir_snprintf(dbSetting, sizeof(dbSetting), "%s%u_%s", PREFIX_TRIGGERID, triggerID, szSetting);
+ return DBDeleteContactSetting(hContact, szModule, dbSetting);
+}
+
+// --------------------------------------------------------------------------
+// Database Helper Functions: Actions
+// --------------------------------------------------------------------------
+
+static int __inline DBWriteActionSettingByte(DWORD actionID, HANDLE hContact,const AnsiChar *szModule,const AnsiChar *szSetting,BYTE val) {
+
+ AnsiChar dbSetting[MAX_SETTING_LEN];
+
+ mir_snprintf(dbSetting, sizeof(dbSetting), "%s%u_%s", PREFIX_ACTIONID, actionID, szSetting);
+ return DBWriteContactSettingByte(hContact, szModule, dbSetting, val);
+}
+
+static int __inline DBWriteActionSettingWord(DWORD actionID, HANDLE hContact,const AnsiChar *szModule,const AnsiChar *szSetting,WORD val) {
+
+ AnsiChar dbSetting[MAX_SETTING_LEN];
+
+ mir_snprintf(dbSetting, sizeof(dbSetting), "%s%u_%s", PREFIX_ACTIONID, actionID, szSetting);
+ return DBWriteContactSettingWord(hContact, szModule, dbSetting, val);
+}
+
+static int __inline DBWriteActionSettingDword(DWORD actionID, HANDLE hContact,const AnsiChar *szModule,const AnsiChar *szSetting,DWORD val) {
+
+ AnsiChar dbSetting[MAX_SETTING_LEN];
+
+ mir_snprintf(dbSetting, sizeof(dbSetting), "%s%u_%s", PREFIX_ACTIONID, actionID, szSetting);
+ return DBWriteContactSettingDword(hContact, szModule, dbSetting, val);
+}
+
+static int __inline DBWriteActionSettingString(DWORD actionID, HANDLE hContact,const AnsiChar *szModule,const AnsiChar *szSetting,const AnsiChar *val) {
+
+ AnsiChar dbSetting[MAX_SETTING_LEN];
+
+ mir_snprintf(dbSetting, sizeof(dbSetting), "%s%u_%s", PREFIX_ACTIONID, actionID, szSetting);
+ return DBWriteContactSettingString(hContact, szModule, dbSetting, val);
+}
+
+static int __inline DBWriteActionSettingTString(DWORD actionID, HANDLE hContact,const AnsiChar *szModule,const AnsiChar *szSetting,const TCHAR *val) {
+
+ AnsiChar dbSetting[MAX_SETTING_LEN];
+
+ mir_snprintf(dbSetting, sizeof(dbSetting), "%s%u_%s", PREFIX_ACTIONID, actionID, szSetting);
+ return DBWriteContactSettingTString(hContact, szModule, dbSetting, val);
+}
+
+static int __inline DBWriteActionSettingWString(DWORD actionID, HANDLE hContact,const AnsiChar *szModule,const AnsiChar *szSetting,const WCHAR *val) {
+
+ AnsiChar dbSetting[MAX_SETTING_LEN];
+
+ mir_snprintf(dbSetting, sizeof(dbSetting), "%s%u_%s", PREFIX_ACTIONID, actionID, szSetting);
+ return DBWriteContactSettingWString(hContact, szModule, dbSetting, val);
+}
+
+static int __inline DBWriteActionSettingStringUtf(DWORD actionID, HANDLE hContact,const AnsiChar *szModule,const AnsiChar *szSetting,const AnsiChar *val) {
+
+ AnsiChar dbSetting[MAX_SETTING_LEN];
+
+ mir_snprintf(dbSetting, sizeof(dbSetting), "%s%u_%s", PREFIX_ACTIONID, actionID, szSetting);
+ return DBWriteContactSettingStringUtf(hContact, szModule, dbSetting, val);
+}
+
+static int __inline DBGetActionSettingByte(DWORD actionID, HANDLE hContact, const AnsiChar *szModule, const AnsiChar *szSetting, int errorValue) {
+
+
+ AnsiChar dbSetting[MAX_SETTING_LEN];
+
+ mir_snprintf(dbSetting, sizeof(dbSetting), "%s%u_%s", PREFIX_ACTIONID, actionID, szSetting);
+ return DBGetContactSettingByte(hContact, szModule, dbSetting, errorValue);
+}
+
+static WORD __inline DBGetActionSettingWord(DWORD actionID, HANDLE hContact, const AnsiChar *szModule, const AnsiChar *szSetting, int errorValue) {
+
+
+ AnsiChar dbSetting[MAX_SETTING_LEN];
+
+ mir_snprintf(dbSetting, sizeof(dbSetting), "%s%u_%s", PREFIX_ACTIONID, actionID, szSetting);
+ return DBGetContactSettingWord(hContact, szModule, dbSetting, errorValue);
+}
+
+static DWORD __inline DBGetActionSettingDword(DWORD actionID, HANDLE hContact, const AnsiChar *szModule, const AnsiChar *szSetting, int errorValue) {
+
+
+ AnsiChar dbSetting[MAX_SETTING_LEN];
+
+ mir_snprintf(dbSetting, sizeof(dbSetting), "%s%u_%s", PREFIX_ACTIONID, actionID, szSetting);
+ return DBGetContactSettingDword(hContact, szModule, dbSetting, errorValue);
+}
+
+static int __inline DBGetActionSetting(DWORD actionID, HANDLE hContact, const AnsiChar *szModule, const AnsiChar *szSetting, DBVARIANT *dbv) {
+
+
+ AnsiChar dbSetting[MAX_SETTING_LEN];
+
+ mir_snprintf(dbSetting, sizeof(dbSetting), "%s%u_%s", PREFIX_ACTIONID, actionID, szSetting);
+ return DBGetContactSetting(hContact, szModule, dbSetting, dbv);
+}
+
+static int __inline DBGetActionSettingW(DWORD actionID, HANDLE hContact,const AnsiChar *szModule, const AnsiChar *szSetting,DBVARIANT *dbv) {
+
+ AnsiChar dbSetting[MAX_SETTING_LEN];
+
+ mir_snprintf(dbSetting, sizeof(dbSetting), "%s%u_%s", PREFIX_ACTIONID, actionID, szSetting);
+ return DBGetContactSettingW(hContact, szModule, dbSetting, dbv);
+}
+
+static int __inline DBGetActionSettingTString(DWORD actionID, HANDLE hContact,const AnsiChar *szModule, const AnsiChar *szSetting,DBVARIANT *dbv) {
+
+ AnsiChar dbSetting[MAX_SETTING_LEN];
+
+ mir_snprintf(dbSetting, sizeof(dbSetting), "%s%u_%s", PREFIX_ACTIONID, actionID, szSetting);
+ return DBGetContactSettingTString(hContact, szModule, dbSetting, dbv);
+}
+
+static int __inline DBGetActionSettingWString(DWORD actionID, HANDLE hContact,const AnsiChar *szModule, const AnsiChar *szSetting,DBVARIANT *dbv) {
+
+ AnsiChar dbSetting[MAX_SETTING_LEN];
+
+ mir_snprintf(dbSetting, sizeof(dbSetting), "%s%u_%s", PREFIX_ACTIONID, actionID, szSetting);
+ return DBGetContactSettingWString(hContact, szModule, dbSetting, dbv);
+}
+
+static int __inline DBGetActionSettingStringUtf(DWORD actionID, HANDLE hContact,const AnsiChar *szModule, const AnsiChar *szSetting,DBVARIANT *dbv) {
+
+ AnsiChar dbSetting[MAX_SETTING_LEN];
+
+ mir_snprintf(dbSetting, sizeof(dbSetting), "%s%u_%s", PREFIX_ACTIONID, actionID, szSetting);
+ return DBGetContactSettingStringUtf(hContact, szModule, dbSetting, dbv);
+}
+
+static int __inline DBDeleteActionSetting(DWORD actionID, HANDLE hContact,const AnsiChar *szModule,const AnsiChar *szSetting) {
+
+ AnsiChar dbSetting[MAX_SETTING_LEN];
+
+ mir_snprintf(dbSetting, sizeof(dbSetting), "%s%u_%s", PREFIX_ACTIONID, actionID, szSetting);
+ return DBDeleteContactSetting(hContact, szModule, dbSetting);
+}
+
+// --------------------------------------------------------------------------
+// Database Helper Functions: Conditions
+// --------------------------------------------------------------------------
+
+static int __inline DBWriteConditionSettingByte(DWORD conditionID, HANDLE hContact,const AnsiChar *szModule,const AnsiChar *szSetting,BYTE val) {
+
+ AnsiChar dbSetting[MAX_SETTING_LEN];
+
+ mir_snprintf(dbSetting, sizeof(dbSetting), "%s%u_%s", PREFIX_CONDITIONID, conditionID, szSetting);
+ return DBWriteContactSettingByte(hContact, szModule, dbSetting, val);
+}
+
+static int __inline DBWriteConditionSettingWord(DWORD conditionID, HANDLE hContact,const AnsiChar *szModule,const AnsiChar *szSetting,WORD val) {
+
+ AnsiChar dbSetting[MAX_SETTING_LEN];
+
+ mir_snprintf(dbSetting, sizeof(dbSetting), "%s%u_%s", PREFIX_CONDITIONID, conditionID, szSetting);
+ return DBWriteContactSettingWord(hContact, szModule, dbSetting, val);
+}
+
+static int __inline DBWriteConditionSettingDword(DWORD conditionID, HANDLE hContact,const AnsiChar *szModule,const AnsiChar *szSetting,DWORD val) {
+
+ AnsiChar dbSetting[MAX_SETTING_LEN];
+
+ mir_snprintf(dbSetting, sizeof(dbSetting), "%s%u_%s", PREFIX_CONDITIONID, conditionID, szSetting);
+ return DBWriteContactSettingDword(hContact, szModule, dbSetting, val);
+}
+
+static int __inline DBWriteConditionSettingString(DWORD conditionID, HANDLE hContact,const AnsiChar *szModule,const AnsiChar *szSetting,const AnsiChar *val) {
+
+ AnsiChar dbSetting[MAX_SETTING_LEN];
+
+ mir_snprintf(dbSetting, sizeof(dbSetting), "%s%u_%s", PREFIX_CONDITIONID, conditionID, szSetting);
+ return DBWriteContactSettingString(hContact, szModule, dbSetting, val);
+}
+
+static int __inline DBWriteConditionSettingTString(DWORD conditionID, HANDLE hContact,const AnsiChar *szModule,const AnsiChar *szSetting,const TCHAR *val) {
+
+ AnsiChar dbSetting[MAX_SETTING_LEN];
+
+ mir_snprintf(dbSetting, sizeof(dbSetting), "%s%u_%s", PREFIX_CONDITIONID, conditionID, szSetting);
+ return DBWriteContactSettingTString(hContact, szModule, dbSetting, val);
+}
+
+static int __inline DBWriteConditionSettingWString(DWORD conditionID, HANDLE hContact,const AnsiChar *szModule,const AnsiChar *szSetting,const WCHAR *val) {
+
+ AnsiChar dbSetting[MAX_SETTING_LEN];
+
+ mir_snprintf(dbSetting, sizeof(dbSetting), "%s%u_%s", PREFIX_CONDITIONID, conditionID, szSetting);
+ return DBWriteContactSettingWString(hContact, szModule, dbSetting, val);
+}
+
+static int __inline DBWriteConditionSettingStringUtf(DWORD conditionID, HANDLE hContact,const AnsiChar *szModule,const AnsiChar *szSetting,const AnsiChar *val) {
+
+ AnsiChar dbSetting[MAX_SETTING_LEN];
+
+ mir_snprintf(dbSetting, sizeof(dbSetting), "%s%u_%s", PREFIX_CONDITIONID, conditionID, szSetting);
+ return DBWriteContactSettingStringUtf(hContact, szModule, dbSetting, val);
+}
+
+static int __inline DBGetConditionSettingByte(DWORD conditionID, HANDLE hContact, const AnsiChar *szModule, const AnsiChar *szSetting, int errorValue) {
+
+
+ AnsiChar dbSetting[MAX_SETTING_LEN];
+
+ mir_snprintf(dbSetting, sizeof(dbSetting), "%s%u_%s", PREFIX_CONDITIONID, conditionID, szSetting);
+ return DBGetContactSettingByte(hContact, szModule, dbSetting, errorValue);
+}
+
+static WORD __inline DBGetConditionSettingWord(DWORD conditionID, HANDLE hContact, const AnsiChar *szModule, const AnsiChar *szSetting, int errorValue) {
+
+
+ AnsiChar dbSetting[MAX_SETTING_LEN];
+
+ mir_snprintf(dbSetting, sizeof(dbSetting), "%s%u_%s", PREFIX_CONDITIONID, conditionID, szSetting);
+ return DBGetContactSettingWord(hContact, szModule, dbSetting, errorValue);
+}
+
+static DWORD __inline DBGetConditionSettingDword(DWORD conditionID, HANDLE hContact, const AnsiChar *szModule, const AnsiChar *szSetting, int errorValue) {
+
+
+ AnsiChar dbSetting[MAX_SETTING_LEN];
+
+ mir_snprintf(dbSetting, sizeof(dbSetting), "%s%u_%s", PREFIX_CONDITIONID, conditionID, szSetting);
+ return DBGetContactSettingDword(hContact, szModule, dbSetting, errorValue);
+}
+
+static int __inline DBGetConditionSetting(DWORD conditionID, HANDLE hContact, const AnsiChar *szModule, const AnsiChar *szSetting, DBVARIANT *dbv) {
+
+
+ AnsiChar dbSetting[MAX_SETTING_LEN];
+
+ mir_snprintf(dbSetting, sizeof(dbSetting), "%s%u_%s", PREFIX_CONDITIONID, conditionID, szSetting);
+ return DBGetContactSetting(hContact, szModule, dbSetting, dbv);
+}
+
+static int __inline DBGetConditionSettingW(DWORD conditionID, HANDLE hContact,const AnsiChar *szModule, const AnsiChar *szSetting,DBVARIANT *dbv) {
+
+ AnsiChar dbSetting[MAX_SETTING_LEN];
+
+ mir_snprintf(dbSetting, sizeof(dbSetting), "%s%u_%s", PREFIX_CONDITIONID, conditionID, szSetting);
+ return DBGetContactSettingW(hContact, szModule, dbSetting, dbv);
+}
+
+static int __inline DBGetConditionSettingTString(DWORD conditionID, HANDLE hContact,const AnsiChar *szModule, const AnsiChar *szSetting,DBVARIANT *dbv) {
+
+ AnsiChar dbSetting[MAX_SETTING_LEN];
+
+ mir_snprintf(dbSetting, sizeof(dbSetting), "%s%u_%s", PREFIX_CONDITIONID, conditionID, szSetting);
+ return DBGetContactSettingTString(hContact, szModule, dbSetting, dbv);
+}
+
+static int __inline DBGetConditionSettingWString(DWORD conditionID, HANDLE hContact,const AnsiChar *szModule, const AnsiChar *szSetting,DBVARIANT *dbv) {
+
+ AnsiChar dbSetting[MAX_SETTING_LEN];
+
+ mir_snprintf(dbSetting, sizeof(dbSetting), "%s%u_%s", PREFIX_CONDITIONID, conditionID, szSetting);
+ return DBGetContactSettingWString(hContact, szModule, dbSetting, dbv);
+}
+
+static int __inline DBGetConditionSettingStringUtf(DWORD conditionID, HANDLE hContact,const AnsiChar *szModule, const AnsiChar *szSetting,DBVARIANT *dbv) {
+
+ AnsiChar dbSetting[MAX_SETTING_LEN];
+
+ mir_snprintf(dbSetting, sizeof(dbSetting), "%s%u_%s", PREFIX_CONDITIONID, conditionID, szSetting);
+ return DBGetContactSettingStringUtf(hContact, szModule, dbSetting, dbv);
+}
+
+static int __inline DBDeleteConditionSetting(DWORD conditionID, HANDLE hContact,const AnsiChar *szModule,const AnsiChar *szSetting) {
+
+ AnsiChar dbSetting[MAX_SETTING_LEN];
+
+ mir_snprintf(dbSetting, sizeof(dbSetting), "%s%u_%s", PREFIX_CONDITIONID, conditionID, szSetting);
+ return DBDeleteContactSetting(hContact, szModule, dbSetting);
+}
+
+*)
+{$ENDIF}
diff --git a/plugins/Pascal_Headers/reserve/helpers/m_webcam.inc b/plugins/Pascal_Headers/reserve/helpers/m_webcam.inc new file mode 100644 index 0000000000..592e28a479 --- /dev/null +++ b/plugins/Pascal_Headers/reserve/helpers/m_webcam.inc @@ -0,0 +1,142 @@ +{
+ WebCam Video plugin by Sergei Polishchuk, SoftCab Inc
+ http://www.softcab.com
+ pserge@softcab.com
+}
+
+{$IFNDEF M_WEBCAM}
+{$DEFINE M_WEBCAM}
+
+const
+ MS_WEBCAM_OPEN = 'WebCam/Open';
+{
+ This opens webcamera
+ wParam, and lParam must be zero.
+ Returns HANDLE to web camera.
+ For Example:
+ HANDLE hWebcamera = CallService(MS_WEBCAM_OPEN, 0, 0);
+}
+
+ MS_WEBCAM_ISREADY = 'WebCam/IsReady';
+{
+ This zero if camera is ready for use, and non-zero if camera is still initializing.
+ It's useful to user this function after asynchronous opening of camera
+ wParam must be zero.
+ lParam = (LPARAM)(HANDLE)hCamera - camera handle
+ For Example:
+ HANDLE hWebcamera = CallService(MS_WEBCAM_ISREADY, 0, 0);
+}
+
+ MS_WEBCAM_CLOSE = 'WebCam/Close';
+{
+ This will close web camera.
+ wParam must be zero
+ lParam = (LPARAM)(HANDLE)hWebcamera - a handle returned by MS_WEBCAM_OPEN
+ Return value is undefined.
+ For Example:
+ CallService(MS_WEBCAM_CLOSE, 0, (LPARAM)hWebcamera);
+}
+
+ MS_WEBCAM_SHOWWND = 'WebCam/Show';
+{
+ This will show or hide web camera window
+ wParam = 1 to show window, or zero to hide one
+ lParam = (LPARAM)(HANDLE)hWebcamera - handle to camera
+ Return value is undefined.
+ For Example, this will show the window:
+ CallService(MS_WEBCAM_SHOWWND, 1, (LPARAM)hWebcamera);
+}
+
+ MS_WEBCAM_FREE = 'WebCam/Free';
+{
+ This will free WEBCAM_QUERY fields.
+ wParam = sizeof(WEBCAM_QUERY)
+ lParam = (LPARAM)(WEBCAM_QUERY*)&Query
+ Return value is undefined
+ For Example:
+ CallService(MS_WEBCAM_FREE, sizeof(Query), (LPARAM)&Query);
+}
+
+ MS_WEBCAM_QUERY = 'WebCam/Query';
+ WANT_PICTURE = pointer(-1);
+{
+ This will query web camera for data.
+ wParam = sizeof(WEBCAM_QUERY)
+ lParam = (LPARAM)(WEBCAM_QUERY*)&Query
+ Returns zero in case of success, or non-zero in case of any error
+ Before queryng camera, you need to setup some WEBCAM_QUERY structure fields.
+}
+
+(*
+WEBCAM_QUERY Query;
+memset(&Query, 0, sizeof(Query));
+Query.hCamera = hWebcamera;
+Query.Jpeg = WANT_PICTURE; // we want to get .JPG image
+Query.Bitmap = NULL; // we do not need .BMP image
+int ret = CallService(MS_WEBCAM_QUERY, sizeof(Query), (LPARAM)&Query);
+if(!ret)
+{ if(Query.Jpeg != NULL)
+ { // do something with JPG picture. For example, you may save it to .JPG file.
+ }
+ // now let's release the memory
+ CallService(MS_WEBCAM_FREE, sizeof(Query), (LPARAM)&Query);
+}
+*)
+
+ MS_WEBCAM_SCREENSHOT = 'WebCam/ScreenShot';
+{
+ This will return window screenshot
+ wParam = sizeof(WEBCAM_QUERY)
+ lParam = (LPARAM)(WEBCAM_QUERY*)&Query
+ Returns zero in case of success, or non-zero in case of any error
+ WEBCAMBUF->hCamera specifies window handle.
+ It's not required to open webcamera in order to run this service function.
+}
+
+(*
+
+WEBCAM_QUERY Query;
+memset(&Query, 0, sizeof(Query));
+Query.hCamera = (HANDLE)GetDesktopWindow(); // getting whole desktop picture.
+Query.Jpeg = WANT_PICTURE; // we want to get .JPG image
+Query.Bitmap = NULL; // we do not need .BMP image
+int ret = CallService(MS_WEBCAM_SCREENSHOT, sizeof(Query), (LPARAM)&Query);
+if(!ret)
+{ if(Query.Jpeg != NULL)
+ { // do something with JPG picture. For example, you may save it to .JPG file.
+ }
+ // now let's release the memory
+ CallService(MS_WEBCAM_FREE, sizeof(Query), (LPARAM)&Query);
+}
+
+*)
+
+ ME_WEBCAM_SNAPSHOTRECEIVED = 'WebCam/SnapshotRecv';
+{
+ This event will be fired right after receiving snapshot from remote contact.
+ wParam=(WPARAM)(HANDLE)hContact - a contact handle
+ lParam=(LPARAM)(WEBCAMBUF*)buffer - a buffer that contains JPEG image
+ IMPORTANT: you should not modify the buffer. It's read-only.
+}
+
+type
+ ptag_WEBCAMBUF = ^tag_WEBCAMBUF;
+ tag_WEBCAMBUF = record
+ Size:dword; // size of Data buffer in bytes
+ Data:array [0..0] of byte;
+ end;
+ PWEBCAMBUF = ^WEBCAMBUF;
+ WEBCAMBUF = tag_WEBCAMBUF;
+
+type
+ ptag_WEBCAM_QUERY = ^tag_WEBCAM_QUERY;
+ tag_WEBCAM_QUERY = record
+ hCamera:THANDLE; // [in] HANDLE to web camera
+ cx,cy :word; // [out] camera picture size
+ Jpeg :PWEBCAMBUF; // [in,out] points to .JPG file content in memory
+ Bitmap :PWEBCAMBUF; // [in,out] points to .BMP file content in memory
+ end;
+ PWEBCAM_QUERY = ^WEBCAM_QUERY;
+ WEBCAM_QUERY = tag_WEBCAM_QUERY;
+
+{$ENDIF}
|