summaryrefslogtreecommitdiff
path: root/src/sysync_SDK/Sources/enginemodulebridge.cpp
blob: eeaa0ded7bc141eefa94f12f5352e80cb36d5ad1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
/*
 *  File:    enginemodulebridge.cpp
 *
 *  Author:  Beat Forster (bfo@synthesis.ch)
 *
 *
 *  Synthesis SyncML client test connector
 *
 *  Copyright (c) 2007-2009 by Synthesis AG (www.synthesis.ch)
 *
 *
 */


#include "enginemodulebridge.h"  // include the interface file and utilities
#include "SDK_util.h"
#include "UI_util.h"


namespace sysync {


// local name
#define MyName "enginemodulebridge"



// --------------------------------------------------------------
TEngineModuleBridge::TEngineModuleBridge() {
  fDLL= NULL;
  fIsServer= false;
} // constructor


TEngineModuleBridge::~TEngineModuleBridge() {
  Term();
} // destructor



// --------------------------------------------------------------
TSyError TEngineModuleBridge::Init()
{
  TSyError err= UI_Connect( fCI, fDLL, fIsServer, fEngineName.c_str(), fPrgVersion, fDebugFlags );
  return   err;
} // Init


TSyError TEngineModuleBridge::Term()
{
  TSyError   err= LOCERR_OK;
  if (fCI) { err= UI_Disconnect( fCI, fDLL, fIsServer ); fCI= NULL; }
  return     err;
} // Term


// --------------------------------------------------------------
TSyError TEngineModuleBridge::SetStringMode( uInt16 aCharSet,
                                             uInt16 aLineEndMode, bool aBigEndian )
{
  SetStringMode_Func  p= fCI->ui.SetStringMode;  if (!p) return LOCERR_NOTIMP;
  return              p( fCI, aCharSet, aLineEndMode, aBigEndian );
} // SetStringMode


TSyError TEngineModuleBridge::InitEngineXML( cAppCharP aConfigXML )
{
  InitEngineXML_Func  p= fCI->ui.InitEngineXML;  if (!p) return LOCERR_NOTIMP;
  return              p( fCI, aConfigXML );
} // InitEngineXML


TSyError TEngineModuleBridge::InitEngineFile( cAppCharP aConfigFilePath )
{
  InitEngineFile_Func p= fCI->ui.InitEngineFile; if (!p) return LOCERR_NOTIMP;
  return              p( fCI, aConfigFilePath );
} // InitEngineFile


TSyError TEngineModuleBridge::InitEngineCB( TXMLConfigReadFunc aReaderFunc, void* aContext )
{
  InitEngineCB_Func   p= fCI->ui.InitEngineCB;   if (!p) return LOCERR_NOTIMP;
  return              p( fCI, aReaderFunc, aContext );
} // InitEngineCB



// --------------------------------------------------------------
TSyError TEngineModuleBridge::OpenSession( SessionH &aSessionH, uInt32 aSelector,
                                           cAppCharP aSessionName )
{
  OpenSession_Func       p= fCI->ui.OpenSession;       if (!p) return LOCERR_NOTIMP;
  return                 p( fCI, &aSessionH, aSelector, aSessionName );
} // OpenSession


TSyError TEngineModuleBridge::OpenSessionKey( SessionH aSessionH,
                                              KeyH &aKeyH, uInt16 aMode )
{
  OpenSessionKey_Func    p= fCI->ui.OpenSessionKey;    if (!p) return LOCERR_NOTIMP;
  return                 p( fCI, aSessionH, &aKeyH, aMode );
} // OpenSessionKey


TSyError TEngineModuleBridge::SessionStep( SessionH aSessionH, uInt16 &aStepCmd,
                                           TEngineProgressInfo *aInfoP )
{
  SessionStep_Func       p= fCI->ui.SessionStep;       if (!p) return LOCERR_NOTIMP;
  return                 p( fCI, aSessionH, &aStepCmd, aInfoP );
} // SessionStep


TSyError TEngineModuleBridge::GetSyncMLBuffer( SessionH aSessionH,  bool  aForSend,
                                               appPointer &aBuffer, memSize &aBufSize )
{
  GetSyncMLBuffer_Func   p= fCI->ui.GetSyncMLBuffer;   if (!p) return LOCERR_NOTIMP;
  return                 p( fCI, aSessionH, aForSend, &aBuffer, &aBufSize );
} // GetSyncMLBuffer


TSyError TEngineModuleBridge::RetSyncMLBuffer( SessionH aSessionH, bool aForSend,
                                               memSize aRetSize )
{
  RetSyncMLBuffer_Func   p= fCI->ui.RetSyncMLBuffer;   if (!p) return LOCERR_NOTIMP;
  return                 p( fCI, aSessionH, aForSend, aRetSize );
} // RetSyncMLBuffer


TSyError TEngineModuleBridge::ReadSyncMLBuffer( SessionH aSessionH,
                                                appPointer aBuffer, memSize  aBufSize,
                                                                    memSize &aValSize )
{
  ReadSyncMLBuffer_Func  p= fCI->ui.ReadSyncMLBuffer;  if (!p) return LOCERR_NOTIMP;
  return                 p( fCI, aSessionH, aBuffer, aBufSize, &aValSize );
} // ReadSyncMLBuffer


TSyError TEngineModuleBridge::WriteSyncMLBuffer( SessionH aSessionH,
                                                 appPointer aBuffer, memSize aValSize )
{
  WriteSyncMLBuffer_Func p= fCI->ui.WriteSyncMLBuffer; if (!p) return LOCERR_NOTIMP;
  return                 p( fCI, aSessionH, aBuffer, aValSize );
} // WriteSyncMLBuffer


TSyError TEngineModuleBridge::CloseSession( SessionH aSessionH )
{
  CloseSession_Func      p= fCI->ui.CloseSession;      if (!p) return LOCERR_NOTIMP;
  return                 p( fCI, aSessionH );
} // CloseSession



// --------------------------------------------------------------
TSyError TEngineModuleBridge::OpenKeyByPath( KeyH &aKeyH,
                                             KeyH aParentKeyH, cAppCharP aPath,
                                             uInt16 aMode )
{
  OpenKeyByPath_Func p= fCI->ui.OpenKeyByPath; if (!p) return LOCERR_NOTIMP;
  return             p( fCI, &aKeyH, aParentKeyH, aPath, aMode );
} // OpenKeyByPath


TSyError TEngineModuleBridge::OpenSubkey( KeyH &aKeyH,
                                          KeyH aParentKeyH, sInt32 aID,
                                          uInt16 aMode )
{
  OpenSubkey_Func    p= fCI->ui.OpenSubkey;    if (!p) return LOCERR_NOTIMP;
  return             p( fCI, &aKeyH, aParentKeyH, aID, aMode );
} // OpenSubKey


TSyError TEngineModuleBridge::DeleteSubkey( KeyH aParentKeyH, sInt32 aID )
{
  DeleteSubkey_Func  p= fCI->ui.DeleteSubkey;  if (!p) return LOCERR_NOTIMP;
  return             p( fCI, aParentKeyH, aID );
} // DeleteSubkey


TSyError TEngineModuleBridge::GetKeyID( KeyH aKeyH, sInt32 &aID )
{
  GetKeyID_Func      p= fCI->ui.GetKeyID;      if (!p) return LOCERR_NOTIMP;
  return             p( fCI, aKeyH, &aID );
} // GetKeyID


TSyError TEngineModuleBridge::SetTextMode( KeyH aKeyH, uInt16 aCharSet, uInt16 aLineEndMode,
                                           bool aBigEndian )
{
  SetTextMode_Func   p= fCI->ui.SetTextMode;   if (!p) return LOCERR_NOTIMP;
  return             p( fCI, aKeyH, aCharSet, aLineEndMode, aBigEndian );
} // SetTextMode


TSyError TEngineModuleBridge::SetTimeMode( KeyH aKeyH, uInt16 aTimeMode )
{
  SetTimeMode_Func   p= fCI->ui.SetTimeMode;   if (!p) return LOCERR_NOTIMP;
  return             p( fCI, aKeyH, aTimeMode );
} // SetTimeMode


TSyError TEngineModuleBridge::CloseKey( KeyH aKeyH )
{
  CloseKey_Func      p= fCI->ui.CloseKey;      if (!p) return LOCERR_NOTIMP;
  return             p( fCI, aKeyH );
} // CloseKey



// --------------------------------------------------------------
TSyError TEngineModuleBridge::GetValue( KeyH aKeyH, cAppCharP aValName,  uInt16  aValType,
                                  appPointer aBuffer, memSize aBufSize, memSize &aValSize )
{
  GetValue_Func     p= fCI->ui.GetValue;     if (!p) return LOCERR_NOTIMP;
  return            p( fCI, aKeyH, aValName, aValType, aBuffer,aBufSize,&aValSize );
} // GetValue


TSyError TEngineModuleBridge::GetValueByID( KeyH aKeyH,    sInt32 aID,       sInt32  arrIndex,
                                                                             uInt16  aValType,
                                      appPointer aBuffer, memSize aBufSize, memSize &aValSize )
{
  GetValueByID_Func p= fCI->ui.GetValueByID; if (!p) return LOCERR_NOTIMP;
  return            p( fCI, aKeyH, aID, arrIndex, aValType, aBuffer,aBufSize,&aValSize );
} // GetValueByID


sInt32   TEngineModuleBridge::GetValueID( KeyH aKeyH, cAppCharP aName )
{
  GetValueID_Func   p= fCI->ui.GetValueID;   if (!p) return 0;
  return            p( fCI, aKeyH, aName );
} // GetValueID


TSyError TEngineModuleBridge::SetValue( KeyH aKeyH, cAppCharP aValName, uInt16 aValType,
                                 cAppPointer aBuffer, memSize aValSize )
{
  SetValue_Func     p= fCI->ui.SetValue;     if (!p) return LOCERR_NOTIMP;
  return            p( fCI, aKeyH, aValName, aValType, aBuffer,aValSize );
} // SetValue


TSyError TEngineModuleBridge::SetValueByID( KeyH aKeyH,    sInt32 aID, sInt32 arrIndex,
                                                           uInt16 aValType,
                                     cAppPointer aBuffer, memSize aValSize )
{
  SetValueByID_Func p= fCI->ui.SetValueByID; if (!p) return LOCERR_NOTIMP;
  return            p( fCI, aKeyH, aID, arrIndex, aValType, aBuffer,aValSize );
} // SetValueByID



// ---- tunnel functions -----------------------------------------------------------------
TSyError TEngineModuleBridge::StartDataRead( SessionH aContext, cAppCharP   lastToken,
                                                                cAppCharP resumeToken )
{
  SDR_Func     p= fCI->dt.StartDataRead; if (!p) return LOCERR_NOTIMP;
  return       p( (CContext)aContext, lastToken, resumeToken );
} // StartDataRead


TSyError TEngineModuleBridge::ReadNextItem( SessionH aContext, ItemID  aID, appCharP *aItemData,
                                                               sInt32 *aStatus, bool  aFirst )
{
  RdNItemSFunc p= fCI->dt.ReadNextItem; if (!p) return LOCERR_NOTIMP;
  return       p( (CContext)aContext, aID, aItemData, aStatus, aFirst );
} // ReadNextItem


TSyError TEngineModuleBridge::ReadItem( SessionH aContext, cItemID aID, appCharP *aItemData )
{
  Rd_ItemSFunc p= fCI->dt.ReadItem; if (!p) return LOCERR_NOTIMP;
  return       p( (CContext)aContext, aID, aItemData );
} // ReadItem


TSyError TEngineModuleBridge::EndDataRead( SessionH aContext )
{
  EDR_Func     p= fCI->dt.EndDataRead; if (!p) return LOCERR_NOTIMP;
  return       p( (CContext)aContext );
} // EndDataRead


TSyError TEngineModuleBridge::StartDataWrite( SessionH aContext )
{
  SDW_Func     p= fCI->dt.StartDataWrite; if (!p) return LOCERR_NOTIMP;
  return       p( (CContext)aContext );
} // StartDataWrite


TSyError TEngineModuleBridge::InsertItem( SessionH aContext, cAppCharP aItemData, ItemID aID )
{
  InsItemSFunc p= fCI->dt.InsertItem; if (!p) return LOCERR_NOTIMP;
  return       p( (CContext)aContext, aItemData, aID );
} // InsertItem


TSyError TEngineModuleBridge::UpdateItem( SessionH aContext, cAppCharP aItemData, cItemID   aID,
                                                                                   ItemID updID )
{
  UpdItemSFunc p= fCI->dt.UpdateItem; if (!p) return LOCERR_NOTIMP;
  return       p( (CContext)aContext, aItemData, aID, updID  );
} // UpdateItem


TSyError TEngineModuleBridge::MoveItem( SessionH aContext, cItemID aID, cAppCharP newParID )
{
  MovItem_Func p= fCI->dt.MoveItem; if (!p) return LOCERR_NOTIMP;
  return       p( (CContext)aContext, aID, newParID );
} // MoveItem


TSyError TEngineModuleBridge::DeleteItem( SessionH aContext, cItemID aID )
{
  DelItem_Func p= fCI->dt.DeleteItem; if (!p) return LOCERR_NOTIMP;
  return       p( (CContext)aContext, aID );
} // DeleteItem


TSyError TEngineModuleBridge::EndDataWrite( SessionH aContext, bool success, appCharP *newToken )
{
  EDW_Func     p= fCI->dt.EndDataWrite; if (!p) return LOCERR_NOTIMP;
  return       p( (CContext)aContext, success, newToken );
} // EndDataWrite


void     TEngineModuleBridge::DisposeObj( SessionH aContext, void* memory )
{
  DisposeProc  p= fCI->dt.DisposeObj; if (!p) return;
               p( (CContext)aContext, memory );
} // DisposeObj


// --- asKey ---
TSyError TEngineModuleBridge::ReadNextItemAsKey( SessionH aContext, ItemID  aID,     KeyH aItemKey,
                                                                    sInt32 *aStatus, bool aFirst )
{
  RdNItemKFunc p= fCI->dt.ReadNextItemAsKey; if (!p) return LOCERR_NOTIMP;
  return       p( (CContext)aContext, aID, aItemKey, aStatus, aFirst );
} // ReadNextItemAsKey


TSyError TEngineModuleBridge::ReadItemAsKey( SessionH aContext, cItemID aID, KeyH aItemKey )
{
  Rd_ItemKFunc p= fCI->dt.ReadItemAsKey; if (!p) return LOCERR_NOTIMP;
  return       p( (CContext)aContext, aID, aItemKey );
} // ReadItemAsKey


TSyError TEngineModuleBridge::InsertItemAsKey( SessionH aContext, KeyH aItemKey, ItemID aID )
{
  InsItemKFunc p= fCI->dt.InsertItemAsKey; if (!p) return LOCERR_NOTIMP;
  return       p( (CContext)aContext, aItemKey, aID );
} // InsertItemAsKey


TSyError TEngineModuleBridge::UpdateItemAsKey( SessionH aContext, KeyH aItemKey, cItemID   aID,
                                                                                  ItemID updID )
{
  UpdItemKFunc p= fCI->dt.UpdateItemAsKey; if (!p) return LOCERR_NOTIMP;
  return       p( (CContext)aContext, aItemKey, aID, updID  );
} // UpdateItemAsKey





} // namespace sysync
/* eof */