From cb4a46e7fbe62d788e66ed6121c717a2d22a4d7c Mon Sep 17 00:00:00 2001 From: watcherhd Date: Thu, 21 Apr 2011 14:14:52 +0000 Subject: svn.miranda.im is moving to a new home! git-svn-id: http://miranda-plugins.googlecode.com/svn/trunk@7 e753b5eb-9565-29b2-b5c5-2cc6f99dfbcb --- fingerprint_mod/include/m_cluiframes.h | 253 ++++++++ fingerprint_mod/include/m_database.h | 1046 ++++++++++++++++++++++++++++++++ fingerprint_mod/include/m_icolib.h | 92 +++ fingerprint_mod/include/m_langpack.h | 94 +++ fingerprint_mod/include/m_options.h | 108 ++++ fingerprint_mod/include/m_plugins.h | 82 +++ fingerprint_mod/include/m_system.h | 366 +++++++++++ fingerprint_mod/include/m_utils.h | 325 ++++++++++ fingerprint_mod/include/newpluginapi.h | 169 ++++++ fingerprint_mod/include/win2k.h | 287 +++++++++ 10 files changed, 2822 insertions(+) create mode 100644 fingerprint_mod/include/m_cluiframes.h create mode 100644 fingerprint_mod/include/m_database.h create mode 100644 fingerprint_mod/include/m_icolib.h create mode 100644 fingerprint_mod/include/m_langpack.h create mode 100644 fingerprint_mod/include/m_options.h create mode 100644 fingerprint_mod/include/m_plugins.h create mode 100644 fingerprint_mod/include/m_system.h create mode 100644 fingerprint_mod/include/m_utils.h create mode 100644 fingerprint_mod/include/newpluginapi.h create mode 100644 fingerprint_mod/include/win2k.h (limited to 'fingerprint_mod/include') diff --git a/fingerprint_mod/include/m_cluiframes.h b/fingerprint_mod/include/m_cluiframes.h new file mode 100644 index 0000000..1cc4510 --- /dev/null +++ b/fingerprint_mod/include/m_cluiframes.h @@ -0,0 +1,253 @@ +/* +Miranda ICQ: the free icq client for MS Windows +Copyright (C) 2000-2 Richard Hughes, Roland Rabien & Tristan Van de Vreede + +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. +*/ + +///#include "commonheaders.h" +//#pragma hdrstop + +//////////////////////////////////// +//Extra Image Column Support +0.5.0.0 + +//Extra columns type. +//column arranged in this way +// +// [statusicon] ContactName [WEB][ADV1][ADV2][SMS][EMAIL][PROTO][CLIENT] +// +#define EXTRA_ICON_EMAIL 1 +#define EXTRA_ICON_PROTO 2 +#define EXTRA_ICON_SMS 3 +#define EXTRA_ICON_ADV1 4 +#define EXTRA_ICON_ADV2 5 +#define EXTRA_ICON_WEB 6 +#define EXTRA_ICON_CLIENT 7 +#define EXTRA_ICON_ADV3 8 +#define EXTRA_ICON_ADV4 9 + +#define EXTRA_ICON_COUNT 9 + +typedef struct +{ +int cbSize; //must be sizeof(IconExtraColumn) +int ColumnType; +HANDLE hImage; //return value from MS_CLIST_EXTRA_ADD_ICON +}IconExtraColumn,*pIconExtraColumn; + + +//Set icon for contact at needed column +//wparam=hContact +//lparam=pIconExtraColumn +//return 0 on success,-1 on failure +// +//See above for supported columns +#define MS_CLIST_EXTRA_SET_ICON "CListFrames/SetIconForExraColumn" + +//Adding icon to extra image list. +//Call this in ME_CLIST_EXTRA_LIST_REBUILD event +// +//wparam=hIcon +//lparam=0 +//return hImage on success,-1 on failure +#define MS_CLIST_EXTRA_ADD_ICON "CListFrames/AddIconToExtraImageList" + + + +#define ME_CLIST_EXTRA_LIST_REBUILD "CListFrames/OnExtraListRebuild" + +//called with wparam=hContact +#define ME_CLIST_EXTRA_IMAGE_APPLY "CListFrames/OnExtraImageApply" + + +/////////////////////////////////// + + + + +// +//want show tooltip for statusbar +//wparam=(char *)protocolname +//lparam=0 +#define ME_CLIST_FRAMES_SB_SHOW_TOOLTIP "CListFrames/StatusBarShowToolTip" + + +//want hide tooltip for statusbar +//wparam=lparam=0 + +#define ME_CLIST_FRAMES_SB_HIDE_TOOLTIP "CListFrames/StatusBarHideToolTip" + +// + + + +//adds a frame window +//wParam=(CLISTFrame*) +//lParam=0 +//returns an integer, the frame id. +typedef struct tagCLISTFrame { + DWORD cbSize; + HWND hWnd ; + HICON hIcon; + int align; //al flags below + int height; + int Flags; //F_flags below + char *name; //frame window name,will be shown in menu + char *TBname; //titlebar caption + //COLORREF TBBackColour; //titlebar background colour +} CLISTFrame; +#define F_VISIBLE 1 //Frame visible +#define F_SHOWTB 2 //Show TitleBar +#define F_UNCOLLAPSED 4 //UnCollapse frame +#define F_LOCKED 8 //Lock Frame +#define F_NOBORDER 16 //Dont apply WS_BORDER style for window +#define F_SHOWTBTIP 32 //Show titlebar tooltip +#define F_NO_SUBCONTAINER 1024 //Support skining no subcontainer needed + + +// frame alignment +#define alTop 0x00000001 +#define alBottom 0x00000002 +#define alClient 0x00000004 //only one alClient frame +#define MS_CLIST_FRAMES_ADDFRAME "CListFrames/AddFrame" + +#define MS_CLIST_FRAMES_REMOVEFRAME "CListFrames/RemoveFrame" + +//shows all frames +//wParam=lParam=0 +//returns 0 on success, -1 on failure +#define MS_CLIST_FRAMES_SHOWALLFRAMES "CListFrames/ShowALLFrames" + +//shows the titlebars of all frames +//wParam=lParam=0 +//returns 0 on success, -1 on failure +#define MS_CLIST_FRAMES_SHOWALLFRAMESTB "CListFrames/ShowALLFramesTB" + +//hides the titlebars of all frames +//wParam=lParam=0 +//returns 0 on success, -1 on failure +#define MS_CLIST_FRAMES_HIDEALLFRAMESTB "CListFrames/HideALLFramesTB" + +//shows the frame if it is hidden, +//hides the frame if it is shown +//wParam=FrameId +//lParam=0 +//returns 0 on success, -1 on failure +#define MS_CLIST_FRAMES_SHFRAME "CListFrames/SHFrame" + +//shows the frame titlebar if it is hidden, +//hides the frame titlebar if it is shown +//wParam=FrameId +//lParam=0 +//returns 0 on success, -1 on failure +#define MS_CLIST_FRAMES_SHFRAMETITLEBAR "CListFrame/SHFrameTitleBar" + +//locks the frame if it is unlocked, +//unlock the frame if it is locked +//wParam=FrameId +//lParam=0 +//returns 0 on success, -1 on failure +#define MS_CLIST_FRAMES_ULFRAME "CListFrame/ULFrame" + +//collapses the frame if it is uncollapsed, +//uncollapses the frame if it is collapsed +//wParam=FrameId +//lParam=0 +//returns 0 on success, -1 on failure +#define MS_CLIST_FRAMES_UCOLLFRAME "CListFrame/UCOLLFrame" + +//trigger border flags +//wparam=frameid +//lparam=0 +#define MS_CLIST_FRAMES_SETUNBORDER "CListFrame/SetUnBorder" + +//redraws the frame +//wParam=FrameId, -1 for all frames +//lparam=FU_flags +//returns a pointer to option, -1 on failure +#define FU_TBREDRAW 1 //redraw titlebar +#define FU_FMREDRAW 2 //redraw Frame +#define FU_FMPOS 4 //update Frame position +#define MS_CLIST_FRAMES_UPDATEFRAME "CListFrame/UpdateFrame" + +//gets the frame options +//(HIWORD)wParam=FrameId +//(LOWORD)wParam=FO_flag +//lParam=0 +//returns a pointer to option, -1 on failure +#define FO_FLAGS 0x0001 //return set of F_VISIBLE,F_SHOWTB,F_UNCOLLAPSED,F_LOCKED,F_NOBORDER,F_SHOWTBTIP +#define FO_NAME 0x0002 //Change name +#define FO_TBNAME 0x0003 //Change TB caption +#define FO_TBSTYLE 0x0004 //Change TB style +#define FO_TBEXSTYLE 0x0005 //Change TB exstyle +#define FO_ICON 0x0006 //Change icon +#define FO_HEIGHT 0x0007 //Change height +#define FO_ALIGN 0x0008 //Change align +#define FO_TBTIPNAME 0x0009 //Change TB tooltip +#define FO_FLOATING 0x000a //Change floating mode + +#define MS_CLIST_FRAMES_GETFRAMEOPTIONS "CListFrame/GetFrameOptions" + +//sets the frame options +//(HIWORLD)wParam=FrameId +//(LOWORD)wParam=FO_flag +//lParam=value +//returns 0 on success, -1 on failure +#define MS_CLIST_FRAMES_SETFRAMEOPTIONS "CListFrame/SetFrameOptions" + + +//menu stuff + +//add a new item to the context frame menu +//wParam=0 +//lParam=(LPARAM)(CLISTMENUITEM*)&mi +//returns a handle to the new item +//popupposition=frameid +//contactowner=advanced parameter +#define MS_CLIST_ADDCONTEXTFRAMEMENUITEM "CList/AddContextFrameMenuItem" + +//remove a item from context frame menu +//wParam=hMenuItem returned by MS_CLIST_ADDCONTACTMENUITEM +//lParam=0 +//returns 0 on success, nonzero on failure +#define MS_CLIST_REMOVECONTEXTFRAMEMENUITEM "CList/RemoveContextFrameMenuItem" + +//builds the context menu for a frame +//wparam=frameid +//lParam=0 +//returns a HMENU on success, or NULL on failure +#define MS_CLIST_MENUBUILDFRAMECONTEXT "CList/BuildContextFrameMenu" + +/* +//the frame menu is about to be built +wparam=frameid +lparam= +-1 for build from titlebar, + use + MS_CLIST_ADDCONTEXTFRAMEMENUITEM + MS_CLIST_REMOVECONTEXTFRAMEMENUITEM + +>0 for build in main menu, +must be popupname=lparam to place your items in right popup of main menu. + use + MS_CLIST_ADDMAINMENUITEM + MS_CLIST_REMOVEMAINMENUITEM + +*/ +#define ME_CLIST_PREBUILDFRAMEMENU "CList/PreBuildFrameMenu" + +//needed by cluiframes module to add frames menu to main menu. +//it just calls NotifyEventHooks(hPreBuildFrameMenuEvent,wParam,lParam); +#define MS_CLIST_FRAMEMENUNOTIFY "CList/ContextFrameMenuNotify" diff --git a/fingerprint_mod/include/m_database.h b/fingerprint_mod/include/m_database.h new file mode 100644 index 0000000..ac4fcff --- /dev/null +++ b/fingerprint_mod/include/m_database.h @@ -0,0 +1,1046 @@ +/* + +Miranda IM: the free IM client for Microsoft* Windows* + +Copyright 2000-2003 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_DATABASE_H__ +#define M_DATABASE_H__ 1 + +/******************* DATABASE MODULE ***************************/ + +/* Notes (as I think of them): +- The module is 100% thread-safe +- The database is the main routing point for the vast majority of Miranda. + Events are sent from the protocol module to here, and the send/recv message + module (for example) hooks the db/event/added event. Events like 'contact + online status changed' do not come through here - icqlib will send that one. +- contacts work much the same. the find/add users module calls db/contact/add + and db/contact/writesetting and the contact list will get db/contact/added + and db/contact/settingchanged events +- The user is just a special contact. A hcontact of NULL in most functions + means the user. Functions in which it cannot be used will be stated +- events attached to the user are things like system messages +- also in this module are crypt/decrypt functions for stuff that should be + obfuscated on the disk, and some time functions for dealing with timestamps + in events. +- the contactsettings system is designed for being read by many different + modules. eg lots of people will be interested in "ICQ"/"UIN", but the module + name passed to contact/writesetting should always be your own. The Mirabilis + ICQ database importer clearly has to be an exception to this rule, along with + a few other bits. +- the current database format means that geteventcontact is exceptionally slow. + It should be avoidable in most cases so I'm not too concerned, but if people + really need to use it a lot, I'll sort it out. +- handles do not need to be closed unless stated +- the database is loaded as a memory mapped file. This has various + disadvantages but a massive advantage in speed for random access. +- The database is optimised for reading. Write performance is fairly bad, + except for adding events which is the most common activity and pretty good. +- I'll work on caching to improve this later +- Deleted items are left as empty space and never reused. All new items are + put at the end. A count is kept of this slack space and at some point a + separate programme will need to be written to repack the database when the + slack gets too high. It's going to be a good few months of usage before this + can happen to anyone though, so no rush. +*/ + +/******************** GENERALLY USEFUL STUFF***********************/ + +#include + +//DBVARIANT: used by db/contact/getsetting and db/contact/writesetting +#define DBVT_DELETED 0 //this setting just got deleted, no other values are valid +#define DBVT_BYTE 1 //bVal and cVal are valid +#define DBVT_WORD 2 //wVal and sVal are valid +#define DBVT_DWORD 4 //dVal and lVal are valid +#define DBVT_ASCIIZ 255 //pszVal is valid +#define DBVT_BLOB 254 //cpbVal and pbVal are valid +#define DBVT_UTF8 253 //pszVal is valid +#define DBVT_WCHAR 252 //pszVal is valid +#define DBVTF_VARIABLELENGTH 0x80 +typedef struct { + BYTE type; + union { + BYTE bVal; char cVal; + WORD wVal; short sVal; + DWORD dVal; long lVal; + struct { + union { + char *pszVal; + TCHAR *ptszVal; + WCHAR *pwszVal; + }; + WORD cchVal; //only used for db/contact/getsettingstatic + }; + struct { + WORD cpbVal; + BYTE *pbVal; + }; + }; +} DBVARIANT; + +/******************************************************************/ +/************************* SERVICES *******************************/ +/******************************************************************/ + +/* DB/Contact/GetProfileName service +Gets the name of the profile currently being used by the database module. This +is the same as the filename of the database, minus extension + wParam=(WPARAM)(UINT)cbName + lParam=(LPARAM)(char*)pszName +pszName is a pointer to the buffer that receives the name of the profile +cbName is the size in bytes of the pszName buffer +Returns 0 on success or nonzero otherwise +*/ +#define MS_DB_GETPROFILENAME "DB/GetProfileName" + +/* DB/Contact/GetProfilePath service +Gets the path of the profile currently being used by the database module. This +path does not include the last '\'. + wParam=(WPARAM)(UINT)cbName + lParam=(LPARAM)(char*)pszName +pszName is a pointer to the buffer that receives the path of the profile +cbName is the size in bytes of the pszName buffer +Returns 0 on success or nonzero otherwise +*/ +#define MS_DB_GETPROFILEPATH "DB/GetProfilePath" + +/************************* Contact ********************************/ + +/* DB/Contact/GetSetting service +Look up the value of a named setting for a specific contact in the database + wParam=(WPARAM)(HANDLE)hContact + lParam=(LPARAM)(DBCONTACTGETSETTING*)&dbcgs +hContact should have been returned by find*contact or addcontact +Caller is responsible for free()ing dbcgs.pValue->pszVal and pbVal if they are +returned. This should be done with db/contact/freevariant if you have your own +heap (like DLLs do). +Note that DBCONTACTGETSETTING takes a pointer to a DBVARIANT, whereas +DBCONTACTWRITESETTING contains a DBVARIANT. +Returns 0 on success or nonzero if the setting name was not found or hContact +was invalid +Because this is such a common function there are some short helper function at +the bottom of this header that use it. + +(Added during 0.3.3+ development!!) + +If a setting is queried under for contact and it is deleted it will +not be returned as a successful attempt, prior to 0.3.3 a *deleted* +setting would be successfully read (which was a bug because the pValue +was often garbage and maybe not even NULL terminated) + +To test for existing but 'deleted' settings, the return value will +be 2, and pValue->type==DBVT_DELETED, at this point pValue is undefined. +*/ +typedef struct { + const char *szModule; // pointer to name of the module that wrote the + // setting to get + const char *szSetting; // pointer to name of the setting to get + DBVARIANT *pValue; // pointer to variant to receive the value +} DBCONTACTGETSETTING; +#define MS_DB_CONTACT_GETSETTING "DB/Contact/GetSetting" + +/* DB/Contact/GetSettingString service 0.4.3+ +Same as DB/Contact/GetSetting, but also gets the required string type inside +the dbcgs->type parameter +*/ +#define MS_DB_CONTACT_GETSETTING_STR "DB/Contact/GetSettingStr" + +/* DB/Contact/GetSettingStatic service +Look up the value of a named setting for a specific contact in the database + wParam=(WPARAM)(HANDLE)hContact + lParam=(LPARAM)(DBCONTACTGETSETTING*)&dbcgs +hContact should have been returned by find*contact or addcontact +This service differs from db/contact/getsetting in that it won't malloc() +memory for the return value if it needs to do so. This introduces some extra +constraints: +Upon calling dbcgs.pValue->type should be initialised to the expected type of +the setting. If the setting is of an integral type it won't matter if it's +wrong and the service will correct it before returning, however if the setting +is a string or a blob the service needs to know where to put the data and will +fail if type is set wrongly. +If dbcgs.pValue->type is DBVT_ASCIIZ or DBVT_BLOB upon calling, the +corresponding data field (pszVal or pbVal) must point to a buffer allocated by +the caller and the length field (cchVal or cpbVal) must contain the size of +that buffer in bytes. +If the setting type is variable length (DBVT_ASCIIZ or DBVT_BLOB), on exit the +length field (cchVal or cpbVal) will be filled with the full length of the +setting's value (excluding the terminating nul if it's DBVT_ASCIIZ). +This service exists as well as db/contact/getsetting because malloc()/free() +can be too slow for frequently queried settings. +Returns 0 on success or nonzero if the setting name was not found or hContact +was invalid. +*/ +#define MS_DB_CONTACT_GETSETTINGSTATIC "DB/Contact/GetSettingStatic" + +/* DB/Contact/FreeVariant service +Free the memory in a DBVARIANT that is allocated by a call to +db/contact/getsetting + wParam=0 + lParam=(LPARAM)(DBVARIANT*)&dbv +Returns 0 on success, nonzero otherwise +This service is actually just a wrapper around a call to free() and a test to +check that it is a string or a blob in the variant. It exists because DLLs have +their own heap and cannot free the memory allocated in db/contact/getsetting. +Thus it need not be called if you know the variant contains some form of int, +and you will often see free() used instead in code written before I noticed +this problem. +Good style, of course, dictates that it should be present to match all calls to +db/contact/getsetting, but that's not going to happen of course. +There's a helper function for this at the bottom of this header too. +*/ +#define MS_DB_CONTACT_FREEVARIANT "DB/Contact/FreeVariant" + +/* DB/Contact/WriteSetting service +Change the value of, or create a new value with, a named setting for a specific +contact in the database to the given value + wParam=(WPARAM)(HANDLE)hContact + lParam=(LPARAM)(DBCONTACTWRITESETTING*)&dbcws +hContact should have been returned by find*contact or addcontact +Returns 0 on success or nonzero if hContact was invalid +Note that DBCONTACTGETSETTING takes a pointer to a DBVARIANT, whereas +DBCONTACTWRITESETTING contains a DBVARIANT. +Because this is such a common function there are some short helper function at +the bottom of this header that use it. +Triggers a db/contact/settingchanged event just before it returns. +*/ +typedef struct { + const char *szModule; // pointer to name of the module that wrote the + // setting to get + const char *szSetting; // pointer to name of the setting to get + DBVARIANT value; // variant containing the value to set +} DBCONTACTWRITESETTING; +#define MS_DB_CONTACT_WRITESETTING "DB/Contact/WriteSetting" + +/* DB/Contact/DeleteSetting service +Removes a named setting for a specific contact from the database + wParam=(WPARAM)(HANDLE)hContact + lParam=(LPARAM)(DBCONTACTGETSETTING*)&dbcgs +hContact should have been returned by find*contact or addcontact +pValue from dbcgs is not used. +Returns 0 on success or nonzero if the setting was not present or hContact was +invalid +Triggers a db/contact/settingchanged event before it deletes the setting. The +'new value' of the setting is set to type=0 and all the other fields are +undefined. +*/ +#define MS_DB_CONTACT_DELETESETTING "DB/Contact/DeleteSetting" + +/* db/contact/enumsettings v0.1.0.1+ +Lists all the settings a specific modules has stored in the database for a +specific contact. +wParam=(WPARAM)(HANDLE)hContact +lParam=(LPARAM)(DBCONTACTENUMSETTINGS*)&dbces +Returns the return value of the last call to pfnEnumProc, or -1 if there are +no settings for that module/contact pair +Writing to or deleting from the database while enumerating will have +unpredictable results for the enumeration, but the write will succeed. +Use db/modules/enum to get a complete list of module names +szSetting is only guaranteed to be valid for the duration of the callback. If +you want to keep it for longer you must allocation your own storage. +*/ +typedef int (*DBSETTINGENUMPROC)(const char *szSetting,LPARAM lParam); +typedef struct { + DBSETTINGENUMPROC pfnEnumProc; + LPARAM lParam; //passed direct to pfnEnumProc + const char *szModule; //name of the module to get settings for + DWORD ofsSettings; //filled by the function to contain the offset from + //the start of the database of the requested settings group. +} DBCONTACTENUMSETTINGS; +#define MS_DB_CONTACT_ENUMSETTINGS "DB/Contact/EnumSettings" + +/* DB/Contact/GetCount service +Gets the number of contacts in the database, which does not count the user + wParam=lParam=0 +Returns the number of contacts. They can be retrieved using contact/findfirst +and contact/findnext +*/ +#define MS_DB_CONTACT_GETCOUNT "DB/Contact/GetCount" + +/* DB/Contact/FindFirst service +Gets the handle of the first contact in the database. This handle can be used +with loads of functions. It does not need to be closed. + wParam=lParam=0 +Returns a handle to the first contact in the db on success, or NULL if there +are no contacts in the db. +*/ +#define MS_DB_CONTACT_FINDFIRST "DB/Contact/FindFirst" + +/* DB/Contact/FindNext service +Gets the handle of the next contact after hContact in the database. This handle +can be used with loads of functions. It does not need to be closed. + wParam=(WPARAM)(HANDLE)hContact + lParam=0 +Returns a handle to the contact after hContact in the db on success or NULL if +hContact was the last contact in the db or hContact was invalid. +*/ +#define MS_DB_CONTACT_FINDNEXT "DB/Contact/FindNext" + +/* DB/Contact/Delete +Deletes the contact hContact from the database and all events and settings +associated with it. + wParam=(WPARAM)(HANDLE)hContact + lParam=0 +Returns 0 on success or nonzero if hContact was invalid +Please don't try to delete the user contact (hContact=NULL) +Triggers a db/contact/deleted event just *before* it removes anything +Because all events are deleted, lots of people may end up with invalid event +handles from this operation, which they should be prepared for. +*/ +#define MS_DB_CONTACT_DELETE "DB/Contact/Delete" + +/* DB/Contact/Add +Adds a new contact to the database. New contacts initially have no settings +whatsoever, they must all be added with db/contacts/writesetting. + wParam=lParam=0 +Returns a handle to the newly created contact on success, or NULL otherwise. +Triggers a db/contact/added event just before it returns. +*/ +#define MS_DB_CONTACT_ADD "DB/Contact/Add" + +/* DB/Contact/Is +Checks if a given value is a valid contact handle, note that due +to the nature of multiple threading, a valid contact can still become +invalid after a call to this service. + wParam=(WPARAM)hContact + lParam=0 +Returns 1 if the contact is a contact, or 0 if the contact is not valid. +*/ +#define MS_DB_CONTACT_IS "DB/Contact/Is" + +/************************** Event *********************************/ + +/* DB/Event/GetCount service +Gets the number of events in the chain belonging to a contact in the database. + wParam=(WPARAM)(HANDLE)hContact + lParam=0 +Returns the number of events in the chain owned by hContact or -1 if hContact +is invalid. They can be retrieved using the event/find* services. +*/ +#define MS_DB_EVENT_GETCOUNT "DB/Event/GetCount" + +/* DB/Event/Add +Adds a new event to a contact's event list + wParam=(WPARAM)(HANDLE)hContact + lParam=(LPARAM)(DBEVENTINFO*)&dbe +Returns a handle to the newly added event, or NULL on failure +Triggers a db/event/added event just before it returns. +Events are sorted chronologically as they are entered, so you cannot guarantee +that the new hEvent is the last event in the chain, however if a new event is +added that has a timestamp less than 90 seconds *before* the event that should +be after it, it will be added afterwards, to allow for protocols that only +store times to the nearest minute, and slight delays in transports. +There are a few predefined eventTypes below for easier compatibility, but +modules are free to define their own, beginning at 2000 +DBEVENTINFO.timestamp is in GMT, as returned by time(). There are services +db/time/x below with useful stuff for dealing with it. +*/ +#define DBEF_FIRST 1 //this is the first event in the chain; + //internal only: *do not* use this flag +#define DBEF_SENT 2 //this event was sent by the user. If not set this + //event was received. +#define DBEF_READ 4 //event has been read by the user. It does not need + //to be processed any more except for history. +typedef struct { + int cbSize; //size of the structure in bytes + char *szModule; //pointer to name of the module that 'owns' this + //event, ie the one that is in control of the data format + DWORD timestamp; //seconds since 00:00, 01/01/1970. Gives us times until + //2106 unless you use the standard C library which is + //signed and can only do until 2038. In GMT. + DWORD flags; //the omnipresent flags + WORD eventType; //module-defined event type field + DWORD cbBlob; //size of pBlob in bytes + PBYTE pBlob; //pointer to buffer containing module-defined event data +} DBEVENTINFO; +#define EVENTTYPE_MESSAGE 0 +#define EVENTTYPE_URL 1 +#define EVENTTYPE_CONTACTS 2 //v0.1.2.2+ +#define EVENTTYPE_ADDED 1000 //v0.1.1.0+: these used to be module- +#define EVENTTYPE_AUTHREQUEST 1001 //specific codes, hence the module- +#define EVENTTYPE_FILE 1002 //specific limit has been raised to 2000 +#define MS_DB_EVENT_ADD "DB/Event/Add" + +/* DB/Event/Delete +Removes a single event from the database + wParam=(WPARAM)(HANDLE)hContact + lParam=(LPARAM)(HANDLE)hDbEvent +hDbEvent should have been returned by db/event/add or db/event/find*event +Returns 0 on success, or nonzero if hDbEvent was invalid +Triggers a db/event/deleted event just *before* the event is deleted +*/ +#define MS_DB_EVENT_DELETE "DB/Event/Delete" + +/* DB/Event/GetBlobSize +Retrieves the space in bytes required to store the blob in hDbEvent + wParam=(WPARAM)(HANDLE)hDbEvent + lParam=0 +hDbEvent should have been returned by db/event/add or db/event/find*event +Returns the space required in bytes, or -1 if hDbEvent is invalid +*/ +#define MS_DB_EVENT_GETBLOBSIZE "DB/Event/GetBlobSize" + +/* DB/Event/Get +Retrieves all the information stored in hDbEvent + wParam=(WPARAM)(HANDLE)hDbEvent + lParam=(LPARAM)(DBEVENTINFO*)&dbe +hDbEvent should have been returned by db/event/add or db/event/find*event +Returns 0 on success or nonzero if hDbEvent is invalid +Don't forget to set dbe.cbSize, dbe.pBlob and dbe.cbBlob before calling this +service +The correct value dbe.cbBlob can be got using db/event/getblobsize +If successful, all the fields of dbe are filled. dbe.cbBlob is set to the +actual number of bytes retrieved and put in dbe.pBlob +If dbe.cbBlob is too small, dbe.pBlob is filled up to the size of dbe.cbBlob +and then dbe.cbBlob is set to the required size of data to go in dbe.pBlob +On return, dbe.szModule is a pointer to the database module's own internal list +of modules. Look but don't touch. +*/ +#define MS_DB_EVENT_GET "DB/Event/Get" + +/* DB/Event/MarkRead +Changes the flags for an event to mark it as read. + wParam=(WPARAM)(HANDLE)hContact + lParam=(LPARAM)(HANDLE)hDbEvent +hDbEvent should have been returned by db/event/add or db/event/find*event +Returns the entire flag DWORD for the event after the change, or -1 if hDbEvent +is invalid. +This is the one database write operation that does not trigger an event. +Modules should not save flags states for any length of time. +*/ +#define MS_DB_EVENT_MARKREAD "DB/Event/MarkRead" + +/* DB/Event/GetContact +Retrieves a handle to the contact that owns hDbEvent. + wParam=(WPARAM)(HANDLE)hDbEvent + lParam=0 +hDbEvent should have been returned by db/event/add or db/event/find*event +NULL is a valid return value, meaning, as usual, the user. +Returns (HANDLE)(-1) if hDbEvent is invalid, or the handle to the contact on +success +This service is exceptionally slow. Use only when you have no other choice at +all. +*/ +#define MS_DB_EVENT_GETCONTACT "DB/Event/GetContact" + +/* DB/Event/FindFirst +Retrieves a handle to the first event in the chain for hContact + wParam=(WPARAM)(HANDLE)hContact + lParam=0 +Returns the handle, or NULL if hContact is invalid or has no events +Events in a chain are sorted chronologically automatically +*/ +#define MS_DB_EVENT_FINDFIRST "DB/Event/FindFirst" + +/* DB/Event/FindFirstUnread +Retrieves a handle to the first unread event in the chain for hContact + wParam=(WPARAM)(HANDLE)hContact + lParam=0 +Returns the handle, or NULL if hContact is invalid or all its events have been +read +Events in a chain are sorted chronologically automatically, but this does not +necessarily mean that all events after the first unread are unread too. They +should be checked individually with event/findnext and event/get +This service is designed for startup, reloading all the events that remained +unread from last time +*/ +#define MS_DB_EVENT_FINDFIRSTUNREAD "DB/Event/FindFirstUnread" + +/* DB/Event/FindLast +Retrieves a handle to the last event in the chain for hContact + wParam=(WPARAM)(HANDLE)hContact + lParam=0 +Returns the handle, or NULL if hContact is invalid or has no events +Events in a chain are sorted chronologically automatically +*/ +#define MS_DB_EVENT_FINDLAST "DB/Event/FindLast" + +/* DB/Event/FindNext +Retrieves a handle to the next event in a chain after hDbEvent + wParam=(WPARAM)(HANDLE)hDbEvent + lParam=0 +Returns the handle, or NULL if hDbEvent is invalid or is the last event +Events in a chain are sorted chronologically automatically +*/ +#define MS_DB_EVENT_FINDNEXT "DB/Event/FindNext" + +/* DB/Event/FindPrev +Retrieves a handle to the previous event in a chain before hDbEvent + wParam=(WPARAM)(HANDLE)hDbEvent + lParam=0 +Returns the handle, or NULL if hDbEvent is invalid or is the first event +Events in a chain are sorted chronologically automatically +*/ +#define MS_DB_EVENT_FINDPREV "DB/Event/FindPrev" + +/************************** Encryption ****************************/ + +/* DB/Crypt/EncodeString +Scrambles pszString in-place using a strange encryption algorithm + wParam=(WPARAM)(int)cbString + lParam=(LPARAM)(char*)pszString +cbString is the size of the buffer pointed to by pszString, *not* the length +of pszString. This service may be changed at a later date such that it +increases the length of pszString +Returns 0 always +*/ +#define MS_DB_CRYPT_ENCODESTRING "DB/Crypt/EncodeString" + +/* DB/Crypt/DecodeString +Descrambles pszString in-place using the strange encryption algorithm + wParam=(WPARAM)(int)cbString + lParam=(LPARAM)(char*)pszString +Reverses the operation done by crypt/encodestring +cbString is the size of the buffer pointed to by pszString, *not* the length +of pszString. +Returns 0 always +*/ +#define MS_DB_CRYPT_DECODESTRING "DB/Crypt/DecodeString" + +/**************************** Time ********************************/ + +/* DB/Time/TimestampToLocal +Converts a GMT timestamp into local time + wParam=(WPARAM)(DWORD)timestamp + lParam=0 +Returns the converted value +Timestamps have zero at midnight 1/1/1970 GMT, this service converts such a +value to be based at midnight 1/1/1970 local time. +This service does not use a simple conversion based on the current offset +between GMT and local. Rather, it figures out whether daylight savings time +would have been in place at the time of the stamp and gives the local time as +it would have been at the time and date the stamp contains. +This service isn't nearly as useful as db/time/TimestampToString below and I +recommend avoiding its use when possible so that you don't get your timezones +mixed up (like I did. Living at GMT makes things easier for me, but has certain +disadvantages :-) ). +*/ +#define MS_DB_TIME_TIMESTAMPTOLOCAL "DB/Time/TimestampToLocal" + +/* DB/Time/TimestampToString +Converts a GMT timestamp into a customisable local time string + wParam=(WPARAM)(DWORD)timestamp + lParam=(LPARAM)(DBTIMETOSTRING*)&tts +Returns 0 always +Uses db/time/timestamptolocal for the conversion so read that description to +see what's going on. +The string is formatted according to the current user's locale, language and +preferences. +szFormat can have the following special characters: + t Time without seconds, eg hh:mm + s Time with seconds, eg hh:mm:ss + m Time without minutes, eg hh + d Short date, eg dd/mm/yyyy + D Long date, eg d mmmm yyyy +All other characters are copied across to szDest as-is +*/ +typedef struct { + char *szFormat; // format string, as above + char *szDest; // place to put the output string + int cbDest; // maximum number of bytes to put in szDest +} DBTIMETOSTRING; +#define MS_DB_TIME_TIMESTAMPTOSTRING "DB/Time/TimestampToString" + +typedef struct { + TCHAR *szFormat; // format string, as above + TCHAR *szDest; // place to put the output string + int cbDest; // maximum number of bytes to put in szDest +} DBTIMETOSTRINGT; +#define MS_DB_TIME_TIMESTAMPTOSTRINGT "DB/Time/TimestampToStringT" + +/*************************** Random *******************************/ + +/* +Switches safety settings on or off +wParam=(WPARAM)(BOOL)newSetting +lParam=0 +returns 0 always +newSetting is TRUE initially. +Miranda's database is normally protected against corruption by agressively +flushing data to the disk on writes. If you're doing a lot of writes (eg in +an import plugin) it can sometimes be desirable to switch this feature off to +speed up the process. If you do switch it off, you must remember that crashes +are far more likely to be catastrophic, so switch it back on at the earliest +possible opportunity. +Note that if you're doing a lot of setting writes, the flush is already delayed +so you need not use this service for that purpose. +*/ +#define MS_DB_SETSAFETYMODE "DB/SetSafetyMode" + +/*************************** Modules ******************************/ + +/* db/modules/enum v0.1.0.1+ +Enumerates the names of all modules that have stored or requested information +from the database. +wParam=lParam +lParam=(WPARAM)(DBMODULEENUMPROC)dbmep +Returns the value returned by the last call to dbmep +This service is only really useful for debugging, in conjunction with +db/contact/enumsettings +lParam is passed directly to dbmep +dbmep should return 0 to continue enumeration, or nonzero to stop. +ofsModuleName is the offset of the module name from the start of the profile +database, and is only useful for really heavyweight debugging +Modules names will be enumerated in no particular order +Writing to the database while module names are being enumerated will cause +unpredictable results in the enumeration, but the write will work. +szModuleName is only guaranteed to be valid for the duration of the callback. +If you want to keep it for longer you must allocation your own storage. +**BUG**: Prior to 0.1.2.0 dbmep was called as (lParam)(szMod,ofsMod,lParam). + This means that the lParam parameter to dbmep was useless, and explains the + slightly odd 'wParam=lParam' in the definition. +*/ +typedef int (*DBMODULEENUMPROC)(const char *szModuleName,DWORD ofsModuleName,LPARAM lParam); +#define MS_DB_MODULES_ENUM "DB/Modules/Enum" + +/******************************************************************/ +/************************** EVENTS ********************************/ +/******************************************************************/ + +/* DB/Event/Added event +Called when a new event has been added to the event chain for a contact + wParam=(WPARAM)(HANDLE)hContact + lParam=(LPARAM)(HANDLE)hDbEvent +hDbEvent is a valid handle to the event. hContact is a valid handle to the +contact to which hDbEvent refers. +Since events are sorted chronologically, you cannot guarantee that hDbEvent is +at any particular position in the chain. +*/ +#define ME_DB_EVENT_ADDED "DB/Event/Added" + +/* DB/Event/FilterAdd (NOTE: Added during 0.3.3+ development!) +Called **before** a new event is made of a DBEVENTINFO structure, this +hook is not SAFE unless you know what you're doing with it, the arguments +are passed as-is (with errors, pointer problems, if any) from any arguments +passed to MS_DB_EVENT_ADD. + +The point of this hook is to stop any unwanted database events, to stop +an event being added, return 1, to allow the event to pass through return +0. + wParam=(WPARAM)(HANDLE)hContact + lParam=(LPARAM)&DBEVENTINFO + +Any changed made to the said DBEVENTINFO are also passed along to the database, +therefore it is possible to shape the data, however DO NOT DO THIS. +*/ +#define ME_DB_EVENT_FILTER_ADD "DB/Event/FilterAdd" + +/* DB/Event/Deleted event +Called when an event is about to be deleted from the event chain for a contact + wParam=(WPARAM)(HANDLE)hContact + lParam=(LPARAM)(HANDLE)hDbEvent +hDbEvent is a valid handle to the event which is about to be deleted, but it +won't be once your hook has returned. +hContact is a valid handle to the contact to which hDbEvent refers, and will +remain valid. +Returning nonzero from your hook will not stop the deletion, but it will, as +usual, stop other hooks from being called. +*/ +#define ME_DB_EVENT_DELETED "DB/Event/Deleted" + +/* DB/Contact/Added event +Called when a new contact has been added to the database + wParam=(WPARAM)(HANDLE)hContact + lParam=0 +hContact is a valid handle to the new contact. +Contacts are initially created without any settings, so if you hook this event +you will almost certainly also want to hook db/contact/settingchanged as well. +*/ +#define ME_DB_CONTACT_ADDED "DB/Contact/Added" + +/* DB/Contact/Deleted event +Called when an contact is about to be deleted + wParam=(WPARAM)(HANDLE)hContact + lParam=0 +hContact is a valid handle to the contact which is about to be deleted, but it +won't be once your hook has returned. +Returning nonzero from your hook will not stop the deletion, but it will, as +usual, stop other hooks from being called. +Deleting a contact invalidates all events in its chain. +*/ +#define ME_DB_CONTACT_DELETED "DB/Contact/Deleted" + +/* DB/Contact/SettingChanged event +Called when a contact has had one of its settings changed + wParam=(WPARAM)(HANDLE)hContact + lParam=(LPARAM)(DBCONTACTWRITESETTING*)&dbcws +hContact is a valid handle to the contact that has changed. +This event will be triggered many times rapidly when a whole bunch of values +are set. +Modules which hook this should be aware of this fact and quickly return if they +are not interested in the value that has been changed. +Careful not to get into infinite loops with this event. +The structure dbcws is the same one as is passed to the original service, so +don't change any of the members. +*/ +#define ME_DB_CONTACT_SETTINGCHANGED "DB/Contact/SettingChanged" + + +/******************************************************************/ +/********************* SETTINGS HELPER FUNCTIONS ******************/ +/******************************************************************/ + +#ifndef DB_NOHELPERFUNCTIONS + +/* hate typing the fucking jinormous names of the db "helper" functions, ffs. */ + +#define db_byte_get(a,b,c,d) DBGetContactSettingByte(a,b,c,d) +#define db_word_get(a,b,c,d) DBGetContactSettingWord(a,b,c,d) +#define db_dword_get(a,b,c,d) DBGetContactSettingDword(a,b,c,d) +#define db_get(a,b,c,d) DBGetContactSetting(a,b,c,d) + +#define db_byte_set(a,b,c,d) DBWriteContactSettingByte(a,b,c,d); +#define db_word_set(a,b,c,d) DBWriteContactSettingWord(a,b,c,d); +#define db_dword_set(a,b,c,d) DBWriteContactSettingDword(a,b,c,d); +#define db_string_set(a,b,c,d) DBWriteContactSettingString(a,b,c,d); + +#define db_unset(a,b,c) DBDeleteContactSetting(a,b,c); + +#define DBGetContactSettingByte(a,b,c,d) DBGetContactSettingByte_Helper(a,b,c,d,__FILE__,__LINE__) +#define DBGetContactSettingWord(a,b,c,d) DBGetContactSettingWord_Helper(a,b,c,d,__FILE__,__LINE__) +#define DBGetContactSettingDword(a,b,c,d) DBGetContactSettingDword_Helper(a,b,c,d,__FILE__,__LINE__) +#define DBGetContactSetting(a,b,c,d) DBGetContactSetting_Helper(a,b,c,d,__FILE__,__LINE__) +#define DBGetContactSettingW(a,b,c,d) DBGetContactSettingW_Helper(a,b,c,d,__FILE__,__LINE__) +#define DBGetContactSettingTString(a,b,c,d) DBGetContactSettingTString_Helper(a,b,c,d,__FILE__,__LINE__) +#define DBGetContactSettingWString(a,b,c,d) DBGetContactSettingWString_Helper(a,b,c,d,__FILE__,__LINE__) +#define DBGetContactSettingStringUtf(a,b,c,d) DBGetContactSettingStringUtf_Helper(a,b,c,d,__FILE__,__LINE__) + +#define db_msg_dbg(s) MessageBoxA(0,(s),"",0); + +#ifdef _DEBUG +#include +#endif + +__inline static int DBGetContactSettingByte_Helper(HANDLE hContact, const char *szModule, + const char *szSetting, int errorValue, const char *szFile, const int nLine) +{ + DBVARIANT dbv; + DBCONTACTGETSETTING cgs; + + cgs.szModule=szModule; + cgs.szSetting=szSetting; + cgs.pValue=&dbv; + if(CallService(MS_DB_CONTACT_GETSETTING,(WPARAM)hContact,(LPARAM)&cgs)) + return errorValue; +#ifdef _DEBUG + if(dbv.type!=DBVT_BYTE) { + char buf[128]; + _snprintf(buf,sizeof(buf),"%s:%d for %s/%s not a byte, return: %d",szFile,nLine,szModule,szSetting,dbv.type); + db_msg_dbg(buf); + } +#endif + return dbv.bVal; +} + +__inline static int DBGetContactSettingWord_Helper(HANDLE hContact,const char *szModule, + const char *szSetting,int errorValue,const char *szFile, const int nLine) +{ + DBVARIANT dbv; + DBCONTACTGETSETTING cgs; + + cgs.szModule=szModule; + cgs.szSetting=szSetting; + cgs.pValue=&dbv; + if(CallService(MS_DB_CONTACT_GETSETTING,(WPARAM)hContact,(LPARAM)&cgs)) + return errorValue; +#ifdef _DEBUG + if(dbv.type!=DBVT_WORD) { + char buf[128]; + _snprintf(buf,sizeof(buf),"%s:%d for %s/%s not a word, return: %d",szFile,nLine,szModule,szSetting,dbv.type); + db_msg_dbg(buf); + } +#endif + return dbv.wVal; +} + +__inline static DWORD DBGetContactSettingDword_Helper(HANDLE hContact,const char *szModule, + const char *szSetting,DWORD errorValue, const char *szFile, const int nLine) +{ + DBVARIANT dbv; + DBCONTACTGETSETTING cgs; + + cgs.szModule=szModule; + cgs.szSetting=szSetting; + cgs.pValue=&dbv; + if(CallService(MS_DB_CONTACT_GETSETTING,(WPARAM)hContact,(LPARAM)&cgs)) + return errorValue; +#ifdef _DEBUG + if(dbv.type!=DBVT_DWORD) { + char buf[128]; + _snprintf(buf,sizeof(buf),"%s:%d for %s/%s not a dword, return: %d",szFile,nLine,szModule,szSetting,dbv.type); + db_msg_dbg(buf); + } +#endif + return dbv.dVal; +} + +__inline static int DBGetContactSettingW_Helper(HANDLE hContact,const char *szModule, + const char *szSetting,DBVARIANT *dbv, const char *szFile, const int nLine) +{ + int rc; + DBCONTACTGETSETTING cgs; + cgs.szModule=szModule; + cgs.szSetting=szSetting; + cgs.pValue=dbv; + dbv->type = 0; + + rc=CallService(MS_DB_CONTACT_GETSETTING_STR,(WPARAM)hContact,(LPARAM)&cgs); +#if defined(_DEBUG) && defined(DBCHECKSETTINGS) + if (rc != 0) { + char buf[128]; + _snprintf(buf,sizeof(buf),"%s:%d failed to fetch %s/%s",szFile,nLine,szModule,szSetting); + db_msg_dbg(buf); + } +#endif + return rc; +} + +__inline static int DBGetContactSettingTString_Helper(HANDLE hContact,const char *szModule, + const char *szSetting,DBVARIANT *dbv, const char *szFile, const int nLine) +{ + int rc; + DBCONTACTGETSETTING cgs; + cgs.szModule=szModule; + cgs.szSetting=szSetting; + cgs.pValue=dbv; +#if defined(_UNICODE) + dbv->type = DBVT_WCHAR; +#else + dbv->type = DBVT_ASCIIZ; +#endif + + rc=CallService(MS_DB_CONTACT_GETSETTING_STR,(WPARAM)hContact,(LPARAM)&cgs); +#if defined(_DEBUG) && defined(DBCHECKSETTINGS) + if (rc != 0) { + char buf[128]; + _snprintf(buf,sizeof(buf),"%s:%d failed to fetch %s/%s",szFile,nLine,szModule,szSetting); + db_msg_dbg(buf); + } +#endif + return rc; +} + +__inline static int DBGetContactSettingWString_Helper(HANDLE hContact,const char *szModule, + const char *szSetting,DBVARIANT *dbv, const char *szFile, const int nLine) +{ + int rc; + DBCONTACTGETSETTING cgs; + cgs.szModule=szModule; + cgs.szSetting=szSetting; + cgs.pValue=dbv; + dbv->type = DBVT_WCHAR; + + rc=CallService(MS_DB_CONTACT_GETSETTING_STR,(WPARAM)hContact,(LPARAM)&cgs); +#if defined(_DEBUG) && defined(DBCHECKSETTINGS) + if (rc != 0) { + char buf[128]; + _snprintf(buf,sizeof(buf),"%s:%d failed to fetch %s/%s",szFile,nLine,szModule,szSetting); + db_msg_dbg(buf); + } +#endif + return rc; +} + +__inline static int DBGetContactSettingStringUtf_Helper(HANDLE hContact,const char *szModule, + const char *szSetting,DBVARIANT *dbv, const char *szFile, const int nLine) +{ + int rc; + DBCONTACTGETSETTING cgs; + cgs.szModule=szModule; + cgs.szSetting=szSetting; + cgs.pValue=dbv; + dbv->type = DBVT_UTF8; + + rc=CallService(MS_DB_CONTACT_GETSETTING_STR,(WPARAM)hContact,(LPARAM)&cgs); +#if defined(_DEBUG) && defined(DBCHECKSETTINGS) + if (rc != 0) { + char buf[128]; + _snprintf(buf,sizeof(buf),"%s:%d failed to fetch %s/%s",szFile,nLine,szModule,szSetting); + db_msg_dbg(buf); + } +#endif + return rc; +} + +__inline static int DBGetContactSetting_Helper(HANDLE hContact,const char *szModule, + const char *szSetting,DBVARIANT *dbv, const char *szFile, const int nLine) +{ + int rc; + DBCONTACTGETSETTING cgs; + cgs.szModule=szModule; + cgs.szSetting=szSetting; + cgs.pValue=dbv; + rc=CallService(MS_DB_CONTACT_GETSETTING,(WPARAM)hContact,(LPARAM)&cgs); +#if defined(_DEBUG) && defined(DBCHECKSETTINGS) + if (rc != 0) { + char buf[128]; + _snprintf(buf,sizeof(buf),"%s:%d failed to fetch %s/%s",szFile,nLine,szModule,szSetting); + db_msg_dbg(buf); + } +#endif + return rc; +} + +__inline static int DBFreeVariant(DBVARIANT *dbv) +{ + return CallService(MS_DB_CONTACT_FREEVARIANT,0,(LPARAM)dbv); +} + +__inline static int DBDeleteContactSetting(HANDLE hContact,const char *szModule,const char *szSetting) +{ + DBCONTACTGETSETTING cgs; + cgs.szModule=szModule; + cgs.szSetting=szSetting; + return CallService(MS_DB_CONTACT_DELETESETTING,(WPARAM)hContact,(LPARAM)&cgs); +} + +__inline static int DBWriteContactSettingByte(HANDLE hContact,const char *szModule,const char *szSetting,BYTE val) +{ + DBCONTACTWRITESETTING cws; + + cws.szModule=szModule; + cws.szSetting=szSetting; + cws.value.type=DBVT_BYTE; + cws.value.bVal=val; + return CallService(MS_DB_CONTACT_WRITESETTING,(WPARAM)hContact,(LPARAM)&cws); +} + +__inline static int DBWriteContactSettingWord(HANDLE hContact,const char *szModule,const char *szSetting,WORD val) +{ + DBCONTACTWRITESETTING cws; + + cws.szModule=szModule; + cws.szSetting=szSetting; + cws.value.type=DBVT_WORD; + cws.value.wVal=val; + return CallService(MS_DB_CONTACT_WRITESETTING,(WPARAM)hContact,(LPARAM)&cws); +} + +__inline static int DBWriteContactSettingDword(HANDLE hContact,const char *szModule,const char *szSetting,DWORD val) +{ + DBCONTACTWRITESETTING cws; + + cws.szModule=szModule; + cws.szSetting=szSetting; + cws.value.type=DBVT_DWORD; + cws.value.dVal=val; + return CallService(MS_DB_CONTACT_WRITESETTING,(WPARAM)hContact,(LPARAM)&cws); +} + +__inline static int DBWriteContactSettingString(HANDLE hContact,const char *szModule,const char *szSetting,const char *val) +{ + DBCONTACTWRITESETTING cws; + + cws.szModule=szModule; + cws.szSetting=szSetting; + cws.value.type=DBVT_ASCIIZ; + cws.value.pszVal=(char*)val; + return CallService(MS_DB_CONTACT_WRITESETTING,(WPARAM)hContact,(LPARAM)&cws); +} + +__inline static int DBWriteContactSettingTString(HANDLE hContact,const char *szModule,const char *szSetting,const TCHAR *val) +{ + DBCONTACTWRITESETTING cws; + + cws.szModule=szModule; + cws.szSetting=szSetting; + #if defined( _UNICODE ) + cws.value.type=DBVT_WCHAR; + cws.value.pwszVal=(WCHAR*)val; + #else + cws.value.type=DBVT_ASCIIZ; + cws.value.pszVal=(char*)val; + #endif + return CallService(MS_DB_CONTACT_WRITESETTING,(WPARAM)hContact,(LPARAM)&cws); +} + +__inline static int DBWriteContactSettingWString(HANDLE hContact,const char *szModule,const char *szSetting,const WCHAR *val) +{ + DBCONTACTWRITESETTING cws; + + cws.szModule=szModule; + cws.szSetting=szSetting; + cws.value.type=DBVT_WCHAR; + cws.value.pwszVal=(WCHAR*)val; + return CallService(MS_DB_CONTACT_WRITESETTING,(WPARAM)hContact,(LPARAM)&cws); +} + +__inline static int DBWriteContactSettingStringUtf(HANDLE hContact,const char *szModule,const char *szSetting,const char *val) +{ + DBCONTACTWRITESETTING cws; + + cws.szModule=szModule; + cws.szSetting=szSetting; + cws.value.type=DBVT_UTF8; + cws.value.pszVal=(char*)val; + return CallService(MS_DB_CONTACT_WRITESETTING,(WPARAM)hContact,(LPARAM)&cws); +} + +/* inlined range tolerate versions */ + +__inline static BYTE DBGetContactSettingRangedByte(HANDLE hContact, const char *szModule, const char *szSetting, BYTE errorValue, BYTE minValue, BYTE maxValue) { + BYTE bVal = DBGetContactSettingByte(hContact, szModule, szSetting, errorValue); + + if (bVal < minValue || bVal > maxValue) { +#ifdef _DEBUG + char szBuf[MAX_PATH]; + wsprintfA(szBuf, "(%s:%s) not in range of %d..%d", szModule,szSetting,minValue,maxValue); + MessageBoxA(0,szBuf,"DBGetContactSettingRangedByte failed",MB_ICONERROR); +#endif + return errorValue; + } + else + return bVal; +} + +__inline static WORD DBGetContactSettingRangedWord(HANDLE hContact, const char *szModule, const char *szSetting, WORD errorValue, WORD minValue, WORD maxValue) { + WORD wVal = DBGetContactSettingWord(hContact, szModule, szSetting, errorValue); + + if (wVal < minValue || wVal > maxValue) { +#ifdef _DEBUG + char szBuf[MAX_PATH]; + wsprintfA(szBuf, "(%s:%s) not in range of %d..%d", szModule,szSetting,minValue,maxValue); + MessageBoxA(0,szBuf,"DBGetContactSettingRangedWord failed",MB_ICONERROR); +#endif + return errorValue; + } + else + return wVal; +} + +__inline static DWORD DBGetContactSettingRangedDword(HANDLE hContact, const char *szModule, const char *szSetting, DWORD errorValue, DWORD minValue, DWORD maxValue) { + DWORD dVal = DBGetContactSettingDword(hContact, szModule, szSetting, errorValue); + + if (dVal < minValue || dVal > maxValue) { +#ifdef _DEBUG + char szBuf[MAX_PATH]; + wsprintfA(szBuf, "(%s:%s) not in range of %d..%d", szModule,szSetting,minValue,maxValue); + MessageBoxA(0,szBuf,"DBGetContactSettingRangedDword failed",MB_ICONERROR); +#endif + return errorValue; + } + else + return dVal; +} + +#endif + +#endif // M_DATABASE_H__ diff --git a/fingerprint_mod/include/m_icolib.h b/fingerprint_mod/include/m_icolib.h new file mode 100644 index 0000000..a80d0f4 --- /dev/null +++ b/fingerprint_mod/include/m_icolib.h @@ -0,0 +1,92 @@ +// ---------------------------------------------------------------------------80 +// Icons Library Manager plugin for Miranda Instant Messenger +// __________________________________________________________ +// +// Copyright © 2005 Denis Stanishevskiy // StDenis +// Copyright © 2006 Joe Kucera, Bio +// +// 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. +// +// ----------------------------------------------------------------------------- + +#define SKINICONDESC_SIZE sizeof(SKINICONDESC) // v0.0.1.0+ +#define SKINICONDESC_SIZE_V1 0x18 +#define SKINICONDESC_SIZE_V2 0x1C // v0.0.0.2+ +#define SKINICONDESC_SIZE_V3 0x24 // v0.0.0.3+ + +typedef struct { + int cbSize; + union { + char *pszSection; // section name used to group icons + TCHAR *ptszSection; + wchar_t *pwszSection; + }; + union { + char *pszDescription; // description for options dialog + TCHAR *ptszDescription; + wchar_t *pwszDescription; + }; + char *pszName; // name to refer to icon when playing and in db + char *pszDefaultFile; // default icon file to use + int iDefaultIndex; // index of icon in default file + HICON hDefaultIcon; // handle to default icon + int cx,cy; // dimensions of icon + int flags; // combination of SIDF_* +} SKINICONDESC; + +#define SIDF_SORTED 0x1 // Icons in section are sorted by name +#define SIDF_UNICODE 0x100 // Section and Description are in UCS-2 + +#if defined(_UNICODE) + #define SIDF_TCHAR SIDF_UNICODE +#else + #define SIDF_TCHAR 0 +#endif + +// +// Add a icon into options UI +// +// wParam = (WPARAM)0 +// lParam = (LPARAM)(SKINICONDESC*)sid; +// +#define MS_SKIN2_ADDICON "Skin2/Icons/AddIcon" + +// +// Remove a icon from options UI +// +// wParam = (WPARAM)0 +// lParam = (LPARAM)(char*)pszName +// WARNING: This will invalidate all HICONs retrieved for specified pszName +// +#define MS_SKIN2_REMOVEICON "Skin2/Icons/RemoveIcon" + +// +// Retrieve HICON with name specified in lParam +// Returned HICON SHOULDN'T be destroyed, it is managed by IcoLib +// +#define MS_SKIN2_GETICON "Skin2/Icons/GetIcon" + +// +// Retrieved HICON is not needed anymore (this helps optimize GDI usage) +// +// wParam = (WPARAM)HICON (optional) +// lParam = (LPARAM)(char*)pszName (optional) // at least one needs to be specified +// +#define MS_SKIN2_RELEASEICON "Skin2/Icons/ReleaseIcon" + +// +// Icons change notification +// +#define ME_SKIN2_ICONSCHANGED "Skin2/IconsChanged" diff --git a/fingerprint_mod/include/m_langpack.h b/fingerprint_mod/include/m_langpack.h new file mode 100644 index 0000000..cd6ebdf --- /dev/null +++ b/fingerprint_mod/include/m_langpack.h @@ -0,0 +1,94 @@ +/* + +Miranda IM: the free IM client for Microsoft* Windows* + +Copyright 2000-2003 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_LANGPACK_H__ +#define M_LANGPACK_H__ + +#define LANG_UNICODE 0x1000 + +//translates a single string into the user's local language v0.1.1.0+ +//wParam=0 +//lParam=(LPARAM)(const char*)szEnglish +//returns a pointer to the localised string. If there is no known translation +//it will return szEnglish. The return value does not need to be freed in any +//way +//Note that the Translate() macro as defined below will crash plugins that are +//loaded into Miranda 0.1.0.1 and earlier. If anyone's actually using one of +//these versions, I pity them. +#define MS_LANGPACK_TRANSLATESTRING "LangPack/TranslateString" +#define Translate(s) ((char*)CallService(MS_LANGPACK_TRANSLATESTRING,0,(LPARAM)(s))) +#define TranslateW(s) ((WCHAR*)CallService(MS_LANGPACK_TRANSLATESTRING,LANG_UNICODE,(LPARAM)(s))) +#if defined( _UNICODE ) + #define TranslateT(s) TranslateW(_T(s)) + #define TranslateTS(s) TranslateW(s) +#else + #define TranslateT(s) Translate(s) + #define TranslateTS(s) Translate(s) +#endif + +//translates a dialog into the user's local language v0.1.1.0+ +//wParam=0 +//lParam=(LPARAM)(LANGPACKTRANSLATEDIALOG*)&lptd +//returns 0 on success, nonzero on failure +//This service only knows about the following controls: +//Window titles, STATIC, EDIT, Hyperlink, BUTTON +typedef struct { + int cbSize; + DWORD flags; + HWND hwndDlg; + const int *ignoreControls; //zero-terminated list of control IDs *not* to + //translate +} LANGPACKTRANSLATEDIALOG; +#define LPTDF_NOIGNOREEDIT 1 //translate all edit controls. By default + //non-read-only edit controls are not translated +#define LPTDF_NOTITLE 2 //do not translate the title of the dialog + +#define MS_LANGPACK_TRANSLATEDIALOG "LangPack/TranslateDialog" +__inline static int TranslateDialogDefault(HWND hwndDlg) +{ + LANGPACKTRANSLATEDIALOG lptd; + lptd.cbSize=sizeof(lptd); + lptd.flags=0; + lptd.hwndDlg=hwndDlg; + lptd.ignoreControls=NULL; + return CallService(MS_LANGPACK_TRANSLATEDIALOG,0,(LPARAM)&lptd); +} + +//translates a menu into the user's local language v0.1.1.0+ +//wParam=(WPARAM)(HMENU)hMenu +//lParam=0 +//returns 0 on success, nonzero on failure +#define MS_LANGPACK_TRANSLATEMENU "LangPack/TranslateMenu" + +//returns the codepage used in the language pack v0.4.3.0+ +//wParam=0 +//lParam=0 +//returns the codepage stated in the langpack, or CP_ACP if no langpack installed +#define MS_LANGPACK_GETCODEPAGE "LangPack/GetCodePage" + +//returns the strdup/wcsdup of lparam according to the langpack v0.4.3.0+ +//wParam=0 +//lParam=(LPARAM)(char*)source string +//returns the codepage stated in the langpack, or CP_ACP if no langpack installed +#define MS_LANGPACK_PCHARTOTCHAR "LangPack/PcharToTchar" +#endif // M_LANGPACK_H__ diff --git a/fingerprint_mod/include/m_options.h b/fingerprint_mod/include/m_options.h new file mode 100644 index 0000000..fdbab5c --- /dev/null +++ b/fingerprint_mod/include/m_options.h @@ -0,0 +1,108 @@ +/* + +Miranda IM: the free IM client for Microsoft* Windows* + +Copyright 2000-2003 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_OPTIONS_H__ +#define M_OPTIONS_H__ + +/* Opt/Initialise +The user opened the options dialog. Modules should do whatever initialisation +they need and call opt/addpage one or more times if they want pages displayed +in the options dialog +wParam=addInfo +lParam=0 +addInfo should be passed straight to the wParam of opt/addpage +*/ +#define ME_OPT_INITIALISE "Opt/Initialise" + +/* Opt/AddPage +Must only be called during an opt/initialise hook +Adds a page to the options dialog +wParam=addInfo +lParam=(LPARAM)(OPTIONSDIALOGPAGE*)odp +addInfo must have come straight from the wParam of opt/initialise +Pages in the options dialog operate just like pages in property sheets. See the +Microsoft documentation for details on how they operate. +Strings in the structure can be released as soon as the service returns, but +icons must be kept around. This is not a problem if you're loading them from a +resource. +Prior to v0.1.2.1 the options dialog would resize to fit the largest page, but +since then it is fixed in size. The largest page that fits neatly is 314x240 +DLUs. +*/ +typedef struct { + int cbSize; + int position; //a position number, lower numbers are topmost + union { + char* pszTitle; + TCHAR* ptszTitle; + }; + DLGPROC pfnDlgProc; + char *pszTemplate; + HINSTANCE hInstance; + HICON hIcon; //v0.1.0.1+ + union { + char* pszGroup; //v0.1.0.1+ + TCHAR* ptszGroup; //v0.1.0.1+ + }; + int groupPosition; //v0.1.0.1+ + HICON hGroupIcon; //v0.1.0.1+ + DWORD flags; //v0.1.2.1+ + int nIDBottomSimpleControl; //v0.1.2.1+ if in simple mode the dlg will be cut off after this control, 0 to disable + int nIDRightSimpleControl; //v0.1.2.1+ if in simple mode the dlg will be cut off after this control, 0 to disable + UINT *expertOnlyControls; + int nExpertOnlyControls; //v0.1.2.1+ these controls will be hidden in simple mode. Array must remain valid for duration of dlg. +} OPTIONSDIALOGPAGE; +#define ODPF_SIMPLEONLY 1 // page is only shown when in simple mode +#define ODPF_EXPERTONLY 2 // " expert mode +#define ODPF_BOLDGROUPS 4 // give group box titles a bold font +#define ODPF_UNICODE 8 // string fields in OPTIONSDIALOGPAGE are WCHAR* + +#if defined( _UNICODE ) + #define ODPF_TCHAR ODPF_UNICODE +#else + #define ODPF_TCHAR 0 +#endif + +#define PSN_EXPERTCHANGED 2 //sent to pages via WM_NOTIFY when the expert checkbox is clicked. lParam=new state +#define PSM_ISEXPERT (WM_USER+101) //returns true/false +#define PSM_GETBOLDFONT (WM_USER+102) //returns HFONT used for group box titles +#define MS_OPT_ADDPAGE "Opt/AddPage" + +//Opens the options dialog, optionally at the specified page v0.1.2.1+ +//wParam=0 +//lParam=(LPARAM)(OPENOPTIONSDIALOG*)&ood; +//Returns 0 on success, nonzero on failure +//The behaviour if the options dialog is already open is that it will just be +//activated, the page won't be changed. This may change in the future. +typedef struct { + int cbSize; + const char *pszGroup; //set to NULL if it's a root item + const char *pszPage; //set to NULL to just open the options at no + //specific page +} OPENOPTIONSDIALOG; +#define MS_OPT_OPENOPTIONS "Opt/OpenOptions" + +#define SETTING_SHOWEXPERT_DEFAULT 1 + +#endif //M_OPTIONS_H__ + diff --git a/fingerprint_mod/include/m_plugins.h b/fingerprint_mod/include/m_plugins.h new file mode 100644 index 0000000..1159f83 --- /dev/null +++ b/fingerprint_mod/include/m_plugins.h @@ -0,0 +1,82 @@ +/* + +Miranda IM: the free IM client for Microsoft* Windows* + +Copyright 2000-2003 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_PLUGINS_H__ +#define M_PLUGINS_H__ + +/* + Undocumented: Do NOT use. + Version: 0.3.4.1+ (2004/10/04) +*/ +#define DBPE_DONE 1 +#define DBPE_CONT 0 +#define DBPE_HALT (-1) +typedef struct PLUGIN_DB_ENUM { + int cbSize; + // 0 = continue, 1 = found, -1 = stop now + int (*pfnEnumCallback) ( char * pluginname, /*DATABASELINK*/ void * link, LPARAM lParam); + LPARAM lParam; +} PLUGIN_DB_ENUM; +#define MS_PLUGINS_ENUMDBPLUGINS "Plugins/DbEnumerate" + + +#define DEFMOD_PROTOCOLICQ 1 //removed from v0.3 alpha +#define DEFMOD_PROTOCOLMSN 2 //removed from v0.1.2.0+ +#define DEFMOD_UIFINDADD 3 +#define DEFMOD_UIUSERINFO 4 +#define DEFMOD_SRMESSAGE 5 //removed from v0.3.3a (temp) +#define DEFMOD_SRURL 6 +#define DEFMOD_SREMAIL 7 +#define DEFMOD_SRAUTH 8 +#define DEFMOD_SRFILE 9 +#define DEFMOD_UIHELP 10 +#define DEFMOD_UIHISTORY 11 +//#define DEFMOD_RNDCHECKUPD 12 //removed from v0.3.1 alpha +//#define DEFMOD_RNDICQIMPORT 13 //removed from v0.3 alpha +#define DEFMOD_RNDAUTOAWAY 14 +#define DEFMOD_RNDUSERONLINE 15 +#define DEFMOD_RNDCRYPT 16 //v0.1.0.1-v0.1.2.0 +#define DEFMOD_SRAWAY 17 //v0.1.0.1+ +#define DEFMOD_RNDIGNORE 18 //v0.1.0.1+ +#define DEFMOD_UIVISIBILITY 19 //v0.1.1.0+, options page only +#define DEFMOD_UICLUI 20 //v0.1.1.0+ +//#define DEFMOD_UIPLUGINOPTS 21 //removed from 0.4.0.1 +#define DEFMOD_PROTOCOLNETLIB 22 //v0.1.2.2+ +#define DEFMOD_RNDIDLE 23 //v0.3.4a+ +#define DEFMOD_CLISTALL 24 //v0.3.4a+ (2004/09/28) +#define DEFMOD_DB 25 //v0.3.4.3+ (2004/10/11) + +#define DEFMOD_HIGHEST 25 + +//plugins/getdisabledefaultarray +//gets an array of the modules that the plugins report they want to replace +//wParam=lParam=0 +//returns a pointer to an array of ints, with elements 1 or 0 indexed by the +//DEFMOD_ constants. 1 to signify that the default module shouldn't be loaded. +//this is primarily for use by the core's module initialiser, but could also +//be used by modules that are doing naughty things that are very +//feature-dependent +#define MS_PLUGINS_GETDISABLEDEFAULTARRAY "Plugins/GetDisableDefaultArray" + +#endif // M_PLUGINS_H__ + diff --git a/fingerprint_mod/include/m_system.h b/fingerprint_mod/include/m_system.h new file mode 100644 index 0000000..188c2d3 --- /dev/null +++ b/fingerprint_mod/include/m_system.h @@ -0,0 +1,366 @@ +/* + +Miranda IM: the free IM client for Microsoft* Windows* + +Copyright 2000-2003 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_SYSTEM_H__ +#define M_SYSTEM_H__ 1 + +#ifndef MIRANDANAME +#define MIRANDANAME "Miranda IM" +#endif +#ifndef MIRANDACLASS +#define MIRANDACLASS "Miranda" +#endif + +//miranda/system/modulesloaded +//called after all modules have been successfully initialised +//wParam=lParam=0 +//used to resolve double-dependencies in the module load order +#define ME_SYSTEM_MODULESLOADED "Miranda/System/ModulesLoaded" + +//miranda/system/shutdown event +//called just before the application terminates +//the database is still guaranteed to be running during this hook. +//wParam=lParam=0 +#define ME_SYSTEM_SHUTDOWN "Miranda/System/Shutdown" + +//miranda/system/oktoexit event +//called before the app goes into shutdown routine to make sure everyone is +//happy to exit +//wParam=lParam=0 +//return nonzero to stop the exit cycle +#define ME_SYSTEM_OKTOEXIT "Miranda/System/OkToExitEvent" + +//miranda/system/oktoexit service +//Check if everyone is happy to exit +//wParam=lParam=0 +//if everyone acknowleges OK to exit then returns true, otherwise false +#define MS_SYSTEM_OKTOEXIT "Miranda/System/OkToExit" + +//gets the version number of Miranda encoded as a DWORD v0.1.0.1+ +//wParam=lParam=0 +//returns the version number, encoded as one version per byte, therefore +//version 1.2.3.10 is 0x0102030a +#define MS_SYSTEM_GETVERSION "Miranda/System/GetVersion" + +//gets the version of Miranda encoded as text v0.1.0.1+ +//wParam=cch +//lParam=(LPARAM)(char*)pszVersion +//cch is the size of the buffer pointed to by pszVersion, in bytes +//may return a build qualifier, such as "0.1.0.1 alpha" +//returns 0 on success, nonzero on failure +#define MS_SYSTEM_GETVERSIONTEXT "Miranda/System/GetVersionText" + +//Adds a HANDLE to the list to be checked in the main message loop v0.1.2.0+ +//wParam=(WPARAM)(HANDLE)hObject +//lParam=(LPARAM)(const char*)pszService +//returns 0 on success or nonzero on failure +//Causes pszService to be CallService()d (wParam=hObject,lParam=0) from the +//main thread whenever hObject is signalled. +//The Miranda message loop has a MsgWaitForMultipleObjects() call in it to +//implement this feature. See the documentation for that function for +//information on what objects are supported. +//There is a limit of MAXIMUM_WAIT_OBJECTS minus one (MWO is defined in winnt.h +//to be 64) on the number of handles MSFMO() can process. This service will +//return nonzero if that many handles are already being waited on. + +//As of writing, the following parts of Miranda are thread-safe, so can be +//called from any thread: +//All of modules.h except NotifyEventHooks() +//Read-only parts of m_database.h (since the write parts will call hooks) +//All of m_langpack.h +//for all other routines your mileage may vary, but I would strongly recommend +//that you call them from the main thread, or ask about it on plugin-dev if you +//think it really ought to work. + +//Update during 0.1.2.0 development, 16/10/01: +//NotifyEventHooks() now translates all calls into the context of the main +//thread, which means that all of m_database.h is now completely safe. + +//Update during 0.1.2.2 development, 17/4/02: +//The main thread's message loop now also deals with asynchronous procedure +//calls. Loop up QueueUserAPC() for a neater way to accomplish a lot of the +//things that used to require ms_system_waitonhandle. + +//Miranda is compiled with the multithreaded runtime - don't forget to do the +//same with your plugin. +#define MS_SYSTEM_WAITONHANDLE "Miranda/System/WaitOnHandle" + +//Removes a HANDLE from the wait list v0.1.2.0+ +//wParam=(WPARAM)(HANDLE)hObject +//lParam=0 +//returns 0 on success or nonzero on failure. +#define MS_SYSTEM_REMOVEWAIT "Miranda/System/RemoveWait" + +/* Returns Miranda's RTL/CRT function poiners to malloc() free() realloc() -- 0.1.2.2+ +This is useful for preallocation of memory for use with Miranda's services +that Miranda can free -- or reallocation of a block of memory passed with a service. +Do not use with memory unless it is explicitly expected the memory *can* +or *shall* be used in this way. the passed structure is expected to have it's .cbSize initialised + +wParam=0, lParam = (LPARAM) &MM_INTERFACE +*/ + +struct MM_INTERFACE { + int cbSize; + void* (*mmi_malloc) (size_t); + void* (*mmi_realloc) (void*, size_t); + void (*mmi_free) (void*); +}; + +#define MS_SYSTEM_GET_MMI "Miranda/System/GetMMI" + +/* Returns the pointer to the simple lists manager. +If the sortFunc member of the list gets assigned, the list becomes sorted + +wParam=0, lParam = 0 +*/ + +typedef int ( *FSortFunc )( void*, void* ); + +typedef struct +{ + void** items; + int realCount; + int limit; + int increment; + + FSortFunc sortFunc; +} + SortedList; + +struct LIST_INTERFACE { + int cbSize; + + SortedList* ( *List_Create )( int, int ); + void ( *List_Destroy )( SortedList* ); + + void* ( *List_Find )( SortedList*, void* ); + int ( *List_GetIndex )( SortedList*, void*, int* ); + int ( *List_Insert )( SortedList*, void*, int ); + int ( *List_Remove )( SortedList*, int ); + int ( *List_IndexOf )( SortedList*, void* ); +}; + +#define MS_SYSTEM_GET_LI "Miranda/System/GetLI" + +/* + + -- Thread Safety -- + + Proper thread safe shutdown was implemented in 0.3.0.0 (2003/04/18) + and not before, therefore it is improper that any MT plugins be used + with earlier versions of Miranda (as hav0c will result) + + Note: This does not apply to MT plugins which included their own + thread-safe shutdown routines. + + Shutdown thread safety works thusly: + + All new threads must call MS_SYSTEM_THREAD_PUSH and MS_SYSTEM_THREAD_POP + when they return. + + Due to the nature of thread creation, it is illegal to assume + just a call pair of MS_SYSTEM_THREAD_PUSH inside the thread will + be enough -- the source thread may only return when the new child + thread has actually executed MS_SYSTEM_THREAD_PUSH + + This is because a thread maybe in an undefined state at the point + when the thread creation routine returns, thus Miranda may exit + thinking it is safe to do so, because MS_SYSTEM_THREAD_PUSH was not + called in time. + + See miranda.c for how this can be done using an event object + which is signalled just after the MS_SYSTEM_THREAD_PUSH call is executed + and so the source thread knows that the created thread is known to Miranda. + + -- What happens when Miranda exits -- + + Miranda will firstly set an event object to signalled, this will + make MS_SYSTEM_TERMINATED return TRUE, it will then fire ME_SYSTEM_PRESHUTDOWN + at this point, no plugins or modules are unloaded. + + Miranda will then enumerate all active threads and queue an APC call + to each thread, so any thread in an alertable state will become active, + this functionailty may not be required by your threads: but if you use + the Winsock2 event object system or Sleep() please use the alertable + wait functions, so that the thread will 'wake up' when Miranda queues + a message to it, SleepEx() will return WAIT_IO_COMPLETION if this happens. + + After all threads have been signalled, Miranda will spin on the unwind thread stack waiting + for it to become empty, in this time, it will carry on processing thread + switches, clearing it's own APC calls (used by NotifyEventHooks(), CallServiceSync()) + + So a thread should be written in this kind of form: + + void mythread(void *arg) + { + // assume all thread pushing/popping is done by forkthread() + int run=1; + for (;run;) + { + Beep(4391,500); + SleepEx(1500,TRUE); + if (Miranda_Terminated()) { + Beep(5000,150); run=0; + } //if + } //for + } + + The above will make a nice Beep every 1.5 seconds and when the UI + quits, it will make a lower beep and then return. + + As many copies of this thread maybe running, the creator does not need + to worry about what to do with previous threads, as long as they're on the + unwind stack.If there are any global resources (and they're mutex) you can free() them + at Unload(), which will only be called, after all threads have returned. + + -- Summary -- + + MS_SYSTEM_TERMINATED (will start returning TRUE) + ME_SYSTEM_PRESHUTDOWN will be fired (The CList won't be visible at this point) + + All PROTOTYPE_PROTOCOL registered plugins will be sent ID_STATUS_OFFLINE + automatically. + + All the threads will be notified via QueueUserAPC() and then Miranda + will poll on the unwind thread queue until it is empty. + + ME_SYSTEM_SHUTDOWN will be fired, the database will be unloaded, the core + will be unloaded -- Miranda will return. + +*/ + +/* +wParam=0 +lParam=0 + +Add a thread to the unwind wait stack that Miranda will poll on +when it is tearing down modules. + +This must be called in the context of the thread that is to be pushed +i.e. there are no args, it works out what thread is being called +and gets itself a handle to the calling thread. + +*/ +#define MS_SYSTEM_THREAD_PUSH "Miranda/Thread/Push" + +/* +wParam=0 +lParam=0 + +Remove a thread from the unwind wait stack -- it is expected +that the call be made in the context of the thread to be removed. + +Miranda will begin to tear down modules and plugins if/when the +last thread from the unwind stack is removed. +*/ +#define MS_SYSTEM_THREAD_POP "Miranda/Thread/Pop" + +/* +wParam=0 +lParam=0 + +This hook is fired just before the thread unwind stack is used, +it allows MT plugins to shutdown threads if they have any special +processing to do, etc. + +*/ +#define ME_SYSTEM_PRESHUTDOWN "Miranda/System/PShutdown" + +/* +wParam=0 +lParam=0 + +Returns TRUE when Miranda has got WM_QUIT and is in the process +of shutting down +*/ +#define MS_SYSTEM_TERMINATED "Miranda/SysTerm" + +/* + wParam : 0 + lParam : (address) void (__cdecl *callback) (void) + Affect : Setup a function pointer to be called after main loop iterations, it allows for + idle processing, See notes + Returns: 1 on success, 0 on failure + + Notes : This service will only allow one function to be registered, if one is registered, 0 will be returned + Remember that this uses __cdecl. + Version: Added during 0.3.4+ + +*/ +#define MS_SYSTEM_SETIDLECALLBACK "Miranda/SetIdleCallback" + +/* + wParam : 0 + lParam : &tick + Affect : return the last window tick where a monitored event was seen, currently WM_CHAR/WM_MOUSEMOVE + Returns: Always returns 0 + Version: Added during 0.3.4+ (2004/09/12) +*/ +#define MS_SYSTEM_GETIDLE "Miranda/GetIdle" + +/* + wParam: cchMax (max length of buffer) + lParam: pointer to buffer to fill + Affect: Returns the build timestamp of the core, as a string of YYYYMMDDhhmmss, this service might + not exist and therefore the build is before 2004-09-30 + Returns: zero on success, non zero on failure + Version: 0.3.4a+ (2004/09/30) + DEFUNCT: This service was removed on 0.3.4.3+ (2004/11/19) use APILEVEL +*/ +#define MS_SYSTEM_GETBUILDSTRING "Miranda/GetBuildString" + +__inline static int Miranda_Terminated(void) +{ + return CallService(MS_SYSTEM_TERMINATED,0,0); +} + +__inline static void miranda_sys_free(void *ptr) +{ + if (ptr) { + struct MM_INTERFACE mm; + mm.cbSize=sizeof(struct MM_INTERFACE); + CallService(MS_SYSTEM_GET_MMI,0,(LPARAM)&mm); + mm.mmi_free(ptr); + } +} + +/* Missing service catcher +Is being called when one calls the non-existent service. +All parameters are stored in the special structure + +The event handler takes 0 as wParam and TMissingServiceParams* as lParam. + +0.4.3+ addition (2006/03/27) +*/ + +typedef struct +{ + const char* name; + WPARAM wParam; + LPARAM lParam; +} + TMissingServiceParams; + +#define ME_SYSTEM_MISSINGSERVICE "System/MissingService" + +#endif // M_SYSTEM_H diff --git a/fingerprint_mod/include/m_utils.h b/fingerprint_mod/include/m_utils.h new file mode 100644 index 0000000..b247535 --- /dev/null +++ b/fingerprint_mod/include/m_utils.h @@ -0,0 +1,325 @@ +/* + +Miranda IM: the free IM client for Microsoft* Windows* + +Copyright 2000-2003 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_UTILS_H__ +#define M_UTILS_H__ 1 + +#include + +//this entire module is v0.1.0.1+ +//this module cannot be redefined by a plugin, because it's not useful for it +//to be possible +//There are some more utility services in the database for dealing with time +//and simple string scrambling, but they are very db-orientated + +/* Opens a URL in the user's default web browser v0.1.0.1+ +wParam=bOpenInNewWindow +lParam=(LPARAM)(const char*)szUrl +returns 0 always +bOpenInNewWindow should be zero to open the URL in the browser window the user +last used, or nonzero to open in a new browser window. If there's no browser +running, one will be opened to show the URL. +*/ +#define MS_UTILS_OPENURL "Utils/OpenURL" + +/* Resizes a dialog by calling a custom routine to move the individual +controls v0.1.0.1+ +wParam=0 +lParam=(LPARAM)(UTILRESIZEDIALOG*)&urd +Returns 0 on success, or nonzero on failure +Does not support dialogtemplateex dialog boxes, and will return failure if you +try to resize one +The dialog itself should have been resized prior to calling this service +pfnResizer is called once for each control in the dialog +pfnResizer should return a combination of one rd_anchorx_ and one rd_anchory +constant +*/ +typedef struct { + int cbSize; + UINT wId; //control ID + RECT rcItem; //original control rectangle, relative to dialog + //modify in-place to specify the new position + SIZE dlgOriginalSize; //size of dialog client area in template + SIZE dlgNewSize; //current size of dialog client area +} UTILRESIZECONTROL; +typedef int (*DIALOGRESIZERPROC)(HWND hwndDlg,LPARAM lParam,UTILRESIZECONTROL *urc); +typedef struct { + int cbSize; + HWND hwndDlg; + HINSTANCE hInstance; //module containing the dialog template + LPCSTR lpTemplate; //dialog template + LPARAM lParam; //caller-defined + DIALOGRESIZERPROC pfnResizer; +} UTILRESIZEDIALOG; +#define RD_ANCHORX_CUSTOM 0 //function did everything required to the x axis, do no more processing +#define RD_ANCHORX_LEFT 0 //move the control to keep it constant distance from the left edge of the dialog +#define RD_ANCHORX_RIGHT 1 //move the control to keep it constant distance from the right edge of the dialog +#define RD_ANCHORX_WIDTH 2 //size the control to keep it constant distance from both edges of the dialog +#define RD_ANCHORX_CENTRE 4 //move the control to keep it constant distance from the centre of the dialog +#define RD_ANCHORY_CUSTOM 0 +#define RD_ANCHORY_TOP 0 +#define RD_ANCHORY_BOTTOM 8 +#define RD_ANCHORY_HEIGHT 16 +#define RD_ANCHORY_CENTRE 32 +#define MS_UTILS_RESIZEDIALOG "Utils/ResizeDialog" + +/* Gets the name of a country given its number v0.1.2.0+ +wParam=countryId +lParam=0 +Returns a pointer to the string containing the country name on success, +or NULL on failure +*/ +#define MS_UTILS_GETCOUNTRYBYNUMBER "Utils/GetCountryByNumber" + +/* Gets the full list of country IDs v0.1.2.0+ +wParam=(WPARAM)(int*)piCount +lParam=(LPARAM)(struct CountryListEntry**)ppList +Returns 0 always +Neither wParam nor lParam can be NULL. +The list is sorted alphabetically by country name, on the assumption that it's +quicker to search numbers out of order than it is to search names out of order +*/ +struct CountryListEntry { + int id; + const char *szName; +}; +#define MS_UTILS_GETCOUNTRYLIST "Utils/GetCountryList" + +/******************************* Window lists *******************************/ + +//allocate a window list v0.1.0.1+ +//wParam=lParam=0 +//returns a handle to the new window list +#define MS_UTILS_ALLOCWINDOWLIST "Utils/AllocWindowList" + +//adds a window to the specified window list v0.1.0.1+ +//wParam=0 +//lParam=(LPARAM)(WINDOWLISTENTRY*)&wle +//returns 0 on success, nonzero on failure +typedef struct { + HANDLE hList; + HWND hwnd; + HANDLE hContact; +} WINDOWLISTENTRY; +#define MS_UTILS_ADDTOWINDOWLIST "Utils/AddToWindowList" +__inline static int WindowList_Add(HANDLE hList,HWND hwnd,HANDLE hContact) { + WINDOWLISTENTRY wle; + wle.hList=hList; wle.hwnd=hwnd; wle.hContact=hContact; + return CallService(MS_UTILS_ADDTOWINDOWLIST,0,(LPARAM)&wle); +} +//removes a window from the specified window list v0.1.0.1+ +//wParam=(WPARAM)(HANDLE)hList +//lParam=(LPARAM)(HWND)hwnd +//returns 0 on success, nonzero on failure +#define MS_UTILS_REMOVEFROMWINDOWLIST "Utils/RemoveFromWindowList" +__inline static int WindowList_Remove(HANDLE hList,HWND hwnd) { + return CallService(MS_UTILS_REMOVEFROMWINDOWLIST,(WPARAM)hList,(LPARAM)hwnd); +} + +//finds a window given the hContact v0.1.0.1+ +//wParam=(WPARAM)(HANDLE)hList +//lParam=(WPARAM)(HANDLE)hContact +//returns the window handle on success, or NULL on failure +#define MS_UTILS_FINDWINDOWINLIST "Utils/FindWindowInList" +__inline static HWND WindowList_Find(HANDLE hList,HANDLE hContact) { + return (HWND)CallService(MS_UTILS_FINDWINDOWINLIST,(WPARAM)hList,(LPARAM)hContact); +} + +//broadcasts a message to all windows in a list v0.1.0.1+ +//wParam=(WPARAM)(HANDLE)hList +//lParam=(LPARAM)(MSG*)&msg +//returns 0 on success, nonzero on failure +//Only msg.message, msg.wParam and msg.lParam are used +#define MS_UTILS_BROADCASTTOWINDOWLIST "Utils/BroadcastToWindowList" +__inline static int WindowList_Broadcast(HANDLE hList,UINT message,WPARAM wParam,LPARAM lParam) { + MSG msg; + msg.message=message; msg.wParam=wParam; msg.lParam=lParam; + return CallService(MS_UTILS_BROADCASTTOWINDOWLIST,(WPARAM)hList,(LPARAM)&msg); +} + +/* + Description: Broadcast a message to all windows in the given list using PostMessage() + Version: 0.3.0.0+ + Inline helper: WindowList_BroadcastAsync + + wParam=(WPARAM)(HANDLE)hList + lParam=(LPARAM)(MSG*)&msg + + Returns 0 on success, nonzero on failure, this service does not fail, even if PostMessage() fails for whatever reason + +*/ +#define MS_UTILS_BROADCASTTOWINDOWLIST_ASYNC "Utils/BroadcastToWindowListAsync" + +__inline static int WindowList_BroadcastAsync(HANDLE hList,UINT message,WPARAM wParam,LPARAM lParam) { + MSG msg; + msg.message=message; msg.wParam=wParam; msg.lParam=lParam; + return CallService(MS_UTILS_BROADCASTTOWINDOWLIST_ASYNC,(WPARAM)hList,(LPARAM)&msg); +} + +/***************************** Hyperlink windows ********************************/ + +//there aren't any services here, because you don't need them. +#define WNDCLASS_HYPERLINK _T("Hyperlink") +//the control will obey the SS_LEFT (0), SS_CENTER (1), and SS_RIGHT (2) styles +//the control will send STN_CLICKED via WM_COMMAND when the link itself is clicked + +// Use this in a SendMessage to set the color of the url when control is enabled +// wParam=DWORD color +// lParam=not used +#define HLK_SETENABLECOLOUR (WM_USER+101) // added in 0.3.1 +// Use this in a SendMessage to set the color of the url when control is disabled +// wParam=DWORD color +// lParam=not used +#define HLK_SETDISABLECOLOUR (WM_USER+102) // added in 0.3.1 + +/***************************** Window Position Saving ***************************/ + +//saves the position of a window in the database v0.1.1.0+ +//wParam=0 +//lParam=(LPARAM)(SAVEWINDOWPOS*)&swp +//returns 0 on success, nonzero on failure +typedef struct { + HWND hwnd; + HANDLE hContact; + const char *szModule; //module name to store the setting in + const char *szNamePrefix; //text to prefix on "x", "width", etc, to form setting names +} SAVEWINDOWPOS; +#define MS_UTILS_SAVEWINDOWPOSITION "Utils/SaveWindowPos" +__inline static int Utils_SaveWindowPosition(HWND hwnd,HANDLE hContact,const char *szModule,const char *szNamePrefix) { + SAVEWINDOWPOS swp; + swp.hwnd=hwnd; swp.hContact=hContact; swp.szModule=szModule; swp.szNamePrefix=szNamePrefix; + return CallService(MS_UTILS_SAVEWINDOWPOSITION,0,(LPARAM)&swp); +} + +//restores the position of a window from the database v0.1.1.0+ +//wParam=flags +//lParam=(LPARAM)(SAVEWINDOWPOS*)&swp +//returns 0 on success, nonzero on failure +//if no position was found in the database, the function returns 1 and does +//nothing +//the NoSize version won't use stored size information: the window is left the +//same size. +#define RWPF_NOSIZE 1 //don't use stored size info: leave dialog same size +#define RWPF_NOMOVE 2 //don't use stored position +#define RWPF_NOACTIVATE 4 //show but don't activate v0.3.3.0+ +#define MS_UTILS_RESTOREWINDOWPOSITION "Utils/RestoreWindowPos" +__inline static int Utils_RestoreWindowPosition(HWND hwnd,HANDLE hContact,const char *szModule,const char *szNamePrefix) { + SAVEWINDOWPOS swp; + swp.hwnd=hwnd; swp.hContact=hContact; swp.szModule=szModule; swp.szNamePrefix=szNamePrefix; + return CallService(MS_UTILS_RESTOREWINDOWPOSITION,0,(LPARAM)&swp); +} +__inline static int Utils_RestoreWindowPositionNoSize(HWND hwnd,HANDLE hContact,const char *szModule,const char *szNamePrefix) { + SAVEWINDOWPOS swp; + swp.hwnd=hwnd; swp.hContact=hContact; swp.szModule=szModule; swp.szNamePrefix=szNamePrefix; + return CallService(MS_UTILS_RESTOREWINDOWPOSITION,RWPF_NOSIZE,(LPARAM)&swp); +} +__inline static int Utils_RestoreWindowPositionNoMove(HWND hwnd,HANDLE hContact,const char *szModule,const char *szNamePrefix) { + SAVEWINDOWPOS swp; + swp.hwnd=hwnd; swp.hContact=hContact; swp.szModule=szModule; swp.szNamePrefix=szNamePrefix; + return CallService(MS_UTILS_RESTOREWINDOWPOSITION,RWPF_NOMOVE,(LPARAM)&swp); +} + +/************************ Colour Picker Control (0.1.2.1+) **********************/ + +#define WNDCLASS_COLOURPICKER _T("ColourPicker") + +#define CPM_SETCOLOUR 0x1000 //lParam=new colour +#define CPM_GETCOLOUR 0x1001 //returns colour +#define CPM_SETDEFAULTCOLOUR 0x1002 //lParam=default, used as first custom colour +#define CPM_GETDEFAULTCOLOUR 0x1003 //returns colour +#define CPN_COLOURCHANGED 1 //sent through WM_COMMAND + +/***************************** Bitmap Filter (0.1.2.1+) *************************/ + +//Loads a bitmap v0.1.2.1+ +//wParam=0 +//lParam=(LPARAM)(const char*)filename +//returns HBITMAP on success, NULL on failure +//This function uses OleLoadPicturePath() so supports BMP, JPEG and GIF. It may +//support PNG on future versions of Windows (or XP for that matter) +//For speed, if the file extension is .bmp or .rle it'll use LoadImage() so as +//to avoid the big lag loading OLE. +//Remember to DeleteObject() when you're done +#define MS_UTILS_LOADBITMAP "Utils/LoadBitmap" + +//Gets the filter strings for use in the open file dialog v0.1.2.1+ +//wParam=cbLengthOfBuffer +//lParam=(LPARAM)(char*)pszBuffer +//Returns 0 on success, nonzero on failure +//See the MSDN under OPENFILENAME.lpstrFilter for the formatting +//An 'All Bitmaps' item is always first and 'All Files' is last. +//The returned string is already translated. +#define MS_UTILS_GETBITMAPFILTERSTRINGS "Utils/GetBitmapFilterStrings" + +//Saves a path to a relative path (from the miranda directory) +//Only saves as a relative path if the file is in the miranda directory (or +//sub directory) +//wParam=(WPARAM)(char*)pszPath +//lParam=(LPARAM)(char*)pszNewPath +//pszPath is the path to convert and pszNewPath is the buffer that +//the new path is copied too. pszNewPath MUST be of the size MAX_PATH. +//Returns numbers of chars copied. +#define MS_UTILS_PATHTORELATIVE "Utils/PathToRelative" + +//Saves a path to a absolute path (from the miranda directory) +//wParam=(WPARAM)(char*)pszPath +//lParam=(LPARAM)(char*)pszNewPath +//pszPath is the path to convert and pszNewPath is the buffer that +//the new path is copied too. pszNewPath MUST be of the size MAX_PATH. +//Returns numbers of chars copied. +#define MS_UTILS_PATHTOABSOLUTE "Utils/PathToAbsolute" + +// Added in 0.4.0.1 +// Here are some string wrappers that are more safe than the win32 versions + +static __inline int mir_snprintf(char *buffer, size_t count, const char* fmt, ...) { + va_list va; + int len; + + va_start(va, fmt); + len = _vsnprintf(buffer, count-1, fmt, va); + va_end(va); + buffer[count-1] = 0; + return len; +} + +static __inline int mir_sntprintf(TCHAR *buffer, size_t count, const TCHAR* fmt, ...) { + va_list va; + int len; + + va_start(va, fmt); + len = _vsntprintf(buffer, count-1, fmt, va); + va_end(va); + buffer[count-1] = 0; + return len; +} + +static __inline int mir_vsnprintf(char *buffer, size_t count, const char* fmt, va_list va) { + int len; + + len = _vsnprintf(buffer, count-1, fmt, va); + buffer[count-1] = 0; + return len; +} + +#endif // M_UTILS_H__ diff --git a/fingerprint_mod/include/newpluginapi.h b/fingerprint_mod/include/newpluginapi.h new file mode 100644 index 0000000..e566974 --- /dev/null +++ b/fingerprint_mod/include/newpluginapi.h @@ -0,0 +1,169 @@ +/* + +Miranda IM: the free IM client for Microsoft* Windows* + +Copyright 2000-2003 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_NEWPLUGINAPI_H__ +#define M_NEWPLUGINAPI_H__ + +#include "m_plugins.h" + +#define PLUGIN_MAKE_VERSION(a,b,c,d) (((((DWORD)(a))&0xFF)<<24)|((((DWORD)(b))&0xFF)<<16)|((((DWORD)(c))&0xFF)<<8)|(((DWORD)(d))&0xFF)) +#define MAXMODULELABELLENGTH 64 + +#if defined( _UNICODE ) + #define UNICODE_AWARE 1 +#else + #define UNICODE_AWARE 0 +#endif + +typedef struct { + int cbSize; + char *shortName; + DWORD version; + char *description; + char *author; + char *authorEmail; + char *copyright; + char *homepage; + BYTE isTransient; //leave this as 0 for now + int replacesDefaultModule; //one of the DEFMOD_ constants in m_plugins.h or zero + //if non-zero, this will supress the loading of the specified built-in module + //with the implication that this plugin provides back-end-compatible features +} PLUGININFO; + +#ifndef MODULES_H_ +typedef int (*MIRANDAHOOK)(WPARAM,LPARAM); +typedef int (*MIRANDASERVICE)(WPARAM,LPARAM); +#define CALLSERVICE_NOTFOUND ((int)0x80000000) +#endif + +//see modules.h for what all this stuff is +typedef struct { + HANDLE (*CreateHookableEvent)(const char *); + int (*DestroyHookableEvent)(HANDLE); + int (*NotifyEventHooks)(HANDLE,WPARAM,LPARAM); + HANDLE (*HookEvent)(const char *,MIRANDAHOOK); + HANDLE (*HookEventMessage)(const char *,HWND,UINT); + int (*UnhookEvent)(HANDLE); + HANDLE (*CreateServiceFunction)(const char *,MIRANDASERVICE); + HANDLE (*CreateTransientServiceFunction)(const char *,MIRANDASERVICE); + int (*DestroyServiceFunction)(HANDLE); + int (*CallService)(const char *,WPARAM,LPARAM); + int (*ServiceExists)(const char *); //v0.1.0.1+ + int (*CallServiceSync)(const char *,WPARAM,LPARAM); //v0.3.3+ + int (*CallFunctionAsync) (void (__stdcall *)(void *), void *); //v0.3.4+ + int (*SetHookDefaultForHookableEvent) (HANDLE, MIRANDAHOOK); // v0.3.4 (2004/09/15) +} PLUGINLINK; + +#ifndef MODULES_H_ +#ifndef NODEFINEDLINKFUNCTIONS +//relies on a global variable 'pluginLink' in the plugins +extern PLUGINLINK *pluginLink; +#define CreateHookableEvent(a) pluginLink->CreateHookableEvent(a) +#define DestroyHookableEvent(a) pluginLink->DestroyHookableEvent(a) +#define NotifyEventHooks(a,b,c) pluginLink->NotifyEventHooks(a,b,c) +#define HookEventMessage(a,b,c) pluginLink->HookEventMessage(a,b,c) +#define HookEvent(a,b) pluginLink->HookEvent(a,b) +#define UnhookEvent(a) pluginLink->UnhookEvent(a) +#define CreateServiceFunction(a,b) pluginLink->CreateServiceFunction(a,b) +#define CreateTransientServiceFunction(a,b) pluginLink->CreateTransientServiceFunction(a,b) +#define DestroyServiceFunction(a) pluginLink->DestroyServiceFunction(a) +#define CallService(a,b,c) pluginLink->CallService(a,b,c) +#define ServiceExists(a) pluginLink->ServiceExists(a) +#define CallServiceSync(a,b,c) pluginLink->CallServiceSync(a,b,c) +#define CallFunctionAsync(a,b) pluginLink->CallFunctionAsync(a,b) +#define SetHookDefaultForHookableEvent(a,b) pluginLink->SetHookDefaultForHookableEvent(a,b) +#endif +#endif + +/* + Database plugin stuff +*/ + +// grokHeader() error codes +#define EGROKPRF_NOERROR 0 +#define EGROKPRF_CANTREAD 1 // can't open the profile for reading +#define EGROKPRF_UNKHEADER 2 // header not supported, not a supported profile +#define EGROKPRF_VERNEWER 3 // header correct, version in profile newer than reader/writer +#define EGROKPRF_DAMAGED 4 // header/version fine, other internal data missing, damaged. + +// makeDatabase() error codes +#define EMKPRF_CREATEFAILED 1 // for some reason CreateFile() didnt like something + +typedef struct { + int cbSize; + + /* + returns what the driver can do given the flag + */ + int (*getCapability) ( int flag ); + + /* + buf: pointer to a string buffer + cch: length of buffer + shortName: if true, the driver should return a short but descriptive name, e.g. "3.xx profile" + Affect: The database plugin must return a "friendly name" into buf and not exceed cch bytes, + e.g. "Database driver for 3.xx profiles" + Returns: 0 on success, non zero on failure + */ + int (*getFriendlyName) ( char * buf, size_t cch, int shortName ); + + /* + profile: pointer to a string which contains full path + name + Affect: The database plugin should create the profile, the filepath will not exist at + the time of this call, profile will be C:\..\.dat + Note: Do not prompt the user in anyway about this operation. + Note: Do not initialise internal data structures at this point! + Returns: 0 on success, non zero on failure - error contains extended error information, see EMKPRF_* + */ + int (*makeDatabase) ( char * profile, int * error ); + + /* + profile: [in] a null terminated string to file path of selected profile + error: [in/out] pointer to an int to set with error if any + Affect: Ask the database plugin if it supports the given profile, if it does it will + return 0, if it doesnt return 1, with the error set in error -- EGROKPRF_* can be valid error + condition, most common error would be [EGROKPRF_UNKHEADER] + Note: Just because 1 is returned, doesnt mean the profile is not supported, the profile might be damaged + etc. + Returns: 0 on success, non zero on failure + */ + int (*grokHeader) ( char * profile, int * error ); + + /* + Affect: Tell the database to create all services/hooks that a 3.xx legecy database might support into link, + which is a PLUGINLINK structure + Returns: 0 on success, nonzero on failure + */ + int (*Load) ( char * profile, void * link ); + + /* + Affect: The database plugin should shutdown, unloading things from the core and freeing internal structures + Returns: 0 on success, nonzero on failure + Note: Unload() might be called even if Load() was never called, wasLoaded is set to 1 if Load() was ever called. + */ + int (*Unload) ( int wasLoaded ); + +} DATABASELINK; + +#endif // M_NEWPLUGINAPI_H__ + diff --git a/fingerprint_mod/include/win2k.h b/fingerprint_mod/include/win2k.h new file mode 100644 index 0000000..dc5ab94 --- /dev/null +++ b/fingerprint_mod/include/win2k.h @@ -0,0 +1,287 @@ +/* + +Miranda IM: the free IM client for Microsoft* Windows* + +Copyright 2000-2003 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 WIN2K_H__ +#define WIN2K_H__ 1 + +/* +This file was made to define the new constants normally provided by the windows +sdk you can get from http://www.microsoft.com/msdownload/platformsdk/sdkupdate/ +To not need to install the whole sdk you can simply comment out the following lines. +To make myself clear, you are supposed to use the sdk, this is just a work around. + +All constants are normally declared in winuser.h + +File created by Christian Kästner, and tweaked a bit by Richard Hughes*/ + +//Windows versions in order of feature presence is: +//95, NT4, 98, ME, 2000, XP +//This is chronological order of release except for ME/2000. ME is barely an +//improvement on 98. +//These macros use the above order, not release order. +#define WinVerMajor() LOBYTE(LOWORD(GetVersion())) +#define WinVerMinor() HIBYTE(LOWORD(GetVersion())) +#define IsWinVerNT() ((GetVersion()&0x80000000)==0) +// IsWinVerNT4Plus() is buggy, Windows 98 is 4.10.1998 +#define IsWinVerNT4Plus() (WinVerMajor()>=5 || WinVerMinor()>0 || IsWinVerNT()) +#define IsWinVer98Plus() (LOWORD(GetVersion())!=4) +#define IsWinVerMEPlus() (WinVerMajor()>=5 || WinVerMinor()>10) +#define IsWinVer2000Plus() (WinVerMajor()>=5) +#define IsWinVerXPPlus() (WinVerMajor()>=5 && LOWORD(GetVersion())!=5) + +// put stuff that's not apart of any SDKs but is used nonetheless + +#define SIZEOF(X) (sizeof(X)/sizeof(X[0])) + +//mii was extended for NT5/Win98, so need the old length for some stuff +#define MENUITEMINFO_V4_SIZE (offsetof(MENUITEMINFO,cch)+sizeof((*((MENUITEMINFO*)0)).cch)) + +#if _MSC_VER >= 1300 +#define NOWIN2K +#endif + +#if WINVER >= 0x501 +#define NOWIN2K +#endif + +#ifdef _MSC_VER +#define BIGI(x) x##i64 +#else +#define BIGI(x) x##LL +#endif + +#if _MSC_VER + // uxtheme.h defines + #ifndef THEMEAPI + #define WM_THEMECHANGED 0x031A // when windows changes themes + #define BP_PUSHBUTTON 1 // Push Button Type + #define PBS_NORMAL 1 + #define PBS_HOT 2 + #define PBS_PRESSED 3 + #define PBS_DISABLED 4 + #define PBS_DEFAULTED 5 + #define BP_CHECKBOX 3 // CheckBox Type + #define TP_BUTTON 1 + #define TS_NORMAL 1 + #define TS_HOT 2 + #define TS_PRESSED 3 + #define TS_DISABLED 4 + #define TS_CHECKED 5 + #define TS_HOTCHECKED 6 + #define CBS_UNCHECKEDNORMAL 1 + #define CBS_UNCHECKEDHOT 2 + #define CBS_CHECKEDNORMAL 5 + #define CBS_CHECKEDHOT 6 + #endif +#endif + +#if defined (__GNUC__) + #define SECURITY_ENTRYPOINTA "InitSecurityInterfaceA" + #define SECURITY_ENTRYPOINT SECURITY_ENTRYPOINTA + #define FreeCredentialsHandle FreeCredentialsHandle + #ifndef OPENFILENAME_SIZE_VERSION_400 + #define OPENFILENAME_SIZE_VERSION_400 sizeof(OPENFILENAME) + #endif + typedef struct tagNMKEY { + NMHDR hdr; + UINT nVKey; + UINT uFlags; + } NMKEY, *LPNMKEY; + #define ODS_HOTLIGHT 0x0040 + #define ODS_INACTIVE 0x0080 + #define SPI_GETFLATMENU 0x1022 + #define COLOR_HOTLIGHT 26 + #define COLOR_MENUBAR 30 + #define COLOR_MENUHILIGHT 29 + #define COLOR_HIGHLIGHT 13 + #define BP_PUSHBUTTON 1 // Push Button Type + #define PBS_NORMAL 1 + #define PBS_HOT 2 + #define PBS_PRESSED 3 + #define PBS_DISABLED 4 + #define PBS_DEFAULTED 5 + #define BP_CHECKBOX 3 // CheckBox Type + #define TP_BUTTON 1 + #define TS_NORMAL 1 + #define TS_HOT 2 + #define TS_PRESSED 3 + #define TS_DISABLED 4 + #define TS_CHECKED 5 + #define TS_HOTCHECKED 6 + #define CBS_UNCHECKEDNORMAL 1 + #define CBS_UNCHECKEDHOT 2 + #define CBS_CHECKEDNORMAL 5 + #define CBS_CHECKEDHOT 6 +// SDK isn't present or some older VC compiler was used, include missing things. +#elif !defined(NOWIN2K) && (!defined WS_EX_LAYERED || !defined IDC_HAND) + + #pragma message("win2k.h") + + #define INVALID_FILE_ATTRIBUTES ((DWORD)-1) + + #define PSDK_WORKAROUND + + #define MONITOR_DEFAULTTONEAREST 2 + + #ifndef EM_SETTEXTEX + #define EM_SETTEXTEX (WM_USER + 97) + #define ST_DEFAULT 0 + #define ST_KEEPUNDO 1 + #define ST_SELECTION 2 + #define ST_NEWCHARS 4 + typedef struct _settextex + { + DWORD flags; + UINT codepage; + } SETTEXTEX; + #endif + + #if(_WIN32_WINNT >= 0x0500) + #define WS_EX_LAYERED 0x00080000 + #define MIIM_STRING 0x00000040 + #define MIIM_BITMAP 0x00000080 + #define MIIM_FTYPE 0x00000100 + #define HBMMENU_CALLBACK ((HBITMAP) -1) + #define ODS_HOTLIGHT 0x0040 + #define ODS_INACTIVE 0x0080 + #define IDC_HAND MAKEINTRESOURCE(32649) + #define COLOR_HOTLIGHT 26 + #define COLOR_MENUBAR 30 + #define COLOR_MENUHILIGHT 29 + #define COLOR_HIGHLIGHT 13 + #define SPI_GETFLATMENU 0x1022 + #define TVS_NOHSCROLL 0x8000 + #define SPI_GETLISTBOXSMOOTHSCROLLING 0x1006 + #define SPI_GETHOTTRACKING 0x100E + #define BIF_NEWDIALOGSTYLE 0x0040 + #define LVS_EX_LABELTIP 0x00004000 + #define DFCS_HOT 0x1000 + #define FLASHW_TRAY 0x00000002; + typedef struct { + UINT cbSize; + HWND hwnd; + DWORD dwFlags; + UINT uCount; + DWORD dwTimeout; + } FLASHWINFO; + /* for the help plugin without the SDK */ + #define SM_XVIRTUALSCREEN 76 + #define SM_YVIRTUALSCREEN 77 + #define SM_CXVIRTUALSCREEN 78 + #define SM_CYVIRTUALSCREEN 79 + #define COLOR_HOTLIGHT 26 + #define VK_OEM_PLUS 0xBB + #define VK_OEM_MINUS 0xBD + + /* the structure only needs to be defined for VC5 or lower */ + #if _MSC_VER < 1200 + typedef struct tagLASTINPUTINFO { + UINT cbSize; + DWORD dwTime; + } LASTINPUTINFO, *PLASTINPUTINFO; + #endif /* #if _MSC_VER < 1200 */ + + #ifndef OPENFILENAME_SIZE_VERSION_400 + #define OPENFILENAME_SIZE_VERSION_400 sizeof(OPENFILENAME) + #endif + + #ifndef CCM_SETVERSION + #define CCM_SETVERSION (CCM_FIRST + 0x7) + #endif + + #define SYSRGN 4 + WINGDIAPI int WINAPI GetRandomRgn(IN HDC, IN HRGN, IN INT); + + #endif /* _WIN32_WINNT >= 0x0500 */ + + #define LWA_ALPHA 0x00000002 + #define AW_HIDE 0x00010000 + #define AW_BLEND 0x00080000 + #define SPI_GETSCREENSAVERRUNNING 114 + #define SM_CMONITORS 80 + + #ifndef AW_ACTIVATE + #define AW_ACTIVATE 0x00020000 + #define AW_SLIDE 0x00040000 + #define AW_VER_NEGATIVE 0x00000008 + #define AW_HOR_POSITIVE 0x00000001 + #endif + + #ifndef DWORD_PTR + typedef DWORD DWORD_PTR; + #endif + + #ifndef HMONITOR + DECLARE_HANDLE(HMONITOR); + typedef struct tagMONITORINFO + { + DWORD cbSize; + RECT rcMonitor; + RECT rcWork; + DWORD dwFlags; + } MONITORINFO, *LPMONITORINFO; + #endif + + + #ifndef IDropTargetHelper + #define INTERFACE IDropTargetHelper + DECLARE_INTERFACE_( IDropTargetHelper, IUnknown ) + { + // IUnknown methods + STDMETHOD (QueryInterface)(THIS_ REFIID riid, void **ppv) PURE; + STDMETHOD_(ULONG, AddRef) ( THIS ) PURE; + STDMETHOD_(ULONG, Release) ( THIS ) PURE; + + // IDropTargetHelper + STDMETHOD (DragEnter)(THIS_ HWND hwndTarget, IDataObject* pDataObject, + POINT* ppt, DWORD dwEffect) PURE; + STDMETHOD (DragLeave)(THIS) PURE; + STDMETHOD (DragOver)(THIS_ POINT* ppt, DWORD dwEffect) PURE; + STDMETHOD (Drop)(THIS_ IDataObject* pDataObject, POINT* ppt, + DWORD dwEffect) PURE; + STDMETHOD (Show)(THIS_ BOOL fShow) PURE; + + }; + #endif /* IDropTargetHelper */ + + #define WM_MENURBUTTONUP 0x0122 + +// tabsrmm uses these + +#define SES_EXTENDBACKCOLOR 4 +#define EM_SETEDITSTYLE (WM_USER + 204) +#define EM_SETSCROLLPOS (WM_USER + 222) +#define SF_USECODEPAGE 0x00000020 + +#define TreeView_SetItemState(hwndTV, hti, data, _mask) \ +{ TVITEM _TVi; \ + _TVi.mask = TVIF_STATE; \ + _TVi.hItem = hti; \ + _TVi.stateMask = _mask; \ + _TVi.state = data; \ + SendMessage((hwndTV), TVM_SETITEM, 0, (LPARAM)(TV_ITEM *)&_TVi); \ +} + +#endif /* SDK check */ +#endif // WIN2K_H__ + -- cgit v1.2.3