summaryrefslogtreecommitdiff
path: root/src/sysync/binfileimplclient.cpp
diff options
context:
space:
mode:
authorLukas Zeller <luz@synthesis.ch>2009-09-08 18:47:33 +0200
committerLukas Zeller <luz@synthesis.ch>2009-09-08 18:47:33 +0200
commite8e71841cd631a4ae7f2b227788efb3b40ffee9d (patch)
treed5558a74f188471cc53711b8bca1ef62f86e30d4 /src/sysync/binfileimplclient.cpp
parentef74e86835d4893ab58dfde2f30ca707096013bd (diff)
DBAPI_TUNNEL_SUPPORT: Implemented now. This allows directly accessing data items from the main application (e.g. for test)
if DBAPI_TUNNEL_SUPPORT is defined in target_options.h, the engine allows the application to start a pseudo-session that allows accessing any sync-enabled datastore through the engine. The data takes the same way as when read or written during a SyncML session. At the API level, items are presented in the internal "item" format based on the configured <fieldlist>. These items can be accessed on a field level using GetValue/SetValue or in a serialized key:value text format. These are exactly the same mechanisms as used in the DB plugin API. A "tunnel session" always accesses only one datastore. It is started by passing SESSIONSEL_DBAPI_TUNNEL as aSelector argument and a datastore name as aSessionName to OpenSession(). The resulting SessionH can then be used to call the StartDataRead, ReadNextItem(AsKey), ReadItem(asKey), EndDataRead, StartDataWrite, InsertItem(AsKey), UpdateItem(AsKey), DeleteItem. The allowed usage of these routines is the same as described for a DB API plugin in the SDK manual, i.e. StartDataRead() must be first, and before any writing operation StartDataWrite() must be called, etc. For the routines that require a aItemKey passed in, the session key (obtained by OpenSessionKey) can be queried for it's "tunnel/item" subkey. The "tunnel/itemtype" value can be read and written to determine the datatype used for the item (it defaults to the datastore's preferred send type).
Diffstat (limited to 'src/sysync/binfileimplclient.cpp')
-rwxr-xr-xsrc/sysync/binfileimplclient.cpp23
1 files changed, 15 insertions, 8 deletions
diff --git a/src/sysync/binfileimplclient.cpp b/src/sysync/binfileimplclient.cpp
index ff973d9..5bb6b2f 100755
--- a/src/sysync/binfileimplclient.cpp
+++ b/src/sysync/binfileimplclient.cpp
@@ -842,7 +842,7 @@ static TSyError writeGlobalFeatureCheck(
? LOCERR_OK : DB_NoContent;
} // writeGlobalFeatureCheck
-// - write a feature number (APPFTR_xxx), if works ok, feature is available, otherwise not
+// - write provisioning string
static TSyError writeProvisioningString(
TStructFieldsKey *aStructFieldsKeyP, const TStructFieldInfo *aFldInfoP,
cAppPointer aBuffer, memSize aValSize
@@ -1089,7 +1089,7 @@ TBinfileLogsKey::TBinfileLogsKey(TEngineInterface *aEngineInterfaceP) :
fBinfileClientConfigP->getBinFilesPath(filepath);
filepath += LOGFILE_DB_NAME;
// - try to open
- fLogFile.setFileInfo(filepath.c_str(),LOGFILE_DB_VERSION,LOGFILE_DB_ID);
+ fLogFile.setFileInfo(filepath.c_str(),LOGFILE_DB_VERSION,LOGFILE_DB_ID,sizeof(TLogFileEntry));
fLogFile.open(0,NULL,NULL);
// Note: errors are not checked here, as no logfile is ok. We'll check before trying to read with isOpen()
} // TBinfileLogsKey::TBinfileLogsKey
@@ -1390,7 +1390,7 @@ localstatus TBinfileClientConfig::openSettingsDatabases(bool aDoLoose)
bferr err;
// - profiles
usedpath=basepath + PROFILE_DB_NAME;
- fProfileBinFile.setFileInfo(usedpath.c_str(),PROFILE_DB_VERSION,PROFILE_DB_ID);
+ fProfileBinFile.setFileInfo(usedpath.c_str(),PROFILE_DB_VERSION,PROFILE_DB_ID,sizeof(TBinfileDBSyncProfile));
err = fProfileBinFile.open(0,NULL,profileUpdateFunc);
if (err!=BFE_OK) {
// create new one or overwrite incompatible one if allowed
@@ -1405,7 +1405,7 @@ localstatus TBinfileClientConfig::openSettingsDatabases(bool aDoLoose)
}
// - targets
usedpath=basepath + TARGETS_DB_NAME;
- fTargetsBinFile.setFileInfo(usedpath.c_str(),TARGETS_DB_VERSION,TARGETS_DB_ID);
+ fTargetsBinFile.setFileInfo(usedpath.c_str(),TARGETS_DB_VERSION,TARGETS_DB_ID,sizeof(TBinfileDBSyncTarget));
err = fTargetsBinFile.open(0,NULL,targetUpdateFunc);
if (err!=BFE_OK || newprofiles) {
// create new one or overwrite incompatible one
@@ -2238,19 +2238,19 @@ void TBinfileClientConfig::cleanChangeLogForDBname(cAppCharP aDBName)
getBinFilesPath(filename);
filename += aDBName;
filename += CHANGELOG_DB_SUFFIX;
- binfile.setFileInfo(filename.c_str(),CHANGELOG_DB_VERSION,CHANGELOG_DB_ID);
+ binfile.setFileInfo(filename.c_str(),CHANGELOG_DB_VERSION,CHANGELOG_DB_ID,0);
binfile.closeAndDelete();
// delete pending maps
getBinFilesPath(filename);
filename += aDBName;
filename += PENDINGMAP_DB_SUFFIX;
- binfile.setFileInfo(filename.c_str(),PENDINGMAP_DB_VERSION,PENDINGMAP_DB_ID);
+ binfile.setFileInfo(filename.c_str(),PENDINGMAP_DB_VERSION,PENDINGMAP_DB_ID,0);
binfile.closeAndDelete();
// delete pending item
getBinFilesPath(filename);
filename += aDBName;
filename += PENDINGITEM_DB_SUFFIX;
- binfile.setFileInfo(filename.c_str(),PENDINGITEM_DB_VERSION,PENDINGITEM_DB_ID);
+ binfile.setFileInfo(filename.c_str(),PENDINGITEM_DB_VERSION,PENDINGITEM_DB_ID,0);
binfile.closeAndDelete();
} // TBinfileClientConfig::cleanChangeLogForDBname
@@ -2563,7 +2563,12 @@ const char * const Protocol_Names[num_transp_protos] = {
localstatus TBinfileImplClient::SelectProfile(uInt32 aProfileSelector, bool aAutoSyncSession)
{
uInt32 recidx,maxidx;
-
+
+ // detect special tunnel session's selection
+ bool tunnel = aProfileSelector==TUNNEL_PROFILE_ID;
+ if (tunnel) {
+ aProfileSelector=DEFAULT_PROFILE_ID;
+ }
// Note: profile database has already been opened in config resolve()
if (aProfileSelector==DEFAULT_PROFILE_ID) {
// default is first one
@@ -2667,6 +2672,8 @@ localstatus TBinfileImplClient::SelectProfile(uInt32 aProfileSelector, bool aAut
// Reset session after profile change (especially fRemoteURI)
// and also remove any datastores we might have
ResetAndRemoveDatastores();
+ // in case of tunnel, don't touch datastores
+ if (tunnel) return LOCERR_OK;
// Now iterate trough associated target records and create datastores
maxidx=fConfigP->fTargetsBinFile.getNumRecords();
TBinfileDBSyncTarget target;