diff options
author | Alexey Kulakov <panda75@bk.ru> | 2012-07-28 18:35:29 +0000 |
---|---|---|
committer | Alexey Kulakov <panda75@bk.ru> | 2012-07-28 18:35:29 +0000 |
commit | 3ccd712341ed9e76252bd595c5a797d6c8ea8992 (patch) | |
tree | 14ce3d3ba5cbcbebca29c5ba618086c9fd768028 /include/delphi/m_db_int.inc | |
parent | be3185a374d39a8ee0f12a4e985ecca279633fff (diff) |
Delphi API updates
git-svn-id: http://svn.miranda-ng.org/main/trunk@1229 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'include/delphi/m_db_int.inc')
-rw-r--r-- | include/delphi/m_db_int.inc | 114 |
1 files changed, 94 insertions, 20 deletions
diff --git a/include/delphi/m_db_int.inc b/include/delphi/m_db_int.inc index 979ee2cb14..f00489ac5d 100644 --- a/include/delphi/m_db_int.inc +++ b/include/delphi/m_db_int.inc @@ -24,6 +24,8 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. {$IFNDEF M_DB_INT}
{$DEFINE M_DB_INT}
+///////////////////////////////////////////////////////////////////////////////
+// basic database interface
type
PMIDatabase = ^TMIDatabase;
TMIDatabase = interface
@@ -63,32 +65,71 @@ type function EnumResidentSettings(pFunc:TDBMODULEENUMPROC; pParam:pointer):bool; stdcall;
end;
+///////////////////////////////////////////////////////////////////////////////
+// basic database checker interface
+
+const
+ STATUS_MESSAGE = 0;
+ STATUS_WARNING = 1;
+ STATUS_ERROR = 2;
+ STATUS_FATAL = 3;
+ STATUS_SUCCESS = 4;
+
+type
+ pDBCHeckCallback = ^tDBCHeckCallback;
+ tDBCHeckCallback = record
+ cbSize:int;
+ spaceProcessed,
+ spaceUsed: dword;
+ hOutFile:THANDLE;
+ bCheckOnly,
+ bBackup,
+ bAggressive,
+ bEraseHistory,
+ bMarkRead,
+ bConvertUtf:int;
+ pfnAddLogMessage: procedure(_type:int; const szFormat:PWideChar{;...}); cdecl;
+ end;
+
+type
+ PMIDatabaseChecker = ^MIDatabaseChecker;
+ MIDatabaseChecker = interface
+ function Start(callback:PDBCHeckCallback):bool;stdcall;
+ function CheckDb(phase:int; firstTime:int):bool; stdcall;
+ procedure Destroy(); stdcall;
+ end;
+
+///////////////////////////////////////////////////////////////////////////////
+// Each database plugin should register itself using this structure
+
+
+{
+ Codes for DATABASELINK functions
+}
+const
+// grokHeader() error codes
+ EGROKPRF_NOERROR = 0;
+ EGROKPRF_CANTREAD = 1; // can't open the profile for reading
+ EGROKPRF_UNKHEADER = 2; // header not supported, not a supported profile
+ EGROKPRF_VERNEWER = 3; // header correct, version in profile newer than reader/writer
+ EGROKPRF_DAMAGED = 4; // header/version fine, other internal data missing, damaged.
+
+// makeDatabase() error codes
+ EMKPRF_CREATEFAILED = 1; // for some reason CreateFile() didnt like something
+
type
PDATABASELINK = ^TDATABASELINK;
TDATABASELINK = record
cbSize : int;
- {
- returns what the driver can do given the flag
- }
- getCapability : function (flag:int):int; cdecl;
- {
- 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
- }
- getFriendlyName : function (buf:TChar; cch:size_t; shortName:int):int; cdecl;
+ szShortName:PAnsiChar; // uniqie short database name
+ szFullName:TChar; // in English, auto-translated by the core
{
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:\..\<name>.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_
}
- makeDatabase : function (profile:TChar; error:Pint):int; cdecl;
+ makeDatabase : function (const profile:TChar):int; cdecl;
{
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
@@ -99,18 +140,51 @@ type etc.
Returns: 0 on success, non zero on failure
}
- grokHeader : function (profile:TChar; error:Pint):int; cdecl;
+ grokHeader : function (const profile:TChar):int; cdecl;
{
- Affect: Tell the database to create all services/hooks that a 3.xx legecy database might support into link
+ Affect: Tell the database to create all services/hooks that a 3.xx legacy database might support into link,
+ which is a DATABASELINK structure
Returns: 0 on success, nonzero on failure
}
- Load : function (profile:TChar):PMIDatabase; cdecl;
+ Load : function (const profile:TChar):PMIDatabase; cdecl;
{
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.
}
- Unload : function (wasLoaded:int):int; cdecl;
+ Unload : function (db:PMIDatabase):int; cdecl;
+ {
+ Returns a pointer to the database checker or NULL if a database doesn't support checking
+ When you don't need this object aanymore, call its Destroy() method
+ }
+ CheckDB : function (const profile:PWideChar; error:pint):PMIDatabaseChecker;cdecl;
end;
+///////////////////////////////////////////////////////////////////////////////
+// Database list's services
+
+const
+{
+ MS_DB_REGISTER_PLUGIN : registers a database plugin
+ wParam : 0 (unused)
+ lParam : DATABASELINK* = database link description
+}
+ MS_DB_REGISTER_PLUGIN:PAnsiChar = 'DB/RegisterPlugin';
+
+{
+ MS_DB_FIND_PLUGIN : looks for a database plugin suitable to open this file
+ wParam : 0 (unused)
+ lParam : const TCHAR* = name of the database file
+ returns DATABASELINK* of the required plugin or NULL on error
+}
+ MS_DB_FIND_PLUGIN:PAnsiChar = 'DB/FindPlugin';
+
+{
+ MS_DB_GET_CURRENT : returns the database pointer for the current profile
+ wParam : 0 (unused)
+ lParam : 0 (unused)
+ returns MIDatabase* of the current profile or NULL on error
+}
+ MS_DB_GET_CURRENT:PAnsiChar = 'DB/GetCurrentDb';
+
{$ENDIF}
|