summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexey Kulakov <panda75@bk.ru>2012-07-28 18:35:29 +0000
committerAlexey Kulakov <panda75@bk.ru>2012-07-28 18:35:29 +0000
commit3ccd712341ed9e76252bd595c5a797d6c8ea8992 (patch)
tree14ce3d3ba5cbcbebca29c5ba618086c9fd768028
parentbe3185a374d39a8ee0f12a4e985ecca279633fff (diff)
Delphi API updates
git-svn-id: http://svn.miranda-ng.org/main/trunk@1229 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
-rw-r--r--include/delphi/m_api.pas25
-rw-r--r--include/delphi/m_core.inc15
-rw-r--r--include/delphi/m_database.inc17
-rw-r--r--include/delphi/m_db_int.inc114
-rw-r--r--include/delphi/reserve/m_newawaysys.inc (renamed from include/delphi/m_newawaysys.inc)0
-rw-r--r--include/delphi/reserve/m_statusplugins.inc10
6 files changed, 144 insertions, 37 deletions
diff --git a/include/delphi/m_api.pas b/include/delphi/m_api.pas
index 133d3cf8b1..92c39c164d 100644
--- a/include/delphi/m_api.pas
+++ b/include/delphi/m_api.pas
@@ -156,18 +156,21 @@ const
}
ME_SYSTEM_MODULEUNLOAD:pAnsiChar = 'Miranda/System/UnloadModule';
- { Database plugin stuff }
-
- // grokHeader() error codes
+{
+ Each service mode plugin must implement MS_SERVICEMODE_LAUNCH
+ This service might return one of the following values:
+ SERVICE_CONTINUE - load Miranda normally, like there's no service plugins at all
+ SERVICE_ONLYDB - load database and then execute service plugin only
+ SERVICE_MONOPOLY - execute only service plugin, even without database
+ SERVICE_FAILED - terminate Miranda execution
+}
const
- 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
+ SERVICE_CONTINUE = 0;
+ SERVICE_ONLYDB = 1;
+ SERVICE_MONOPOLY = 2;
+ SERVICE_FAILED = (-1);
+ MS_SERVICEMODE_LAUNCH:PansiChar = 'ServiceMode/Launch';
{-- end newpluginapi --}
@@ -242,8 +245,6 @@ var
{$include m_timezones.inc}
{$include m_crypto.inc}
- {$include m_newawaysys.inc}
-
implementation
const
diff --git a/include/delphi/m_core.inc b/include/delphi/m_core.inc
index 4a7b6480f0..1923840366 100644
--- a/include/delphi/m_core.inc
+++ b/include/delphi/m_core.inc
@@ -28,6 +28,16 @@ const
CoreDLL = 'mir_core.dll';
///////////////////////////////////////////////////////////////////////////////
+// command line support
+
+// Parse ptszCmdLine. it must NOT be a constant (content will be patched)
+procedure CmdLine_Parse(ptszCmdLine:PWideChar); stdcall;
+ external CoreDLL name 'CmdLine_Parse';
+
+function CmdLine_GetOption(ptszParameter:PWideChar):PWideChar; stdcall;
+ external CoreDLL name 'CmdLine_GetOption';
+
+///////////////////////////////////////////////////////////////////////////////
// database functions
const
@@ -530,6 +540,9 @@ function Utf8EncodeW(const src:PWideChar):PAnsiChar;stdcall;
function Ucs2toUtf8Len(const src:pWideChar):int; stdcall;
external CoreDLL name 'Ucs2toUtf8Len';
+
+function Utf8CheckString(const astr:PAnsiChar):bool;stdcall;
+ external CoreDLL name 'Utf8CheckString';
}
// aliases
function mir_utf8decode(str:PAnsiChar; var ucs2:pWideChar):PAnsiChar;stdcall;
@@ -550,6 +563,8 @@ function mir_utf8encodew(const src:PWideChar):PAnsiChar;stdcall;
function mir_utf8lenW(const src:pWideChar):int; stdcall;
external CoreDLL name 'Ucs2toUtf8Len';
+function mir_utf8checkstring(const astr:PAnsiChar):bool;stdcall;
+ external CoreDLL name 'Utf8CheckString';
///////////////////////////////////////////////////////////////////////////////
diff --git a/include/delphi/m_database.inc b/include/delphi/m_database.inc
index 5ce91df2b3..784610fe3b 100644
--- a/include/delphi/m_database.inc
+++ b/include/delphi/m_database.inc
@@ -26,6 +26,23 @@ const
MS_DB_GETPROFILEPATH :PAnsiChar = 'DB/GetProfilePath';
MS_DB_GETPROFILEPATHW:PAnsiChar = 'DB/GetProfilePathW';
+ {
+ Sets the default profile name programmatically
+ Analog of Database/DefaultProfile in mirandaboot.ini
+ wParam = (WPARAM)(TCHAR*)ptszProfileName
+ lParam = 0 (unused)
+ }
+ MS_DB_SETDEFAULTPROFILE:PAnsiChar = 'DB/SetDefaultProfile';
+
+ {
+ Checks the specified profile like dbtool did.
+ Implemented in the dbchecker plugins, thus it might not exist
+ wParam = (WPARAM)(TCHAR*)ptszProfileName
+ lParam = 0 (unused)
+ }
+
+ MS_DB_CHECKPROFILE:PAnsiChar = 'DB/CheckProfile';
+
type
PDBCONTACTGETSETTING = ^TDBCONTACTGETSETTING;
TDBCONTACTGETSETTING = record
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}
diff --git a/include/delphi/m_newawaysys.inc b/include/delphi/reserve/m_newawaysys.inc
index 1a12135d0b..1a12135d0b 100644
--- a/include/delphi/m_newawaysys.inc
+++ b/include/delphi/reserve/m_newawaysys.inc
diff --git a/include/delphi/reserve/m_statusplugins.inc b/include/delphi/reserve/m_statusplugins.inc
index a638dd1f24..5925be2d6a 100644
--- a/include/delphi/reserve/m_statusplugins.inc
+++ b/include/delphi/reserve/m_statusplugins.inc
@@ -25,10 +25,10 @@
type
PROTOCOLSETTINGEX = record
cbSize :integer;
- szName :PAnsiChar; // pointer to protocol modulename
- szMsg :PAnsiChar; // pointer to the status message (may be NULL)
- status :word; // the status
- lastStatus:word; // last status
+ szName :PAnsiChar; // pointer to protocol modulename
+ szMsg :TChar; // pointer to the status message (may be NULL)
+ status :word; // the status
+ lastStatus:word; // last status
tszAccName:TChar;
end;
@@ -160,7 +160,7 @@ const
// returns 0
MS_KS_ANNOUNCESTATUSCHANGE:PAnsiChar = 'KeepStatus/AnnounceStatusChange';
-function announce_status_change(szProto:PAnsiChar;newstatus:integer;szMsg:PAnsiChar):integer;// cdecl;
+function announce_status_change(szProto:PAnsiChar;newstatus:integer;szMsg:TChar):integer;// cdecl;
var
ps:PROTOCOLSETTINGEX;
begin